Pārlūkot izejas kodu

refactor(server): Move constants into shared

Michael Bromley 7 gadi atpakaļ
vecāks
revīzija
98cdeaf30e

+ 1 - 2
server/e2e/auth.e2e-spec.ts

@@ -9,10 +9,10 @@ import {
     CreateProductVariables,
     CreateRole,
     CreateRoleVariables,
-    GetProductList,
     Permission,
     UpdateProductVariables,
 } from 'shared/generated-types';
+import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from 'shared/shared-constants';
 
 import {
     ASSIGN_ROLE_TO_ADMINISTRATOR,
@@ -25,7 +25,6 @@ import {
     GET_PRODUCT_LIST,
     UPDATE_PRODUCT,
 } from '../../admin-ui/src/app/data/definitions/product-definitions';
-import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from '../src/common/constants';
 
 import { TestClient } from './test-client';
 import { TestServer } from './test-server';

+ 0 - 4
server/e2e/test-client.ts

@@ -1,9 +1,5 @@
-import { AttemptLogin, AttemptLoginVariables } from 'shared/generated-types';
-
-import { ATTEMPT_LOGIN } from '../../admin-ui/src/app/data/definitions/auth-definitions';
 import { getDefaultChannelToken } from '../mock-data/get-default-channel-token';
 import { SimpleGraphQLClient } from '../mock-data/simple-graphql-client';
-import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from '../src/common/constants';
 
 import { testConfig } from './config/test-config';
 

+ 1 - 1
server/mock-data/get-default-channel-token.ts

@@ -1,6 +1,6 @@
+import { DEFAULT_CHANNEL_CODE } from 'shared/shared-constants';
 import { ConnectionOptions, getConnection } from 'typeorm';
 
-import { DEFAULT_CHANNEL_CODE } from '../src/common/constants';
 import { Channel } from '../src/entity/channel/channel.entity';
 
 // tslint:disable:no-console

+ 1 - 1
server/mock-data/simple-graphql-client.ts

@@ -3,9 +3,9 @@ import { GraphQLClient } from 'graphql-request';
 import { GraphQLError } from 'graphql-request/dist/src/types';
 import { print } from 'graphql/language/printer';
 import { AttemptLogin, AttemptLoginVariables } from 'shared/generated-types';
+import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from 'shared/shared-constants';
 
 import { ATTEMPT_LOGIN } from '../../admin-ui/src/app/data/definitions/auth-definitions';
-import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from '../src/common/constants';
 import { getConfig } from '../src/config/vendure-config';
 
 // tslint:disable:no-console

+ 0 - 7
server/src/common/constants.ts

@@ -1,10 +1,3 @@
 import { LanguageCode } from 'shared/generated-types';
 
 export const DEFAULT_LANGUAGE_CODE = LanguageCode.en;
-export const DEFAULT_CHANNEL_CODE = '__default_channel__';
-export const SUPER_ADMIN_ROLE_CODE = '__super_admin_role__';
-export const SUPER_ADMIN_ROLE_DESCRIPTION = 'SuperAdmin';
-export const SUPER_ADMIN_USER_IDENTIFIER = 'superadmin';
-export const SUPER_ADMIN_USER_PASSWORD = 'superadmin';
-export const CUSTOMER_ROLE_CODE = '__customer_role__';
-export const CUSTOMER_ROLE_DESCRIPTION = 'Customer';

+ 1 - 1
server/src/service/administrator.service.ts

@@ -1,9 +1,9 @@
 import { Injectable } from '@nestjs/common';
 import { InjectConnection } from '@nestjs/typeorm';
+import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from 'shared/shared-constants';
 import { ID, PaginatedList } from 'shared/shared-types';
 import { Connection } from 'typeorm';
 
-import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from '../common/constants';
 import { ListQueryOptions } from '../common/types/common-types';
 import { CreateAdministratorDto } from '../entity/administrator/administrator.dto';
 import { Administrator } from '../entity/administrator/administrator.entity';

+ 2 - 1
server/src/service/channel.service.ts

@@ -1,9 +1,10 @@
 import { Injectable } from '@nestjs/common';
 import { InjectConnection } from '@nestjs/typeorm';
+import { DEFAULT_CHANNEL_CODE } from 'shared/shared-constants';
 import { Connection } from 'typeorm';
 
 import { RequestContext } from '../api/common/request-context';
-import { DEFAULT_CHANNEL_CODE, DEFAULT_LANGUAGE_CODE } from '../common/constants';
+import { DEFAULT_LANGUAGE_CODE } from '../common/constants';
 import { ChannelAware } from '../common/types/common-types';
 import { Channel } from '../entity/channel/channel.entity';
 import { I18nError } from '../i18n/i18n-error';

+ 4 - 4
server/src/service/role.service.ts

@@ -1,14 +1,14 @@
 import { Injectable } from '@nestjs/common';
 import { CreateRoleInput, Permission, UpdateRoleInput } from 'shared/generated-types';
-import { ID, PaginatedList } from 'shared/shared-types';
-import { Connection } from 'typeorm';
-
 import {
     CUSTOMER_ROLE_CODE,
     CUSTOMER_ROLE_DESCRIPTION,
     SUPER_ADMIN_ROLE_CODE,
     SUPER_ADMIN_ROLE_DESCRIPTION,
-} from '../common/constants';
+} from 'shared/shared-constants';
+import { ID, PaginatedList } from 'shared/shared-types';
+import { Connection } from 'typeorm';
+
 import { ListQueryOptions } from '../common/types/common-types';
 import { assertFound } from '../common/utils';
 import { Role } from '../entity/role/role.entity';

+ 7 - 0
shared/shared-constants.ts

@@ -4,3 +4,10 @@
  */
 export const API_PORT = 3000;
 export const API_PATH = 'api';
+export const DEFAULT_CHANNEL_CODE = '__default_channel__';
+export const SUPER_ADMIN_ROLE_CODE = '__super_admin_role__';
+export const SUPER_ADMIN_ROLE_DESCRIPTION = 'SuperAdmin';
+export const SUPER_ADMIN_USER_IDENTIFIER = 'superadmin';
+export const SUPER_ADMIN_USER_PASSWORD = 'superadmin';
+export const CUSTOMER_ROLE_CODE = '__customer_role__';
+export const CUSTOMER_ROLE_DESCRIPTION = 'Customer';