@tsed/apollo 6.107.5 → 6.108.0

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.
@@ -33,19 +33,19 @@ let ApolloModule = class ApolloModule {
33
33
  }
34
34
  }
35
35
  };
36
- (0, tslib_1.__decorate)([
36
+ tslib_1.__decorate([
37
37
  (0, di_1.Inject)(),
38
- (0, tslib_1.__metadata)("design:type", common_1.Logger)
38
+ tslib_1.__metadata("design:type", common_1.Logger)
39
39
  ], ApolloModule.prototype, "logger", void 0);
40
- (0, tslib_1.__decorate)([
40
+ tslib_1.__decorate([
41
41
  (0, di_1.Inject)(),
42
- (0, tslib_1.__metadata)("design:type", ApolloService_1.ApolloService)
42
+ tslib_1.__metadata("design:type", ApolloService_1.ApolloService)
43
43
  ], ApolloModule.prototype, "service", void 0);
44
- (0, tslib_1.__decorate)([
44
+ tslib_1.__decorate([
45
45
  (0, di_1.Configuration)(),
46
- (0, tslib_1.__metadata)("design:type", Object)
46
+ tslib_1.__metadata("design:type", Object)
47
47
  ], ApolloModule.prototype, "configuration", void 0);
48
- ApolloModule = (0, tslib_1.__decorate)([
48
+ ApolloModule = tslib_1.__decorate([
49
49
  (0, di_1.Module)()
50
50
  ], ApolloModule);
51
51
  exports.ApolloModule = ApolloModule;
@@ -1 +1 @@
1
- {"version":3,"file":"ApolloModule.js","sourceRoot":"","sources":["../../src/ApolloModule.ts"],"names":[],"mappings":";;;;AAAA,yCAA+D;AAC/D,iCAAuD;AAEvD,4DAAuD;AAGvD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAUvB,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa;QACX,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,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IADxB,IAAA,WAAM,GAAE;GACI,YAAY,CA6CxB;AA7CY,oCAAY","sourcesContent":["import {AfterListen, Logger, OnRoutesInit} from \"@tsed/common\";\nimport {Configuration, Inject, Module} from \"@tsed/di\";\nimport {ApolloSettings} from \"./interfaces/ApolloSettings\";\nimport {ApolloService} from \"./services/ApolloService\";\n\n@Module()\nexport class ApolloModule implements OnRoutesInit, AfterListen {\n @Inject()\n protected logger: Logger;\n\n @Inject()\n protected service: ApolloService;\n\n @Configuration()\n protected configuration: Configuration;\n\n get settings(): {[key: string]: ApolloSettings} | undefined {\n return this.configuration.get(\"apollo\");\n }\n\n $onRoutesInit(): Promise<any> | void {\n const {settings} = this;\n\n if (settings) {\n const promises = Object.entries(settings).map(async ([key, options]) => {\n return this.service.createServer(key, options);\n });\n\n return Promise.all(promises);\n }\n }\n\n $afterListen(): Promise<any> | void {\n const host = this.configuration.getBestHost();\n\n const displayLog = (key: string, path: string) => {\n const url = typeof host.port === \"number\" ? `${host.protocol}://${host.address}:${host.port}` : \"\";\n\n this.logger.info(`[${key}] Apollo server is available on ${url}${path.replace(/^\\//, \"\")}`);\n };\n\n const {settings} = this;\n\n if (settings) {\n Object.entries(settings).map(async ([key, options]) => {\n const {path} = options;\n\n displayLog(key, path);\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ApolloModule.js","sourceRoot":"","sources":["../../src/ApolloModule.ts"],"names":[],"mappings":";;;;AAAA,yCAA+D;AAC/D,iCAAuD;AAEvD,4DAAuD;AAGvD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAUvB,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa;QACX,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,KAA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E;GACI,YAAY,CA6CxB;AA7CY,oCAAY","sourcesContent":["import {AfterListen, Logger, OnRoutesInit} from \"@tsed/common\";\nimport {Configuration, Inject, Module} from \"@tsed/di\";\nimport {ApolloSettings} from \"./interfaces/ApolloSettings\";\nimport {ApolloService} from \"./services/ApolloService\";\n\n@Module()\nexport class ApolloModule implements OnRoutesInit, AfterListen {\n @Inject()\n protected logger: Logger;\n\n @Inject()\n protected service: ApolloService;\n\n @Configuration()\n protected configuration: Configuration;\n\n get settings(): {[key: string]: ApolloSettings} | undefined {\n return this.configuration.get(\"apollo\");\n }\n\n $onRoutesInit(): Promise<any> | void {\n const {settings} = this;\n\n if (settings) {\n const promises = Object.entries(settings).map(async ([key, options]) => {\n return this.service.createServer(key, options);\n });\n\n return Promise.all(promises);\n }\n }\n\n $afterListen(): Promise<any> | void {\n const host = this.configuration.getBestHost();\n\n const displayLog = (key: string, path: string) => {\n const url = typeof host.port === \"number\" ? `${host.protocol}://${host.address}:${host.port}` : \"\";\n\n this.logger.info(`[${key}] Apollo server is available on ${url}${path.replace(/^\\//, \"\")}`);\n };\n\n const {settings} = this;\n\n if (settings) {\n Object.entries(settings).map(async ([key, options]) => {\n const {path} = options;\n\n displayLog(key, path);\n });\n }\n }\n}\n"]}
package/lib/cjs/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tslib_1 = require("tslib");
7
- (0, tslib_1.__exportStar)(require("./ApolloModule"), exports);
8
- (0, tslib_1.__exportStar)(require("./interfaces/ApolloSettings"), exports);
9
- (0, tslib_1.__exportStar)(require("./services/ApolloService"), exports);
7
+ tslib_1.__exportStar(require("./ApolloModule"), exports);
8
+ tslib_1.__exportStar(require("./interfaces/ApolloSettings"), exports);
9
+ tslib_1.__exportStar(require("./services/ApolloService"), exports);
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,8DAA+B;AAC/B,2EAA4C;AAC5C,wEAAyC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./ApolloModule\";\nexport * from \"./interfaces/ApolloSettings\";\nexport * from \"./services/ApolloService\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yDAA+B;AAC/B,sEAA4C;AAC5C,mEAAyC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./ApolloModule\";\nexport * from \"./interfaces/ApolloSettings\";\nexport * from \"./services/ApolloService\";\n"]}
@@ -6,8 +6,8 @@ const di_1 = require("@tsed/di");
6
6
  const logger_1 = require("@tsed/logger");
7
7
  const common_1 = require("@tsed/common");
8
8
  const apollo_server_core_1 = require("apollo-server-core");
9
- const http_1 = (0, tslib_1.__importDefault)(require("http"));
10
- const https_1 = (0, tslib_1.__importDefault)(require("https"));
9
+ const http_1 = tslib_1.__importDefault(require("http"));
10
+ const https_1 = tslib_1.__importDefault(require("https"));
11
11
  let ApolloService = class ApolloService {
12
12
  constructor() {
13
13
  /**
@@ -81,7 +81,7 @@ let ApolloService = class ApolloService {
81
81
  }
82
82
  // istanbul ignore next
83
83
  try {
84
- const { ApolloServer: Server } = await Promise.resolve().then(() => (0, tslib_1.__importStar)(require(`apollo-server-${this.platformName || "express"}`)));
84
+ const { ApolloServer: Server } = await Promise.resolve().then(() => tslib_1.__importStar(require(`apollo-server-${this.platformName || "express"}`)));
85
85
  return new Server(options);
86
86
  }
87
87
  catch (er) {
@@ -104,27 +104,27 @@ let ApolloService = class ApolloService {
104
104
  ].filter(Boolean);
105
105
  }
106
106
  };
107
- (0, tslib_1.__decorate)([
107
+ tslib_1.__decorate([
108
108
  (0, di_1.Constant)("PLATFORM_NAME"),
109
- (0, tslib_1.__metadata)("design:type", String)
109
+ tslib_1.__metadata("design:type", String)
110
110
  ], ApolloService.prototype, "platformName", void 0);
111
- (0, tslib_1.__decorate)([
111
+ tslib_1.__decorate([
112
112
  (0, di_1.Inject)(),
113
- (0, tslib_1.__metadata)("design:type", logger_1.Logger)
113
+ tslib_1.__metadata("design:type", logger_1.Logger)
114
114
  ], ApolloService.prototype, "logger", void 0);
115
- (0, tslib_1.__decorate)([
115
+ tslib_1.__decorate([
116
116
  (0, di_1.Inject)(),
117
- (0, tslib_1.__metadata)("design:type", common_1.PlatformApplication)
117
+ tslib_1.__metadata("design:type", common_1.PlatformApplication)
118
118
  ], ApolloService.prototype, "app", void 0);
119
- (0, tslib_1.__decorate)([
119
+ tslib_1.__decorate([
120
120
  (0, di_1.Inject)(http_1.default.Server),
121
- (0, tslib_1.__metadata)("design:type", Object)
121
+ tslib_1.__metadata("design:type", Object)
122
122
  ], ApolloService.prototype, "httpServer", void 0);
123
- (0, tslib_1.__decorate)([
123
+ tslib_1.__decorate([
124
124
  (0, di_1.Inject)(https_1.default.Server),
125
- (0, tslib_1.__metadata)("design:type", Object)
125
+ tslib_1.__metadata("design:type", Object)
126
126
  ], ApolloService.prototype, "httpsServer", void 0);
127
- ApolloService = (0, tslib_1.__decorate)([
127
+ ApolloService = tslib_1.__decorate([
128
128
  (0, di_1.Service)()
129
129
  ], ApolloService);
130
130
  exports.ApolloService = ApolloService;
@@ -1 +1 @@
1
- {"version":3,"file":"ApolloService.js","sourceRoot":"","sources":["../../../src/services/ApolloService.ts"],"names":[],"mappings":";;;;AAAA,iCAAmD;AACnD,yCAAoC;AACpC,yCAAiD;AAEjD,2DAK4B;AAI5B,6DAAwB;AACxB,+DAA0B;AAG1B,IAAa,aAAa,GAA1B,MAAa,aAAa;IAA1B;QAOE;;;;WAIG;QACO,YAAO,GAMb,IAAI,GAAG,EAAE,CAAC;IA+GhB,CAAC;IApGC,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,QAAwB;QACrD,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAChB,O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CAAC;YACJ,GAAG,CAAC,cAAc,CAAC,OAAO,IAAI,EAAE,CAAC;SAClC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;CACF,CAAA;AA/HC;IADC,IAAA,aAAQ,EAAC,eAAe,CAAC;;mDACL;AAGrB;IADC,IAAA,WAAM,GAAE;2CACS,eAAM;6CAAC;AAgBzB;IADC,IAAA,WAAM,GAAE;2CACI,4BAAmB;0CAAC;AAGjC;IADC,IAAA,WAAM,EAAC,cAAI,CAAC,MAAM,CAAC;;iDACmB;AAGvC;IADC,IAAA,WAAM,EAAC,eAAK,CAAC,MAAM,CAAC;;kDACoB;AA3B9B,aAAa;IADzB,IAAA,YAAO,GAAE;GACG,aAAa,CAiIzB;AAjIY,sCAAa","sourcesContent":["import {Constant, Inject, Service} from \"@tsed/di\";\nimport {Logger} from \"@tsed/logger\";\nimport {PlatformApplication} from \"@tsed/common\";\nimport type {Config} from \"apollo-server-core\";\nimport {\n ApolloServerBase,\n ApolloServerPluginDrainHttpServer,\n ApolloServerPluginLandingPageDisabled,\n ApolloServerPluginLandingPageGraphQLPlayground\n} from \"apollo-server-core\";\nimport type {GraphQLSchema} from \"graphql\";\nimport type {ApolloServer, ApolloSettings} from \"../interfaces/ApolloSettings\";\nimport {ApolloCustomServerCB} from \"../interfaces/ApolloSettings\";\nimport Http from \"http\";\nimport Https from \"https\";\n\n@Service()\nexport class ApolloService {\n @Constant(\"PLATFORM_NAME\")\n platformName: string;\n\n @Inject()\n protected logger: Logger;\n\n /**\n *\n * @type {Map<any, any>}\n * @private\n */\n protected servers: Map<\n string,\n {\n instance: ApolloServerBase;\n schema: GraphQLSchema | undefined;\n }\n > = new Map();\n\n @Inject()\n private app: PlatformApplication;\n\n @Inject(Http.Server)\n private httpServer: Http.Server | null;\n\n @Inject(Https.Server)\n private httpsServer: Https.Server | null;\n\n async createServer(id: string, settings: ApolloSettings): Promise<any> {\n if (this.has(id)) {\n return this.get(id)!;\n }\n\n try {\n const {path, middlewareOptions = {}, server: customServer, ...config} = settings;\n\n this.logger.info(`Create server with Apollo for: ${id}`);\n this.logger.debug(`options: ${JSON.stringify({path})}`);\n\n const server = await this.createInstance(\n {\n ...config,\n plugins: this.getPlugins(settings)\n },\n customServer\n );\n\n if (server) {\n this.servers.set(id || \"default\", {\n instance: server,\n schema: settings.schema\n });\n\n await server.start();\n\n await server.applyMiddleware({\n path: settings.path,\n ...middlewareOptions,\n app: this.app.raw\n });\n\n return server;\n }\n } catch (err) {\n /* istanbul ignore next */\n this.logger.error(err);\n /* istanbul ignore next */\n process.exit(-1);\n }\n }\n\n /**\n * Get an instance of ApolloServer from his id\n * @returns ApolloServer\n */\n get(id: string = \"default\"): ApolloServerBase | undefined {\n return this.servers.get(id)?.instance;\n }\n\n /**\n * Get an instance of GraphQL schema from his id\n * @returns GraphQLSchema\n */\n getSchema(id: string = \"default\"): GraphQLSchema | undefined {\n return this.servers.get(id)?.schema;\n }\n\n /**\n *\n * @param {string} id\n * @returns {boolean}\n */\n has(id: string = \"default\"): boolean {\n return this.servers.has(id);\n }\n\n protected async createInstance(options: Config, server?: ApolloCustomServerCB): Promise<ApolloServer | undefined> {\n // istanbul ignore next\n if (server) {\n return server(options);\n }\n\n // istanbul ignore next\n try {\n const {ApolloServer: Server} = await import(`apollo-server-${this.platformName || \"express\"}`);\n\n return new Server(options);\n } catch (er) {\n this.logger.error(`Platform \"${this.platformName}\" not supported by @tsed/apollo`);\n }\n }\n\n private getPlugins(serverSettings: ApolloSettings): any[] {\n const playground = serverSettings.playground || (serverSettings.playground === undefined && process.env.NODE_ENV !== \"production\");\n\n return [\n playground ? ApolloServerPluginLandingPageGraphQLPlayground() : ApolloServerPluginLandingPageDisabled(),\n this.httpServer &&\n ApolloServerPluginDrainHttpServer({\n httpServer: this.httpServer\n }),\n this.httpsServer &&\n ApolloServerPluginDrainHttpServer({\n httpServer: this.httpsServer\n }),\n ...(serverSettings.plugins || [])\n ].filter(Boolean);\n }\n}\n"]}
1
+ {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AAc,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC;QAEnI,OAAO;YACL,UAAU,CAAC,CAAC,CAAC,IAAA,mEAA8C,GAAE,CAAC,CAAC,CAAC,IAAA,0DAAqC,GAAE;YACvG,IAAI,CAAC,UAAU;gBACb,IAAA,sDAAiC,EAAC;oBAChC,UAAU,EAAE,IAAI,CAAC,UAAU;iBAC5B,CAAC;YACJ,IAAI,CAAC,WAAW;gBACd,IAAA,sDAAiC,EAAC;oBAChC,UAAU,EAAE,IAAI,CAAC,WAAW;iBAC7B,CAAC;YACJ,GAAG,CAAC,cAAc,CAAC,OAAO,IAAI,EAAE,CAAC;SAClC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;CACF,CAAA;AA/HC;IADC,IAAA,aAAQ,EAAC,eAAe,CAAC;;mDACL;AAGrB;IADC,IAAA,WAAM,GAAE;sCACS,eAAM;6CAAC;AAgBzB;IADC,IAAA,WAAM,GAAE;sCACI,4BAAmB;0CAAC;AAGjC;IADC,IAAA,WAAM,EAAC,cAAI,CAAC,MAAM,CAAC;;iDACmB;AAGvC;IADC,IAAA,WAAM,EAAC,eAAK,CAAC,MAAM,CAAC;;kDACoB;AA3B9B,aAAa;IADzB,IAAA,YAAO,GAAE;GACG,aAAa,CAiIzB;AAjIY,sCAAa","sourcesContent":["import {Constant, Inject, Service} from \"@tsed/di\";\nimport {Logger} from \"@tsed/logger\";\nimport {PlatformApplication} from \"@tsed/common\";\nimport type {Config} from \"apollo-server-core\";\nimport {\n ApolloServerBase,\n ApolloServerPluginDrainHttpServer,\n ApolloServerPluginLandingPageDisabled,\n ApolloServerPluginLandingPageGraphQLPlayground\n} from \"apollo-server-core\";\nimport type {GraphQLSchema} from \"graphql\";\nimport type {ApolloServer, ApolloSettings} from \"../interfaces/ApolloSettings\";\nimport {ApolloCustomServerCB} from \"../interfaces/ApolloSettings\";\nimport Http from \"http\";\nimport Https from \"https\";\n\n@Service()\nexport class ApolloService {\n @Constant(\"PLATFORM_NAME\")\n platformName: string;\n\n @Inject()\n protected logger: Logger;\n\n /**\n *\n * @type {Map<any, any>}\n * @private\n */\n protected servers: Map<\n string,\n {\n instance: ApolloServerBase;\n schema: GraphQLSchema | undefined;\n }\n > = new Map();\n\n @Inject()\n private app: PlatformApplication;\n\n @Inject(Http.Server)\n private httpServer: Http.Server | null;\n\n @Inject(Https.Server)\n private httpsServer: Https.Server | null;\n\n async createServer(id: string, settings: ApolloSettings): Promise<any> {\n if (this.has(id)) {\n return this.get(id)!;\n }\n\n try {\n const {path, middlewareOptions = {}, server: customServer, ...config} = settings;\n\n this.logger.info(`Create server with Apollo for: ${id}`);\n this.logger.debug(`options: ${JSON.stringify({path})}`);\n\n const server = await this.createInstance(\n {\n ...config,\n plugins: this.getPlugins(settings)\n },\n customServer\n );\n\n if (server) {\n this.servers.set(id || \"default\", {\n instance: server,\n schema: settings.schema\n });\n\n await server.start();\n\n await server.applyMiddleware({\n path: settings.path,\n ...middlewareOptions,\n app: this.app.raw\n });\n\n return server;\n }\n } catch (err) {\n /* istanbul ignore next */\n this.logger.error(err);\n /* istanbul ignore next */\n process.exit(-1);\n }\n }\n\n /**\n * Get an instance of ApolloServer from his id\n * @returns ApolloServer\n */\n get(id: string = \"default\"): ApolloServerBase | undefined {\n return this.servers.get(id)?.instance;\n }\n\n /**\n * Get an instance of GraphQL schema from his id\n * @returns GraphQLSchema\n */\n getSchema(id: string = \"default\"): GraphQLSchema | undefined {\n return this.servers.get(id)?.schema;\n }\n\n /**\n *\n * @param {string} id\n * @returns {boolean}\n */\n has(id: string = \"default\"): boolean {\n return this.servers.has(id);\n }\n\n protected async createInstance(options: Config, server?: ApolloCustomServerCB): Promise<ApolloServer | undefined> {\n // istanbul ignore next\n if (server) {\n return server(options);\n }\n\n // istanbul ignore next\n try {\n const {ApolloServer: Server} = await import(`apollo-server-${this.platformName || \"express\"}`);\n\n return new Server(options);\n } catch (er) {\n this.logger.error(`Platform \"${this.platformName}\" not supported by @tsed/apollo`);\n }\n }\n\n private getPlugins(serverSettings: ApolloSettings): any[] {\n const playground = serverSettings.playground || (serverSettings.playground === undefined && process.env.NODE_ENV !== \"production\");\n\n return [\n playground ? ApolloServerPluginLandingPageGraphQLPlayground() : ApolloServerPluginLandingPageDisabled(),\n this.httpServer &&\n ApolloServerPluginDrainHttpServer({\n httpServer: this.httpServer\n }),\n this.httpsServer &&\n ApolloServerPluginDrainHttpServer({\n httpServer: this.httpsServer\n }),\n ...(serverSettings.plugins || [])\n ].filter(Boolean);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/apollo",
3
- "version": "6.107.5",
3
+ "version": "6.108.0",
4
4
  "description": "Apollo package for Ts.ED framework",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/cjs/index.js",
@@ -20,14 +20,14 @@
20
20
  "test": "cross-env NODE_ENV=test jest"
21
21
  },
22
22
  "dependencies": {
23
- "tslib": "2.2.0"
23
+ "tslib": "2.3.1"
24
24
  },
25
25
  "private": false,
26
26
  "devDependencies": {
27
- "@tsed/common": "6.107.5",
28
- "@tsed/core": "6.107.5",
29
- "@tsed/di": "6.107.5",
30
- "@tsed/logger": ">=6.1.0",
27
+ "@tsed/common": "6.108.0",
28
+ "@tsed/core": "6.108.0",
29
+ "@tsed/di": "6.108.0",
30
+ "@tsed/logger": ">=6.1.1",
31
31
  "@types/graphql": "14.5.0",
32
32
  "apollo-datasource": "^3.2.0",
33
33
  "apollo-datasource-rest": "^3.3.0",
@@ -38,10 +38,10 @@
38
38
  "graphql": "15.7.2"
39
39
  },
40
40
  "peerDependencies": {
41
- "@tsed/common": "^6.107.5",
42
- "@tsed/core": "^6.107.5",
43
- "@tsed/di": "^6.107.5",
44
- "@tsed/logger": ">=6.1.0",
41
+ "@tsed/common": "^6.108.0",
42
+ "@tsed/core": "^6.108.0",
43
+ "@tsed/di": "^6.108.0",
44
+ "@tsed/logger": ">=6.1.1",
45
45
  "apollo-datasource": ">=3.0.0",
46
46
  "apollo-datasource-rest": ">=3.0.0",
47
47
  "apollo-server-core": ">=3.0.0",