Просмотр исходного кода

refactor(server): Move config helpers into own file

Michael Bromley 7 лет назад
Родитель
Сommit
3572cde85d

+ 2 - 1
server/mock-data/populate.ts

@@ -2,7 +2,8 @@ import { INestApplication } from '@nestjs/common';
 
 
 import { Channel } from '../../shared/generated-types';
 import { Channel } from '../../shared/generated-types';
 import { VendureBootstrapFunction } from '../src/bootstrap';
 import { VendureBootstrapFunction } from '../src/bootstrap';
-import { setConfig, VendureConfig } from '../src/config/vendure-config';
+import { setConfig } from '../src/config/config-helpers';
+import { VendureConfig } from '../src/config/vendure-config';
 
 
 import { clearAllTables } from './clear-all-tables';
 import { clearAllTables } from './clear-all-tables';
 import { getDefaultChannelToken } from './get-default-channel-token';
 import { getDefaultChannelToken } from './get-default-channel-token';

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

@@ -7,7 +7,7 @@ import { Curl } from 'node-libcurl';
 import { CREATE_ASSETS } from '../../admin-ui/src/app/data/definitions/product-definitions';
 import { CREATE_ASSETS } from '../../admin-ui/src/app/data/definitions/product-definitions';
 import { CreateAssets, ImportInfo } from '../../shared/generated-types';
 import { CreateAssets, ImportInfo } from '../../shared/generated-types';
 import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from '../../shared/shared-constants';
 import { SUPER_ADMIN_USER_IDENTIFIER, SUPER_ADMIN_USER_PASSWORD } from '../../shared/shared-constants';
-import { getConfig } from '../src/config/vendure-config';
+import { getConfig } from '../src/config/config-helpers';
 
 
 import { createUploadPostData } from './create-upload-post-data';
 import { createUploadPostData } from './create-upload-post-data';
 
 

+ 2 - 1
server/src/api/resolvers/config.resolver.ts

@@ -1,7 +1,8 @@
 import { Query, Resolver } from '@nestjs/graphql';
 import { Query, Resolver } from '@nestjs/graphql';
 
 
+import { getConfig } from '../../config/config-helpers';
 import { ConfigService } from '../../config/config.service';
 import { ConfigService } from '../../config/config.service';
-import { getConfig, VendureConfig } from '../../config/vendure-config';
+import { VendureConfig } from '../../config/vendure-config';
 
 
 @Resolver('Config')
 @Resolver('Config')
 export class ConfigResolver {
 export class ConfigResolver {

+ 2 - 1
server/src/bootstrap.ts

@@ -5,7 +5,8 @@ import { EntitySubscriberInterface } from 'typeorm';
 import { Type } from '../../shared/shared-types';
 import { Type } from '../../shared/shared-types';
 
 
 import { ReadOnlyRequired } from './common/types/common-types';
 import { ReadOnlyRequired } from './common/types/common-types';
-import { getConfig, setConfig, VendureConfig } from './config/vendure-config';
+import { getConfig, setConfig } from './config/config-helpers';
+import { VendureConfig } from './config/vendure-config';
 import { VendureEntity } from './entity/base/base.entity';
 import { VendureEntity } from './entity/base/base.entity';
 import { registerCustomEntityFields } from './entity/custom-entity-fields';
 import { registerCustomEntityFields } from './entity/custom-entity-fields';
 
 

+ 40 - 0
server/src/config/config-helpers.ts

@@ -0,0 +1,40 @@
+import { DeepPartial } from '../../../shared/shared-types';
+import { ReadOnlyRequired } from '../common/types/common-types';
+
+import { defaultConfig } from './default-config';
+import { mergeConfig } from './merge-config';
+import { VendureConfig } from './vendure-config';
+
+let activeConfig = defaultConfig;
+
+/**
+ * Override the default config by merging in the supplied values. Should only be used prior to
+ * bootstrapping the app.
+ */
+export function setConfig(userConfig: DeepPartial<VendureConfig>): void {
+    activeConfig = mergeConfig(activeConfig, userConfig);
+}
+
+/**
+ * Returns the app config object. In general this function should only be
+ * used before bootstrapping the app. In all other contexts, the {@link ConfigService}
+ * should be used to access config settings.
+ */
+export function getConfig(): ReadOnlyRequired<VendureConfig> {
+    return activeConfig;
+}
+
+/**
+ * Returns the type argument to be passed to the PrimaryGeneratedColumn() decorator
+ * of the base VendureEntity.
+ */
+export function primaryKeyType(): any {
+    return activeConfig.entityIdStrategy.primaryKeyType;
+}
+
+/**
+ * Returns the DB data type of ID columns based on the configured primaryKeyType
+ */
+export function idType(): 'int' | 'varchar' {
+    return activeConfig.entityIdStrategy.primaryKeyType === 'increment' ? 'int' : 'varchar';
+}

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

@@ -7,12 +7,12 @@ import { LanguageCode } from '../../../shared/generated-types';
 import { CustomFields } from '../../../shared/shared-types';
 import { CustomFields } from '../../../shared/shared-types';
 import { ReadOnlyRequired } from '../common/types/common-types';
 import { ReadOnlyRequired } from '../common/types/common-types';
 
 
+import { getConfig } from './config-helpers';
 import { EntityIdStrategy } from './entity-id-strategy/entity-id-strategy';
 import { EntityIdStrategy } from './entity-id-strategy/entity-id-strategy';
 import {
 import {
     AssetOptions,
     AssetOptions,
     AuthOptions,
     AuthOptions,
     EmailOptions,
     EmailOptions,
-    getConfig,
     ImportExportOptions,
     ImportExportOptions,
     OrderMergeOptions,
     OrderMergeOptions,
     OrderProcessOptions,
     OrderProcessOptions,

+ 277 - 314
server/src/config/vendure-config.ts

@@ -1,314 +1,277 @@
-import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
-import { RequestHandler } from 'express';
-import { Observable } from 'rxjs';
-import { ConnectionOptions } from 'typeorm';
-
-import { LanguageCode } from '../../../shared/generated-types';
-import { CustomFields, DeepPartial } from '../../../shared/shared-types';
-import { Transitions } from '../common/finite-state-machine';
-import { ReadOnlyRequired } from '../common/types/common-types';
-import { Order } from '../entity/order/order.entity';
-import { OrderState } from '../service/helpers/order-state-machine/order-state';
-
-import { AssetNamingStrategy } from './asset-naming-strategy/asset-naming-strategy';
-import { AssetPreviewStrategy } from './asset-preview-strategy/asset-preview-strategy';
-import { AssetStorageStrategy } from './asset-storage-strategy/asset-storage-strategy';
-import { defaultConfig } from './default-config';
-import { EmailGenerator, EmailTypes } from './email/email-options';
-import { EmailTransportOptions } from './email/email-transport-options';
-import { EntityIdStrategy } from './entity-id-strategy/entity-id-strategy';
-import { mergeConfig } from './merge-config';
-import { OrderMergeStrategy } from './order-merge-strategy/order-merge-strategy';
-import { PaymentMethodHandler } from './payment-method/payment-method-handler';
-import { PromotionAction } from './promotion/promotion-action';
-import { PromotionCondition } from './promotion/promotion-condition';
-import { ShippingCalculator } from './shipping-method/shipping-calculator';
-import { ShippingEligibilityChecker } from './shipping-method/shipping-eligibility-checker';
-import { VendurePlugin } from './vendure-plugin/vendure-plugin';
-
-export interface AuthOptions {
-    /**
-     * Disable authentication & permissions checks.
-     * NEVER set the to true in production. It exists
-     * only to aid certain development tasks.
-     */
-    disableAuth?: boolean;
-    /**
-     * Sets the method by which the session token is delivered and read.
-     *
-     * - "cookie": Upon login, a 'Set-Cookie' header will be returned to the client, setting a
-     *   cookie containing the session token. A browser-based client (making requests with credentials)
-     *   should automatically send the session cookie with each request.
-     * - "bearer": Upon login, the token is returned in the response and should be then stored by the
-     *   client app. Each request should include the header "Authorization: Bearer <token>".
-     */
-    tokenMethod?: 'cookie' | 'bearer';
-    /**
-     * The secret used for signing the session cookies for authenticated users. Only applies when
-     * tokenMethod is set to "cookie".
-     *
-     * In production applications, this should not be stored as a string in
-     * source control for security reasons, but may be loaded from an external
-     * file not under source control, or from an environment variable, for example.
-     * See https://stackoverflow.com/a/30090120/772859
-     */
-    sessionSecret?: string;
-    /**
-     * Sets the header property which will be used to send the auth token when using the "bearer" method.
-     */
-    authTokenHeaderKey?: string;
-    /**
-     * Session duration, i.e. the time which must elapse from the last authenticted request
-     * after which the user must re-authenticate.
-     *
-     * Expressed as a string describing a time span
-     * [zeit/ms](https://github.com/zeit/ms.js).  Eg: 60, "2 days", "10h", "7d"
-     */
-    sessionDuration?: string | number;
-    /**
-     * Determines whether new User accounts require verification of their email address.
-     */
-    requireVerification?: boolean;
-    /**
-     * Sets the length of time that a verification token is valid for.
-     *
-     * Expressed as a string describing a time span
-     * [zeit/ms](https://github.com/zeit/ms.js).  Eg: 60, "2 days", "10h", "7d"
-     */
-    verificationTokenDuration?: string | number;
-}
-
-export interface OrderProcessOptions<T extends string> {
-    /**
-     * Define how the custom states fit in with the default order
-     * state transitions.
-     */
-    transtitions?: Partial<Transitions<T | OrderState>>;
-    /**
-     * Define logic to run before a state tranition takes place. Returning
-     * false will prevent the transition from going ahead.
-     */
-    onTransitionStart?(
-        fromState: T,
-        toState: T,
-        data: { order: Order },
-    ): boolean | Promise<boolean> | Observable<boolean> | void;
-    /**
-     * Define logic to run after a state transition has taken place.
-     */
-    onTransitionEnd?(fromState: T, toState: T, data: { order: Order }): void;
-    /**
-     * Define a custom error handler function for transition errors.
-     */
-    onError?(fromState: T, toState: T, message?: string): void;
-}
-
-export interface OrderMergeOptions {
-    /**
-     * Defines the strategy used to merge a guest Order and an existing Order when
-     * signing in.
-     */
-    mergeStrategy: OrderMergeStrategy;
-    /**
-     * Defines the strategy used to merge a guest Order and an existing Order when
-     * signing in as part of the checkout flow.
-     */
-    checkoutMergeStrategy: OrderMergeStrategy;
-}
-
-export interface AssetOptions {
-    /**
-     * Defines how asset files and preview images are named before being saved.
-     */
-    assetNamingStrategy: AssetNamingStrategy;
-    /**
-     * Defines the strategy used for storing uploaded binary files. By default files are
-     * persisted to the local file system.
-     */
-    assetStorageStrategy: AssetStorageStrategy;
-    /**
-     * Defines the strategy used for creating preview images of uploaded assets. The default
-     * strategy resizes images based on maximum dimensions and outputs a sensible default
-     * preview image for other file types.
-     */
-    assetPreviewStrategy: AssetPreviewStrategy;
-    /**
-     * The max file size in bytes for uploaded assets.
-     */
-    uploadMaxFileSize?: number;
-}
-
-export interface PromotionOptions {
-    /**
-     * An array of conditions which can be used to construct Promotions
-     */
-    promotionConditions?: Array<PromotionCondition<any>>;
-    /**
-     * An array of actions which can be used to construct Promotions
-     */
-    promotionActions?: Array<PromotionAction<any>>;
-}
-
-export interface ShippingOptions {
-    /**
-     * An array of available ShippingEligibilityCheckers for use in configuring ShippingMethods
-     */
-    shippingEligibilityCheckers?: Array<ShippingEligibilityChecker<any>>;
-    /**
-     * An array of available ShippingCalculator for use in configuring ShippingMethods
-     */
-    shippingCalculators?: Array<ShippingCalculator<any>>;
-}
-
-export interface EmailOptions<EmailType extends string> {
-    /**
-     * Configuration for the creation and templating of each email type
-     */
-    emailTypes?: EmailTypes<EmailType>;
-    /**
-     * The EmailGenerator uses the EmailContext and template to generate the email body
-     */
-    generator?: EmailGenerator;
-    /**
-     * Configuration for the transport (email sending) method
-     */
-    transport: EmailTransportOptions;
-}
-
-export interface PaymentOptions {
-    /**
-     * An array of payment methods with which to process payments.
-     */
-    paymentMethodHandlers: Array<PaymentMethodHandler<any>>;
-}
-
-export interface ImportExportOptions {
-    /**
-     * The directory in which assets to be imported are located.
-     */
-    importAssetsDir?: string;
-}
-
-export interface VendureConfig {
-    /**
-     * The name of the property which contains the token of the
-     * active channel. This property can be included either in
-     * the request header or as a query string.
-     */
-    channelTokenKey?: string;
-    /**
-     * The token for the default channel. If not specified, a token
-     * will be randomly generated.
-     */
-    defaultChannelToken?: string | null;
-    /**
-     * The default languageCode of the app.
-     */
-    defaultLanguageCode?: LanguageCode;
-    /**
-     * The path to the GraphQL API.
-     */
-    apiPath?: string;
-    /**
-     * Set the CORS handling for the server.
-     */
-    cors?: boolean | CorsOptions;
-    /**
-     * Which port the Vendure server should listen on.
-     */
-    port: number;
-    /**
-     * Configuration for authorization.
-     */
-    authOptions: AuthOptions;
-    /**
-     * Configuration for the handling of Assets.
-     */
-    assetOptions?: AssetOptions;
-    /**
-     * Defines the strategy used for both storing the primary keys of entities
-     * in the database, and the encoding & decoding of those ids when exposing
-     * entities via the API. The default uses a simple auto-increment integer
-     * strategy.
-     */
-    entityIdStrategy?: EntityIdStrategy<any>;
-    /**
-     * The connection options used by TypeORM to connect to the database.
-     */
-    dbConnectionOptions: ConnectionOptions;
-    /**
-     * Configures the Conditions and Actions available when creating Promotions.
-     */
-    promotionOptions?: PromotionOptions;
-    /**
-     * Configures the available checkers and calculators for ShippingMethods.
-     */
-    shippingOptions?: ShippingOptions;
-    /**
-     * Defines custom fields which can be used to extend the built-in entities.
-     */
-    customFields?: CustomFields;
-    /**
-     * Defines custom states in the order process finite state machine.
-     */
-    orderProcessOptions?: OrderProcessOptions<any>;
-    /**
-     * Define the strategies governing how Orders are merged when an existing
-     * Customer signs in.
-     */
-    orderMergeOptions?: OrderMergeOptions;
-    /**
-     * Configures available payment processing methods.
-     */
-    paymentOptions: PaymentOptions;
-    /**
-     * Configures the handling of transactional emails.
-     */
-    emailOptions: EmailOptions<any>;
-    /**
-     * Configuration settings for data import and export.
-     */
-    importExportOptions?: ImportExportOptions;
-    /**
-     * Custom Express middleware for the server.
-     */
-    middleware?: Array<{ handler: RequestHandler; route: string }>;
-    /**
-     * An array of plugins.
-     */
-    plugins?: VendurePlugin[];
-}
-
-let activeConfig = defaultConfig;
-
-/**
- * Override the default config by merging in the supplied values. Should only be used prior to
- * bootstrapping the app.
- */
-export function setConfig(userConfig: DeepPartial<VendureConfig>): void {
-    activeConfig = mergeConfig(activeConfig, userConfig);
-}
-
-/**
- * Returns the app config object. In general this function should only be
- * used before bootstrapping the app. In all other contexts, the {@link ConfigService}
- * should be used to access config settings.
- */
-export function getConfig(): ReadOnlyRequired<VendureConfig> {
-    return activeConfig;
-}
-
-/**
- * Returns the type argument to be passed to the PrimaryGeneratedColumn() decorator
- * of the base VendureEntity.
- */
-export function primaryKeyType(): any {
-    return activeConfig.entityIdStrategy.primaryKeyType;
-}
-
-/**
- * Returns the DB data type of ID columns based on the configured primaryKeyType
- */
-export function idType(): 'int' | 'varchar' {
-    return activeConfig.entityIdStrategy.primaryKeyType === 'increment' ? 'int' : 'varchar';
-}
+import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
+import { RequestHandler } from 'express';
+import { Observable } from 'rxjs';
+import { ConnectionOptions } from 'typeorm';
+
+import { LanguageCode } from '../../../shared/generated-types';
+import { CustomFields } from '../../../shared/shared-types';
+import { Transitions } from '../common/finite-state-machine';
+import { Order } from '../entity/order/order.entity';
+import { OrderState } from '../service/helpers/order-state-machine/order-state';
+
+import { AssetNamingStrategy } from './asset-naming-strategy/asset-naming-strategy';
+import { AssetPreviewStrategy } from './asset-preview-strategy/asset-preview-strategy';
+import { AssetStorageStrategy } from './asset-storage-strategy/asset-storage-strategy';
+import { EmailGenerator, EmailTypes } from './email/email-options';
+import { EmailTransportOptions } from './email/email-transport-options';
+import { EntityIdStrategy } from './entity-id-strategy/entity-id-strategy';
+import { OrderMergeStrategy } from './order-merge-strategy/order-merge-strategy';
+import { PaymentMethodHandler } from './payment-method/payment-method-handler';
+import { PromotionAction } from './promotion/promotion-action';
+import { PromotionCondition } from './promotion/promotion-condition';
+import { ShippingCalculator } from './shipping-method/shipping-calculator';
+import { ShippingEligibilityChecker } from './shipping-method/shipping-eligibility-checker';
+import { VendurePlugin } from './vendure-plugin/vendure-plugin';
+
+export interface AuthOptions {
+    /**
+     * Disable authentication & permissions checks.
+     * NEVER set the to true in production. It exists
+     * only to aid certain development tasks.
+     */
+    disableAuth?: boolean;
+    /**
+     * Sets the method by which the session token is delivered and read.
+     *
+     * - "cookie": Upon login, a 'Set-Cookie' header will be returned to the client, setting a
+     *   cookie containing the session token. A browser-based client (making requests with credentials)
+     *   should automatically send the session cookie with each request.
+     * - "bearer": Upon login, the token is returned in the response and should be then stored by the
+     *   client app. Each request should include the header "Authorization: Bearer <token>".
+     */
+    tokenMethod?: 'cookie' | 'bearer';
+    /**
+     * The secret used for signing the session cookies for authenticated users. Only applies when
+     * tokenMethod is set to "cookie".
+     *
+     * In production applications, this should not be stored as a string in
+     * source control for security reasons, but may be loaded from an external
+     * file not under source control, or from an environment variable, for example.
+     * See https://stackoverflow.com/a/30090120/772859
+     */
+    sessionSecret?: string;
+    /**
+     * Sets the header property which will be used to send the auth token when using the "bearer" method.
+     */
+    authTokenHeaderKey?: string;
+    /**
+     * Session duration, i.e. the time which must elapse from the last authenticted request
+     * after which the user must re-authenticate.
+     *
+     * Expressed as a string describing a time span
+     * [zeit/ms](https://github.com/zeit/ms.js).  Eg: 60, "2 days", "10h", "7d"
+     */
+    sessionDuration?: string | number;
+    /**
+     * Determines whether new User accounts require verification of their email address.
+     */
+    requireVerification?: boolean;
+    /**
+     * Sets the length of time that a verification token is valid for.
+     *
+     * Expressed as a string describing a time span
+     * [zeit/ms](https://github.com/zeit/ms.js).  Eg: 60, "2 days", "10h", "7d"
+     */
+    verificationTokenDuration?: string | number;
+}
+
+export interface OrderProcessOptions<T extends string> {
+    /**
+     * Define how the custom states fit in with the default order
+     * state transitions.
+     */
+    transtitions?: Partial<Transitions<T | OrderState>>;
+    /**
+     * Define logic to run before a state tranition takes place. Returning
+     * false will prevent the transition from going ahead.
+     */
+    onTransitionStart?(
+        fromState: T,
+        toState: T,
+        data: { order: Order },
+    ): boolean | Promise<boolean> | Observable<boolean> | void;
+    /**
+     * Define logic to run after a state transition has taken place.
+     */
+    onTransitionEnd?(fromState: T, toState: T, data: { order: Order }): void;
+    /**
+     * Define a custom error handler function for transition errors.
+     */
+    onError?(fromState: T, toState: T, message?: string): void;
+}
+
+export interface OrderMergeOptions {
+    /**
+     * Defines the strategy used to merge a guest Order and an existing Order when
+     * signing in.
+     */
+    mergeStrategy: OrderMergeStrategy;
+    /**
+     * Defines the strategy used to merge a guest Order and an existing Order when
+     * signing in as part of the checkout flow.
+     */
+    checkoutMergeStrategy: OrderMergeStrategy;
+}
+
+export interface AssetOptions {
+    /**
+     * Defines how asset files and preview images are named before being saved.
+     */
+    assetNamingStrategy: AssetNamingStrategy;
+    /**
+     * Defines the strategy used for storing uploaded binary files. By default files are
+     * persisted to the local file system.
+     */
+    assetStorageStrategy: AssetStorageStrategy;
+    /**
+     * Defines the strategy used for creating preview images of uploaded assets. The default
+     * strategy resizes images based on maximum dimensions and outputs a sensible default
+     * preview image for other file types.
+     */
+    assetPreviewStrategy: AssetPreviewStrategy;
+    /**
+     * The max file size in bytes for uploaded assets.
+     */
+    uploadMaxFileSize?: number;
+}
+
+export interface PromotionOptions {
+    /**
+     * An array of conditions which can be used to construct Promotions
+     */
+    promotionConditions?: Array<PromotionCondition<any>>;
+    /**
+     * An array of actions which can be used to construct Promotions
+     */
+    promotionActions?: Array<PromotionAction<any>>;
+}
+
+export interface ShippingOptions {
+    /**
+     * An array of available ShippingEligibilityCheckers for use in configuring ShippingMethods
+     */
+    shippingEligibilityCheckers?: Array<ShippingEligibilityChecker<any>>;
+    /**
+     * An array of available ShippingCalculator for use in configuring ShippingMethods
+     */
+    shippingCalculators?: Array<ShippingCalculator<any>>;
+}
+
+export interface EmailOptions<EmailType extends string> {
+    /**
+     * Configuration for the creation and templating of each email type
+     */
+    emailTypes?: EmailTypes<EmailType>;
+    /**
+     * The EmailGenerator uses the EmailContext and template to generate the email body
+     */
+    generator?: EmailGenerator;
+    /**
+     * Configuration for the transport (email sending) method
+     */
+    transport: EmailTransportOptions;
+}
+
+export interface PaymentOptions {
+    /**
+     * An array of payment methods with which to process payments.
+     */
+    paymentMethodHandlers: Array<PaymentMethodHandler<any>>;
+}
+
+export interface ImportExportOptions {
+    /**
+     * The directory in which assets to be imported are located.
+     */
+    importAssetsDir?: string;
+}
+
+export interface VendureConfig {
+    /**
+     * The name of the property which contains the token of the
+     * active channel. This property can be included either in
+     * the request header or as a query string.
+     */
+    channelTokenKey?: string;
+    /**
+     * The token for the default channel. If not specified, a token
+     * will be randomly generated.
+     */
+    defaultChannelToken?: string | null;
+    /**
+     * The default languageCode of the app.
+     */
+    defaultLanguageCode?: LanguageCode;
+    /**
+     * The path to the GraphQL API.
+     */
+    apiPath?: string;
+    /**
+     * Set the CORS handling for the server.
+     */
+    cors?: boolean | CorsOptions;
+    /**
+     * Which port the Vendure server should listen on.
+     */
+    port: number;
+    /**
+     * Configuration for authorization.
+     */
+    authOptions: AuthOptions;
+    /**
+     * Configuration for the handling of Assets.
+     */
+    assetOptions?: AssetOptions;
+    /**
+     * Defines the strategy used for both storing the primary keys of entities
+     * in the database, and the encoding & decoding of those ids when exposing
+     * entities via the API. The default uses a simple auto-increment integer
+     * strategy.
+     */
+    entityIdStrategy?: EntityIdStrategy<any>;
+    /**
+     * The connection options used by TypeORM to connect to the database.
+     */
+    dbConnectionOptions: ConnectionOptions;
+    /**
+     * Configures the Conditions and Actions available when creating Promotions.
+     */
+    promotionOptions?: PromotionOptions;
+    /**
+     * Configures the available checkers and calculators for ShippingMethods.
+     */
+    shippingOptions?: ShippingOptions;
+    /**
+     * Defines custom fields which can be used to extend the built-in entities.
+     */
+    customFields?: CustomFields;
+    /**
+     * Defines custom states in the order process finite state machine.
+     */
+    orderProcessOptions?: OrderProcessOptions<any>;
+    /**
+     * Define the strategies governing how Orders are merged when an existing
+     * Customer signs in.
+     */
+    orderMergeOptions?: OrderMergeOptions;
+    /**
+     * Configures available payment processing methods.
+     */
+    paymentOptions: PaymentOptions;
+    /**
+     * Configures the handling of transactional emails.
+     */
+    emailOptions: EmailOptions<any>;
+    /**
+     * Configuration settings for data import and export.
+     */
+    importExportOptions?: ImportExportOptions;
+    /**
+     * Custom Express middleware for the server.
+     */
+    middleware?: Array<{ handler: RequestHandler; route: string }>;
+    /**
+     * An array of plugins.
+     */
+    plugins?: VendurePlugin[];
+}

+ 2 - 1
server/src/data-import/import-cli.ts

@@ -3,7 +3,8 @@ import * as path from 'path';
 import { devConfig } from '../../dev-config';
 import { devConfig } from '../../dev-config';
 import { SimpleGraphQLClient } from '../../mock-data/simple-graphql-client';
 import { SimpleGraphQLClient } from '../../mock-data/simple-graphql-client';
 import { bootstrap } from '../bootstrap';
 import { bootstrap } from '../bootstrap';
-import { setConfig, VendureConfig } from '../config/vendure-config';
+import { setConfig } from '../config/config-helpers';
+import { VendureConfig } from '../config/vendure-config';
 
 
 // tslint:disable:no-console
 // tslint:disable:no-console
 /**
 /**

+ 1 - 1
server/src/entity/base/base.entity.ts

@@ -1,7 +1,7 @@
 import { CreateDateColumn, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
 import { CreateDateColumn, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
 
 
 import { DeepPartial, ID } from '../../../../shared/shared-types';
 import { DeepPartial, ID } from '../../../../shared/shared-types';
-import { primaryKeyType } from '../../config/vendure-config';
+import { primaryKeyType } from '../../config/config-helpers';
 
 
 const keyType = primaryKeyType();
 const keyType = primaryKeyType();
 
 

+ 1 - 1
server/src/entity/order/order.entity.ts

@@ -3,7 +3,7 @@ import { Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany } from 'typ
 import { Adjustment, AdjustmentType, ShippingAddress } from '../../../../shared/generated-types';
 import { Adjustment, AdjustmentType, ShippingAddress } from '../../../../shared/generated-types';
 import { DeepPartial, ID } from '../../../../shared/shared-types';
 import { DeepPartial, ID } from '../../../../shared/shared-types';
 import { Calculated } from '../../common/calculated-decorator';
 import { Calculated } from '../../common/calculated-decorator';
-import { idType } from '../../config/vendure-config';
+import { idType } from '../../config/config-helpers';
 import { OrderState } from '../../service/helpers/order-state-machine/order-state';
 import { OrderState } from '../../service/helpers/order-state-machine/order-state';
 import { VendureEntity } from '../base/base.entity';
 import { VendureEntity } from '../base/base.entity';
 import { Customer } from '../customer/customer.entity';
 import { Customer } from '../customer/customer.entity';

+ 1 - 1
server/src/entity/payment-method/payment-method.entity.ts

@@ -3,7 +3,7 @@ import { Column, Entity } from 'typeorm';
 import { ConfigArg } from '../../../../shared/generated-types';
 import { ConfigArg } from '../../../../shared/generated-types';
 import { DeepPartial } from '../../../../shared/shared-types';
 import { DeepPartial } from '../../../../shared/shared-types';
 import { UserInputError } from '../../common/error/errors';
 import { UserInputError } from '../../common/error/errors';
-import { getConfig } from '../../config/vendure-config';
+import { getConfig } from '../../config/config-helpers';
 import { VendureEntity } from '../base/base.entity';
 import { VendureEntity } from '../base/base.entity';
 import { Order } from '../order/order.entity';
 import { Order } from '../order/order.entity';
 import { Payment, PaymentMetadata } from '../payment/payment.entity';
 import { Payment, PaymentMetadata } from '../payment/payment.entity';

+ 1 - 1
server/src/entity/promotion/promotion.entity.ts

@@ -4,9 +4,9 @@ import { Adjustment, AdjustmentOperation, AdjustmentType } from '../../../../sha
 import { DeepPartial } from '../../../../shared/shared-types';
 import { DeepPartial } from '../../../../shared/shared-types';
 import { AdjustmentSource } from '../../common/types/adjustment-source';
 import { AdjustmentSource } from '../../common/types/adjustment-source';
 import { ChannelAware } from '../../common/types/common-types';
 import { ChannelAware } from '../../common/types/common-types';
+import { getConfig } from '../../config/config-helpers';
 import { PromotionItemAction, PromotionOrderAction } from '../../config/promotion/promotion-action';
 import { PromotionItemAction, PromotionOrderAction } from '../../config/promotion/promotion-action';
 import { PromotionCondition } from '../../config/promotion/promotion-condition';
 import { PromotionCondition } from '../../config/promotion/promotion-condition';
-import { getConfig } from '../../config/vendure-config';
 import { Channel } from '../channel/channel.entity';
 import { Channel } from '../channel/channel.entity';
 import { OrderItem } from '../order-item/order-item.entity';
 import { OrderItem } from '../order-item/order-item.entity';
 import { OrderLine } from '../order-line/order-line.entity';
 import { OrderLine } from '../order-line/order-line.entity';

+ 1 - 1
server/src/entity/shipping-method/shipping-method.entity.ts

@@ -4,9 +4,9 @@ import { Adjustment, AdjustmentOperation, AdjustmentType } from '../../../../sha
 import { DeepPartial } from '../../../../shared/shared-types';
 import { DeepPartial } from '../../../../shared/shared-types';
 import { AdjustmentSource } from '../../common/types/adjustment-source';
 import { AdjustmentSource } from '../../common/types/adjustment-source';
 import { ChannelAware } from '../../common/types/common-types';
 import { ChannelAware } from '../../common/types/common-types';
+import { getConfig } from '../../config/config-helpers';
 import { ShippingCalculator } from '../../config/shipping-method/shipping-calculator';
 import { ShippingCalculator } from '../../config/shipping-method/shipping-calculator';
 import { ShippingEligibilityChecker } from '../../config/shipping-method/shipping-eligibility-checker';
 import { ShippingEligibilityChecker } from '../../config/shipping-method/shipping-eligibility-checker';
-import { getConfig } from '../../config/vendure-config';
 import { Channel } from '../channel/channel.entity';
 import { Channel } from '../channel/channel.entity';
 import { Order } from '../order/order.entity';
 import { Order } from '../order/order.entity';
 
 

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

@@ -1,8 +1,8 @@
 import { Module, OnModuleInit } from '@nestjs/common';
 import { Module, OnModuleInit } from '@nestjs/common';
 import { TypeOrmModule } from '@nestjs/typeorm';
 import { TypeOrmModule } from '@nestjs/typeorm';
 
 
+import { getConfig } from '../config/config-helpers';
 import { ConfigModule } from '../config/config.module';
 import { ConfigModule } from '../config/config.module';
-import { getConfig } from '../config/vendure-config';
 import { EventBusModule } from '../event-bus/event-bus.module';
 import { EventBusModule } from '../event-bus/event-bus.module';
 
 
 import { ListQueryBuilder } from './helpers/list-query-builder/list-query-builder';
 import { ListQueryBuilder } from './helpers/list-query-builder/list-query-builder';