@nmxjs/app 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,2 @@
1
- export declare const getGraphQlModule: () => import("@nestjs/common").DynamicModule;
1
+ import { IGetGraphQlModuleOptions } from './interfaces';
2
+ export declare const getGraphQlModule: (options?: IGetGraphQlModuleOptions) => import("@nestjs/common").DynamicModule;
@@ -5,33 +5,36 @@ const apollo_1 = require("@nestjs/apollo");
5
5
  const utils_1 = require("@nmxjs/utils");
6
6
  const types_1 = require("@nmxjs/types");
7
7
  const graphql_1 = require("@nestjs/graphql");
8
- const getGraphQlModule = () => graphql_1.GraphQLModule.forRootAsync({
9
- driver: apollo_1.ApolloDriver,
10
- useFactory: () => ({
11
- debug: false,
12
- autoSchemaFile: true,
13
- installSubscriptionHandlers: true,
14
- playground: (0, utils_1.getEnvironment)() !== types_1.EnvironmentEnum.PRODUCTION,
15
- cors: {
16
- credentials: true,
17
- origin: [process.env.ORIGIN || '*'],
18
- },
19
- formatError: (error) => {
20
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
21
- return (Object.assign(Object.assign(Object.assign({}, (((_b = (_a = error.extensions.exception) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.code)
22
- ? { code: error.extensions.exception.error.code }
23
- : error.extensions.code
24
- ? { code: error.extensions.code }
25
- : {})), (((_d = (_c = error.extensions.exception) === null || _c === void 0 ? void 0 : _c.thrownValue) === null || _d === void 0 ? void 0 : _d.code) ? { code: error.extensions.exception.thrownValue.code } : {})), { message: ((_f = (_e = error.extensions.exception) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.message) ||
26
- ((_g = error.extensions.exception) === null || _g === void 0 ? void 0 : _g.message) ||
27
- ((_j = (_h = error.extensions.exception) === null || _h === void 0 ? void 0 : _h.thrownValue) === null || _j === void 0 ? void 0 : _j.message) ||
28
- error.toString() }));
29
- },
30
- context: ctx => ({
31
- req: ctx.req,
32
- res: ctx.res,
33
- }),
34
- }),
35
- });
8
+ const getGraphQlModule = (options) => {
9
+ var _a, _b;
10
+ return graphql_1.GraphQLModule.forRootAsync(Object.assign(Object.assign(Object.assign({}, (((_a = options === null || options === void 0 ? void 0 : options.inject) === null || _a === void 0 ? void 0 : _a.length) ? { inject: options.inject } : {})), (((_b = options === null || options === void 0 ? void 0 : options.imports) === null || _b === void 0 ? void 0 : _b.length) ? { imports: options.imports } : {})), { driver: apollo_1.ApolloDriver, useFactory: async (...params) => {
11
+ const { origin, onSubscriptionConnect, onSubscriptionDisconnect } = (options === null || options === void 0 ? void 0 : options.useFactory)
12
+ ? await options.useFactory(...params)
13
+ : {};
14
+ return Object.assign(Object.assign({ debug: false, autoSchemaFile: true, installSubscriptionHandlers: true, playground: (0, utils_1.getEnvironment)() !== types_1.EnvironmentEnum.PRODUCTION, cors: {
15
+ credentials: true,
16
+ origin: [origin || process.env.ORIGIN || '*'],
17
+ }, formatError: (error) => {
18
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
19
+ return (Object.assign(Object.assign(Object.assign({}, (((_b = (_a = error.extensions.exception) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.code)
20
+ ? { code: error.extensions.exception.error.code }
21
+ : error.extensions.code
22
+ ? { code: error.extensions.code }
23
+ : {})), (((_d = (_c = error.extensions.exception) === null || _c === void 0 ? void 0 : _c.thrownValue) === null || _d === void 0 ? void 0 : _d.code) ? { code: error.extensions.exception.thrownValue.code } : {})), { message: ((_f = (_e = error.extensions.exception) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.message) ||
24
+ ((_g = error.extensions.exception) === null || _g === void 0 ? void 0 : _g.message) ||
25
+ ((_j = (_h = error.extensions.exception) === null || _h === void 0 ? void 0 : _h.thrownValue) === null || _j === void 0 ? void 0 : _j.message) ||
26
+ error.toString() }));
27
+ } }, (onSubscriptionConnect || onSubscriptionDisconnect
28
+ ? {
29
+ subscriptions: {
30
+ 'subscriptions-transport-ws': Object.assign(Object.assign({}, (onSubscriptionConnect ? { onConnect: onSubscriptionConnect } : {})), (onSubscriptionDisconnect ? { onDisconnect: onSubscriptionDisconnect } : {})),
31
+ },
32
+ }
33
+ : {})), { context: ctx => ({
34
+ req: ctx.req,
35
+ res: ctx.res,
36
+ }) });
37
+ } }));
38
+ };
36
39
  exports.getGraphQlModule = getGraphQlModule;
37
40
  //# sourceMappingURL=getGraphQlModule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getGraphQlModule.js","sourceRoot":"","sources":["../src/getGraphQlModule.ts"],"names":[],"mappings":";;;AAAA,2CAAkE;AAClE,wCAA8C;AAC9C,wCAA+C;AAC/C,6CAAgD;AAEzC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CACnC,uBAAa,CAAC,YAAY,CAAqB;IAC7C,MAAM,EAAE,qBAAY;IACpB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACjB,KAAK,EAAE,KAAK;QACZ,cAAc,EAAE,IAAI;QACpB,2BAA2B,EAAE,IAAI;QACjC,UAAU,EAAE,IAAA,sBAAc,GAAE,KAAK,uBAAe,CAAC,UAAU;QAC3D,IAAI,EAAE;YACJ,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC;SACpC;QACD,WAAW,EAAE,CAAC,KAAU,EAAE,EAAE;;YAAC,OAAA,+CACxB,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAE,KAAK,0CAAE,IAAI;gBACzC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE;gBACjD,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI;oBACvB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,E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CAAC,EAAE,CAAC,KAC/G,OAAO,EACL,CAAA,MAAA,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAE,KAAK,0CAAE,OAAO;6BAC1C,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAE,OAAO,CAAA;6BACnC,MAAA,MAAA,KAAK,CAAC,UAAU,CAAC,SAAS,0CAAE,WAAW,0CAAE,OAAO,CAAA;4BAChD,KAAK,CAAC,QAAQ,EAAE,IAClB,CAAA;iBAAA,IACC,CAAC,qBAAqB,IAAI,wBAAwB;gBACnD,CAAC,CAAC;oBACE,aAAa,EAAE;wBACb,4BAA4B,kCACvB,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACnE,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAChF;qBACF;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC,KACP,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;oBACf,GAAG,EAAE,GAAG,CAAC,GAAG;oBACZ,GAAG,EAAE,GAAG,CAAC,GAAG;iBACb,CAAC,IACF;QACJ,CAAC,IACD,CAAA;CAAA,CAAC;AA/CQ,QAAA,gBAAgB,oBA+CxB"}
@@ -0,0 +1,6 @@
1
+ import { ModuleMetadata } from '@nestjs/common';
2
+ import { IGetGraphQlModuleUseFactoryResult } from './IGetGraphQlModuleUseFactoryResult';
3
+ export interface IGetGraphQlModuleOptions extends Pick<ModuleMetadata, 'imports'> {
4
+ inject?: Array<string | symbol>;
5
+ useFactory: (...params: any[]) => IGetGraphQlModuleUseFactoryResult | Promise<IGetGraphQlModuleUseFactoryResult>;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IGetGraphQlModuleOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGetGraphQlModuleOptions.js","sourceRoot":"","sources":["../../src/interfaces/IGetGraphQlModuleOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { ICallback } from '@nmxjs/types';
2
+ export interface IGetGraphQlModuleUseFactoryResult {
3
+ origin?: string;
4
+ onSubscriptionConnect?: ICallback<Record<string, string>>;
5
+ onSubscriptionDisconnect?: ICallback<Record<string, string>>;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IGetGraphQlModuleUseFactoryResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IGetGraphQlModuleUseFactoryResult.js","sourceRoot":"","sources":["../../src/interfaces/IGetGraphQlModuleUseFactoryResult.ts"],"names":[],"mappings":""}
@@ -1 +1,3 @@
1
1
  export * from './ICreateNestAppOptions';
2
+ export * from './IGetGraphQlModuleOptions';
3
+ export * from './IGetGraphQlModuleUseFactoryResult';
@@ -15,4 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ICreateNestAppOptions"), exports);
18
+ __exportStar(require("./IGetGraphQlModuleOptions"), exports);
19
+ __exportStar(require("./IGetGraphQlModuleUseFactoryResult"), exports);
18
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,6DAA2C;AAC3C,sEAAoD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nmxjs/app",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,6 +31,7 @@
31
31
  "@nmxjs/api": "^1.1.8",
32
32
  "@nmxjs/config": "^1.0.4",
33
33
  "@nmxjs/events": "^1.0.4",
34
+ "@nmxjs/types": "^1.0.0",
34
35
  "compression": "^1.7.4",
35
36
  "helmet": "^7.1.0"
36
37
  }