@tsed/common 7.10.1 → 7.12.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.
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA8D;AAC9D,iCAAsG;AACtG,qEAAmG;AAOnG,mDAA8C;AAC9C,iEAAqF;AACrF,yEAAoE;AACpE,gEAA2D;AAC3D,kEAA6D;AAC7D,4DAAuD;AACvD,gEAA2D;AAC3D,kEAA6D;AAC7D,sDAAiD;AAEjD;;GAEG;AACH,MAAa,eAAe;IACnB,MAAM,CAAC,OAAO,CAA6B;IAEzC,IAAI,GAAW,EAAE,CAAC;IACjB,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;IACtB,SAAS,CAAkB;IAC3B,WAAW,CAAY;IACvB,QAAQ,CAAuB;IACxC,QAAQ,CAAgB;IACxB,QAAQ,CAA2C;IACnD,UAAU,GAA8B,EAAE,CAAC;IAE3C,YAAsB,OAA+C,EAAE,MAAY,EAAE,QAAqC;QACxH,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAE1B,MAAM,aAAa,GAAG,IAAA,mCAAgB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzD,MAAM,YAAY,GAA+B,OAAO,IAAK,eAAe,CAAC,OAAe,CAAC;QAC7F,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,YAAY,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAExE,aAAa,CAAC,aAAa,GAAG,IAAI,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,SAAS,GAAG,IAAA,+BAAc,EAAC;YAC9B,OAAO,EAAE,YA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G,CAAC,EAAE;oBACnF,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;iBACpE;qBAAM;oBACL,MAAM,GAAG,GAAG,wDAAa,GAAG,GAAC,CAAC;oBAC9B,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;iBACrC;aACF;YAED,OAAO;gBACL,GAAG;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,UAAU;gBACb,GAAG;aACJ,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACzD,CAAC;CACF;AA1YD,0CA0YC","sourcesContent":["import {isFunction, isString, nameOf, Type} from \"@tsed/core\";\nimport {colors, InjectorService, ProviderOpts, setLoggerConfiguration, TokenProvider} from \"@tsed/di\";\nimport {getMiddlewaresForHook, PlatformMiddlewareLoadingOptions} from \"@tsed/platform-middlewares\";\nimport {PlatformLayer} from \"@tsed/platform-router\";\nimport type {IncomingMessage, Server, ServerResponse} from \"http\";\nimport type Https from \"https\";\nimport {PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\nimport {Route} from \"../interfaces/Route\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"../services/PlatformAdapter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {createHttpServer} from \"../utils/createHttpServer\";\nimport {createHttpsServer} from \"../utils/createHttpsServer\";\nimport {createInjector} from \"../utils/createInjector\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {getStaticsOptions} from \"../utils/getStaticsOptions\";\nimport {printRoutes} from \"../utils/printRoutes\";\n\n/**\n * @platform\n */\nexport class PlatformBuilder<App = TsED.Application> {\n public static adapter: Type<PlatformAdapter<any>>;\n\n readonly name: string = \"\";\n protected startedAt = new Date();\n protected current = new Date();\n readonly #injector: InjectorService;\n readonly #rootModule: Type<any>;\n readonly #adapter: PlatformAdapter<App>;\n #promise: Promise<this>;\n #servers: (() => Promise<Server | Https.Server>)[];\n #listeners: (Server | Https.Server)[] = [];\n\n protected constructor(adapter: Type<PlatformAdapter<App>> | undefined, module: Type, settings: Partial<TsED.Configuration>) {\n this.#rootModule = module;\n\n const configuration = getConfiguration(settings, module);\n const adapterKlass: Type<PlatformAdapter<App>> = adapter || (PlatformBuilder.adapter as any);\n const name = nameOf(adapterKlass).replace(\"Platform\", \"\").toLowerCase();\n\n configuration.PLATFORM_NAME = name;\n this.name = name;\n\n this.#injector = createInjector({\n adapter: adapterKlass,\n settings: configuration\n });\n\n this.#adapter = this.#injector.get<PlatformAdapter<App>>(PlatformAdapter)!;\n\n this.createHttpServers();\n\n this.#adapter.onInit && this.#adapter.onInit();\n\n this.log(\"Injector created...\");\n }\n\n get injector(): InjectorService {\n return this.#injector;\n }\n\n get rootModule(): any {\n return this.#injector.get(this.#rootModule);\n }\n\n get app(): PlatformApplication<App> {\n return this.injector.get<PlatformApplication<App>>(PlatformApplication)!;\n }\n\n get platform() {\n return this.injector.get<Platform>(Platform)!;\n }\n\n get adapter() {\n return this.#adapter;\n }\n\n /**\n * Return the settings configured by the decorator @@Configuration@@.\n *\n * ```typescript\n * @Configuration({\n * rootDir: Path.resolve(__dirname),\n * port: 8000,\n * httpsPort: 8080,\n * mount: {\n * \"/rest\": \"${rootDir}/controllers/**\\/*.js\"\n * }\n * })\n * export class Server {\n * $onInit(){\n * console.log(this.settings); // {rootDir, port, httpsPort,...}\n * }\n * }\n * ```\n *\n * @returns {PlatformConfiguration}\n */\n get settings() {\n return this.injector.settings;\n }\n\n get logger() {\n return this.injector.logger;\n }\n\n get disableBootstrapLog() {\n return this.settings.get(\"logger.disableBootstrapLog\");\n }\n\n static create<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build(module, {\n httpsPort: false,\n httpPort: false,\n ...settings\n });\n }\n\n static build<App = TsED.Application>(module: Type<any>, {adapter, ...settings}: PlatformBuilderSettings<App>) {\n return new PlatformBuilder(adapter, module, settings);\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build<App>(module, settings).bootstrap();\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => void;\n callback(req: IncomingMessage, res: ServerResponse): void;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n if (req && res) {\n return this.callback()(req, res);\n }\n\n return this.app.callback();\n }\n\n log(...data: any[]) {\n return !this.disableBootstrapLog && this.logger.info(...data, this.diff());\n }\n\n /**\n * Add classes to the components list\n * @param classes\n */\n public addComponents(classes: Type | Type[]) {\n this.settings.set(\"imports\", this.settings.get<any[]>(\"imports\", []).concat(classes));\n\n return this;\n }\n\n /**\n * Add classes decorated by @@Controller@@ to components container.\n *\n * ### Example\n *\n * ```typescript\n * @Controller('/ctrl')\n * class MyController{\n * }\n *\n * platform.addControllers('/rest', [MyController])\n * ```\n *\n * ::: tip\n * If the MyController class isn't decorated, the class will be ignored.\n * :::\n *\n * @param {string} endpoint\n * @param {any[]} controllers\n */\n public addControllers(endpoint: string, controllers: TokenProvider | TokenProvider[]) {\n [].concat(controllers).forEach((token) => {\n this.settings.routes.push({token, route: endpoint});\n });\n }\n\n public async runLifecycle() {\n setLoggerConfiguration(this.injector);\n\n await this.mapTokenMiddlewares();\n\n await this.loadInjector();\n\n this.#adapter.useContext();\n\n await this.loadRoutes();\n\n return this;\n }\n\n async loadInjector() {\n const {injector} = this;\n this.log(\"Build providers\");\n\n await injector.loadModule(this.#rootModule);\n\n this.log(\"Settings and injector loaded...\");\n\n await this.callHook(\"$afterInit\");\n }\n\n async listen(network = true) {\n if (!this.#promise) {\n await this.bootstrap();\n }\n\n await this.callHook(\"$beforeListen\");\n\n if (network) {\n await this.listenServers();\n }\n\n await this.callHook(\"$afterListen\");\n\n await this.ready();\n }\n\n async stop() {\n await this.callHook(\"$onDestroy\");\n await this.injector.destroy();\n\n this.#listeners.map((server) => {\n return new Promise((resolve) => server.close(() => resolve(undefined)));\n });\n }\n\n public async ready() {\n const {startedAt} = this;\n\n await this.callHook(\"$onReady\");\n await this.injector.emit(\"$onServerReady\");\n\n this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);\n }\n\n async callHook(hook: string, ...args: any[]) {\n const {injector} = this;\n\n if (!this.disableBootstrapLog) {\n injector.logger.debug(`\\x1B[1mCall hook ${hook}\\x1B[22m`);\n }\n\n // Load middlewares for the given hook\n this.loadMiddlewaresFor(hook);\n\n // call hooks added by providers\n await injector.emit(hook, ...args);\n }\n\n async loadStatics(hook: string): Promise<void> {\n const statics = this.settings.get<PlatformStaticsSettings>(\"statics\");\n\n getStaticsOptions(statics).forEach(({path, options}) => {\n if (options.hook === hook) {\n this.platform.app.statics(path, options);\n }\n });\n }\n\n useProvider(token: Type<any>, settings?: Partial<ProviderOpts>) {\n this.injector.addProvider(token, settings);\n\n return this;\n }\n\n async bootstrap() {\n this.#promise = this.#promise || this.runLifecycle();\n\n return this.#promise;\n }\n\n protected async loadRoutes() {\n this.#adapter.beforeLoadRoutes && (await this.#adapter.beforeLoadRoutes());\n\n // istanbul ignore next\n if (this.settings.get(\"logger.level\") !== \"off\") {\n const {PlatformLogMiddleware} = await import(\"@tsed/platform-log-middleware\");\n this.app.use(PlatformLogMiddleware);\n }\n\n this.log(\"Load routes\");\n\n if (this.rootModule.$beforeRoutesInit) {\n await this.rootModule.$beforeRoutesInit();\n this.rootModule.$beforeRoutesInit = () => {};\n }\n\n await this.loadStatics(\"$beforeRoutesInit\");\n await this.callHook(\"$beforeRoutesInit\");\n\n const routes = this.injector.settings.get<Route[]>(\"routes\");\n\n this.platform.addRoutes(routes);\n\n await this.callHook(\"$onRoutesInit\");\n\n await this.loadStatics(\"$afterRoutesInit\");\n\n await this.callHook(\"$afterRoutesInit\");\n\n this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());\n\n await this.mapRouters();\n }\n\n protected async mapRouters() {\n const layers = this.platform.getLayers();\n\n this.#adapter.mapLayers(layers);\n\n const rawBody =\n this.settings.get(\"rawBody\") ||\n layers.some(({handlers}) => {\n return handlers.some((handler) => handler.opts?.paramsTypes?.RAW_BODY);\n });\n\n this.settings.set(\"rawBody\", rawBody);\n\n return this.logRoutes(layers.filter((layer) => layer.isProvider()));\n }\n\n protected diff() {\n const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);\n this.current = new Date();\n return ms;\n }\n\n /**\n * Load middlewares from configuration for the given hook\n * @param hook\n * @protected\n */\n protected loadMiddlewaresFor(hook: string): void {\n return getMiddlewaresForHook(hook, this.settings, \"$beforeRoutesInit\").forEach(({use}) => {\n this.app.use(use);\n });\n }\n\n protected createHttpServers() {\n this.#servers = [createHttpServer(this.#injector, this.callback()), createHttpsServer(this.#injector, this.callback())].filter(\n Boolean\n ) as any[];\n }\n\n protected async listenServers(): Promise<void> {\n this.#listeners = await Promise.all(this.#servers.map((cb) => cb && cb()));\n }\n\n protected async logRoutes(layers: PlatformLayer[]) {\n const {logger} = this;\n\n this.log(\"Routes mounted...\");\n\n if (!this.settings.get(\"logger.disableRoutesSummary\") && !this.disableBootstrapLog) {\n const routes: PlatformRouteDetails[] = layers.map((layer) => {\n return {\n url: layer.path,\n method: layer.method,\n name: layer.opts.name || `${layer.provider.className}.constructor()`,\n className: layer.opts.className || layer.provider.className,\n methodClassName: layer.opts.methodClassName || \"\"\n } as PlatformRouteDetails;\n });\n\n logger.info(printRoutes(await this.injector.alterAsync(\"$logRoutes\", routes)));\n }\n }\n\n protected async mapTokenMiddlewares() {\n let middlewares = this.injector.settings.get<PlatformMiddlewareLoadingOptions[]>(\"middlewares\", []);\n const {env} = this.injector.settings;\n const defaultHook = \"$beforeRoutesInit\";\n\n const promises = middlewares.map(async (middleware: PlatformMiddlewareLoadingOptions): Promise<PlatformMiddlewareLoadingOptions> => {\n if (isFunction(middleware)) {\n return {\n env,\n hook: defaultHook,\n use: middleware\n };\n }\n\n if (isString(middleware)) {\n middleware = {env, use: middleware, hook: defaultHook};\n }\n\n let {use, options} = middleware;\n\n if (isString(use)) {\n if ([\"text-parser\", \"raw-parser\", \"json-parser\", \"urlencoded-parser\"].includes(use)) {\n use = this.adapter.bodyParser(use.replace(\"-parser\", \"\"), options);\n } else {\n const mod = await import(use);\n use = (mod.default || mod)(options);\n }\n }\n\n return {\n env,\n hook: defaultHook,\n ...middleware,\n use\n };\n });\n\n middlewares = await Promise.all(promises);\n\n this.injector.settings.set(\"middlewares\", middlewares);\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA8D;AAC9D,iCAAsG;AACtG,qEAAmG;AAOnG,mDAA8C;AAC9C,iEAAqF;AACrF,yEAAoE;AAEpE,gEAA2D;AAC3D,kEAA6D;AAC7D,4DAAuD;AACvD,gEAA2D;AAC3D,kEAA6D;AAC7D,sDAAiD;AAEjD;;GAEG;AACH,MAAa,eAAe;IACnB,MAAM,CAAC,OAAO,CAA6B;IAEzC,IAAI,GAAW,EAAE,CAAC;IACjB,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;IACtB,SAAS,CAAkB;IAC3B,WAAW,CAAY;IACvB,QAAQ,CAAuB;IACxC,QAAQ,CAAgB;IACxB,QAAQ,CAA2C;IACnD,UAAU,GAA8B,EAAE,CAAC;IAE3C,YAAsB,OAA+C,EAAE,MAAY,EAAE,QAAqC;QACxH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CAAC,EAAE;gBAC1B,OAAO;oBACL,GAAG;oBACH,IAAI,EAAE,WAAW;oBACjB,GAAG,EAAE,UAAU;iBAChB,CAAC;aACH;YAED,IAAI,IAAA,eAAQ,EAAC,UAAU,CAAC,EAAE;gBACxB,UAAU,GAAG,EAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAC,CAAC;aACxD;YAED,IAAI,EAAC,GAAG,EAAE,OAAO,EAAC,GAAG,UAAU,CAAC;YAEhC,IAAI,IAAA,eAAQ,EAAC,GAAG,CAAC,EAAE;gBACjB,IAAI,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBACnF,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;iBACpE;qBAAM;oBACL,MAAM,GAAG,GAAG,wDAAa,GAAG,GAAC,CAAC;oBAC9B,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;iBACrC;aACF;YAED,OAAO;gBACL,GAAG;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,UAAU;gBACb,GAAG;aACJ,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACzD,CAAC;CACF;AA1YD,0CA0YC","sourcesContent":["import {isFunction, isString, nameOf, Type} from \"@tsed/core\";\nimport {colors, InjectorService, ProviderOpts, setLoggerConfiguration, TokenProvider} from \"@tsed/di\";\nimport {getMiddlewaresForHook, PlatformMiddlewareLoadingOptions} from \"@tsed/platform-middlewares\";\nimport {PlatformLayer} from \"@tsed/platform-router\";\nimport type {IncomingMessage, Server, ServerResponse} from \"http\";\nimport type Https from \"https\";\nimport {PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\nimport {Route} from \"../interfaces/Route\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"../services/PlatformAdapter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformTest} from \"../services/PlatformTest\";\nimport {createHttpServer} from \"../utils/createHttpServer\";\nimport {createHttpsServer} from \"../utils/createHttpsServer\";\nimport {createInjector} from \"../utils/createInjector\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {getStaticsOptions} from \"../utils/getStaticsOptions\";\nimport {printRoutes} from \"../utils/printRoutes\";\n\n/**\n * @platform\n */\nexport class PlatformBuilder<App = TsED.Application> {\n public static adapter: Type<PlatformAdapter<any>>;\n\n readonly name: string = \"\";\n protected startedAt = new Date();\n protected current = new Date();\n readonly #injector: InjectorService;\n readonly #rootModule: Type<any>;\n readonly #adapter: PlatformAdapter<App>;\n #promise: Promise<this>;\n #servers: (() => Promise<Server | Https.Server>)[];\n #listeners: (Server | Https.Server)[] = [];\n\n protected constructor(adapter: Type<PlatformAdapter<App>> | undefined, module: Type, settings: Partial<TsED.Configuration>) {\n this.#rootModule = module;\n\n const configuration = getConfiguration(settings, module);\n const adapterKlass: Type<PlatformAdapter<App>> = adapter || (PlatformBuilder.adapter as any);\n const name = nameOf(adapterKlass).replace(\"Platform\", \"\").toLowerCase();\n\n configuration.PLATFORM_NAME = name;\n this.name = name;\n\n this.#injector = createInjector({\n adapter: adapterKlass,\n settings: configuration\n });\n\n this.#adapter = this.#injector.get<PlatformAdapter<App>>(PlatformAdapter)!;\n\n this.createHttpServers();\n\n this.#adapter.onInit && this.#adapter.onInit();\n\n this.log(\"Injector created...\");\n }\n\n get injector(): InjectorService {\n return this.#injector;\n }\n\n get rootModule(): any {\n return this.#injector.get(this.#rootModule);\n }\n\n get app(): PlatformApplication<App> {\n return this.injector.get<PlatformApplication<App>>(PlatformApplication)!;\n }\n\n get platform() {\n return this.injector.get<Platform>(Platform)!;\n }\n\n get adapter() {\n return this.#adapter;\n }\n\n /**\n * Return the settings configured by the decorator @@Configuration@@.\n *\n * ```typescript\n * @Configuration({\n * rootDir: Path.resolve(__dirname),\n * port: 8000,\n * httpsPort: 8080,\n * mount: {\n * \"/rest\": \"${rootDir}/controllers/**\\/*.js\"\n * }\n * })\n * export class Server {\n * $onInit(){\n * console.log(this.settings); // {rootDir, port, httpsPort,...}\n * }\n * }\n * ```\n *\n * @returns {PlatformConfiguration}\n */\n get settings() {\n return this.injector.settings;\n }\n\n get logger() {\n return this.injector.logger;\n }\n\n get disableBootstrapLog() {\n return this.settings.get(\"logger.disableBootstrapLog\");\n }\n\n static create<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build(module, {\n httpsPort: false,\n httpPort: false,\n ...settings\n });\n }\n\n static build<App = TsED.Application>(module: Type<any>, {adapter, ...settings}: PlatformBuilderSettings<App>) {\n return new PlatformBuilder(adapter, module, settings);\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build<App>(module, settings).bootstrap();\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => void;\n callback(req: IncomingMessage, res: ServerResponse): void;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n if (req && res) {\n return this.callback()(req, res);\n }\n\n return this.app.callback();\n }\n\n log(...data: any[]) {\n return !this.disableBootstrapLog && this.logger.info(...data, this.diff());\n }\n\n /**\n * Add classes to the components list\n * @param classes\n */\n public addComponents(classes: Type | Type[]) {\n this.settings.set(\"imports\", this.settings.get<any[]>(\"imports\", []).concat(classes));\n\n return this;\n }\n\n /**\n * Add classes decorated by @@Controller@@ to components container.\n *\n * ### Example\n *\n * ```typescript\n * @Controller('/ctrl')\n * class MyController{\n * }\n *\n * platform.addControllers('/rest', [MyController])\n * ```\n *\n * ::: tip\n * If the MyController class isn't decorated, the class will be ignored.\n * :::\n *\n * @param {string} endpoint\n * @param {any[]} controllers\n */\n public addControllers(endpoint: string, controllers: TokenProvider | TokenProvider[]) {\n [].concat(controllers).forEach((token) => {\n this.settings.routes.push({token, route: endpoint});\n });\n }\n\n public async runLifecycle() {\n setLoggerConfiguration(this.injector);\n\n await this.mapTokenMiddlewares();\n\n await this.loadInjector();\n\n this.#adapter.useContext();\n\n await this.loadRoutes();\n\n return this;\n }\n\n async loadInjector() {\n const {injector} = this;\n this.log(\"Build providers\");\n\n await injector.loadModule(this.#rootModule);\n\n this.log(\"Settings and injector loaded...\");\n\n await this.callHook(\"$afterInit\");\n }\n\n async listen(network = true) {\n if (!this.#promise) {\n await this.bootstrap();\n }\n\n await this.callHook(\"$beforeListen\");\n\n if (network) {\n await this.listenServers();\n }\n\n await this.callHook(\"$afterListen\");\n\n await this.ready();\n }\n\n async stop() {\n await this.callHook(\"$onDestroy\");\n await this.injector.destroy();\n\n this.#listeners.map((server) => {\n return new Promise((resolve) => server.close(() => resolve(undefined)));\n });\n }\n\n public async ready() {\n const {startedAt} = this;\n\n await this.callHook(\"$onReady\");\n await this.injector.emit(\"$onServerReady\");\n\n this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);\n }\n\n async callHook(hook: string, ...args: any[]) {\n const {injector} = this;\n\n if (!this.disableBootstrapLog) {\n injector.logger.debug(`\\x1B[1mCall hook ${hook}\\x1B[22m`);\n }\n\n // Load middlewares for the given hook\n this.loadMiddlewaresFor(hook);\n\n // call hooks added by providers\n await injector.emit(hook, ...args);\n }\n\n async loadStatics(hook: string): Promise<void> {\n const statics = this.settings.get<PlatformStaticsSettings>(\"statics\");\n\n getStaticsOptions(statics).forEach(({path, options}) => {\n if (options.hook === hook) {\n this.platform.app.statics(path, options);\n }\n });\n }\n\n useProvider(token: Type<any>, settings?: Partial<ProviderOpts>) {\n this.injector.addProvider(token, settings);\n\n return this;\n }\n\n async bootstrap() {\n this.#promise = this.#promise || this.runLifecycle();\n\n return this.#promise;\n }\n\n protected async loadRoutes() {\n this.#adapter.beforeLoadRoutes && (await this.#adapter.beforeLoadRoutes());\n\n // istanbul ignore next\n if (this.settings.get(\"logger.level\") !== \"off\") {\n const {PlatformLogMiddleware} = await import(\"@tsed/platform-log-middleware\");\n this.app.use(PlatformLogMiddleware);\n }\n\n this.log(\"Load routes\");\n\n if (this.rootModule.$beforeRoutesInit) {\n await this.rootModule.$beforeRoutesInit();\n this.rootModule.$beforeRoutesInit = () => {};\n }\n\n await this.loadStatics(\"$beforeRoutesInit\");\n await this.callHook(\"$beforeRoutesInit\");\n\n const routes = this.injector.settings.get<Route[]>(\"routes\");\n\n this.platform.addRoutes(routes);\n\n await this.callHook(\"$onRoutesInit\");\n\n await this.loadStatics(\"$afterRoutesInit\");\n\n await this.callHook(\"$afterRoutesInit\");\n\n this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());\n\n await this.mapRouters();\n }\n\n protected async mapRouters() {\n const layers = this.platform.getLayers();\n\n this.#adapter.mapLayers(layers);\n\n const rawBody =\n this.settings.get(\"rawBody\") ||\n layers.some(({handlers}) => {\n return handlers.some((handler) => handler.opts?.paramsTypes?.RAW_BODY);\n });\n\n this.settings.set(\"rawBody\", rawBody);\n\n return this.logRoutes(layers.filter((layer) => layer.isProvider()));\n }\n\n protected diff() {\n const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);\n this.current = new Date();\n return ms;\n }\n\n /**\n * Load middlewares from configuration for the given hook\n * @param hook\n * @protected\n */\n protected loadMiddlewaresFor(hook: string): void {\n return getMiddlewaresForHook(hook, this.settings, \"$beforeRoutesInit\").forEach(({use}) => {\n this.app.use(use);\n });\n }\n\n protected createHttpServers() {\n this.#servers = [createHttpServer(this.#injector, this.callback()), createHttpsServer(this.#injector, this.callback())].filter(\n Boolean\n ) as any[];\n }\n\n protected async listenServers(): Promise<void> {\n this.#listeners = await Promise.all(this.#servers.map((cb) => cb && cb()));\n }\n\n protected async logRoutes(layers: PlatformLayer[]) {\n const {logger} = this;\n\n this.log(\"Routes mounted...\");\n\n if (!this.settings.get(\"logger.disableRoutesSummary\") && !this.disableBootstrapLog) {\n const routes: PlatformRouteDetails[] = layers.map((layer) => {\n return {\n url: layer.path,\n method: layer.method,\n name: layer.opts.name || `${layer.provider.className}.constructor()`,\n className: layer.opts.className || layer.provider.className,\n methodClassName: layer.opts.methodClassName || \"\"\n } as PlatformRouteDetails;\n });\n\n logger.info(printRoutes(await this.injector.alterAsync(\"$logRoutes\", routes)));\n }\n }\n\n protected async mapTokenMiddlewares() {\n let middlewares = this.injector.settings.get<PlatformMiddlewareLoadingOptions[]>(\"middlewares\", []);\n const {env} = this.injector.settings;\n const defaultHook = \"$beforeRoutesInit\";\n\n const promises = middlewares.map(async (middleware: PlatformMiddlewareLoadingOptions): Promise<PlatformMiddlewareLoadingOptions> => {\n if (isFunction(middleware)) {\n return {\n env,\n hook: defaultHook,\n use: middleware\n };\n }\n\n if (isString(middleware)) {\n middleware = {env, use: middleware, hook: defaultHook};\n }\n\n let {use, options} = middleware;\n\n if (isString(use)) {\n if ([\"text-parser\", \"raw-parser\", \"json-parser\", \"urlencoded-parser\"].includes(use)) {\n use = this.adapter.bodyParser(use.replace(\"-parser\", \"\"), options);\n } else {\n const mod = await import(use);\n use = (mod.default || mod)(options);\n }\n }\n\n return {\n env,\n hook: defaultHook,\n ...middleware,\n use\n };\n });\n\n middlewares = await Promise.all(promises);\n\n this.injector.settings.set(\"middlewares\", middlewares);\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlatformProvider = void 0;
4
+ const registerPlatformAdapter_1 = require("../utils/registerPlatformAdapter");
5
+ function PlatformProvider() {
6
+ return (klass) => {
7
+ (0, registerPlatformAdapter_1.registerPlatformAdapter)(klass);
8
+ };
9
+ }
10
+ exports.PlatformProvider = PlatformProvider;
11
+ //# sourceMappingURL=PlatformProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformProvider.js","sourceRoot":"","sources":["../../../src/decorators/PlatformProvider.ts"],"names":[],"mappings":";;;AAEA,8EAAyE;AAEzE,SAAgB,gBAAgB;IAC9B,OAAO,CAAC,KAA4B,EAAE,EAAE;QACtC,IAAA,iDAAuB,EAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC;AAJD,4CAIC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\nimport {registerPlatformAdapter} from \"../utils/registerPlatformAdapter\";\n\nexport function PlatformProvider() {\n return (klass: Type<PlatformAdapter>) => {\n registerPlatformAdapter(klass);\n };\n}\n"]}
package/lib/cjs/index.js CHANGED
@@ -12,6 +12,7 @@ tslib_1.__exportStar(require("./config/interfaces/PlatformMulterSettings"), expo
12
12
  tslib_1.__exportStar(require("./config/interfaces/PlatformStaticsSettings"), exports);
13
13
  tslib_1.__exportStar(require("./config/services/PlatformConfiguration"), exports);
14
14
  tslib_1.__exportStar(require("./constants/routerOptions"), exports);
15
+ tslib_1.__exportStar(require("./decorators/PlatformProvider"), exports);
15
16
  tslib_1.__exportStar(require("./decorators/multer/multerFileSize"), exports);
16
17
  tslib_1.__exportStar(require("./decorators/multer/multerOptions"), exports);
17
18
  tslib_1.__exportStar(require("./decorators/multer/multipartFile"), exports);
@@ -58,5 +59,6 @@ tslib_1.__exportStar(require("./utils/getStaticsOptions"), exports);
58
59
  tslib_1.__exportStar(require("./utils/listenServer"), exports);
59
60
  tslib_1.__exportStar(require("./utils/mapReturnedResponse"), exports);
60
61
  tslib_1.__exportStar(require("./utils/printRoutes"), exports);
62
+ tslib_1.__exportStar(require("./utils/registerPlatformAdapter"), exports);
61
63
  tslib_1.__exportStar(require("./utils/setResponseHeaders"), exports);
62
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAA0B;AAC1B,oEAA0C;AAC1C,yFAA+D;AAC/D,qFAA2D;AAC3D,qFAA2D;AAC3D,sFAA4D;AAC5D,kFAAwD;AACxD,oEAA0C;AAC1C,6EAAmD;AACnD,4EAAkD;AAClD,4EAAkD;AAClD,oEAA0C;AAC1C,mEAAyC;AACzC,sEAA4C;AAC5C,uEAA6C;AAC7C,uEAA6C;AAC7C,oEAA0C;AAC1C,mEAAyC;AACzC,wEAA8C;AAC9C,iEAAuC;AACvC,mEAAyC;AACzC,uEAA6C;AAC7C,kEAAwC;AACxC,oEAA0C;AAC1C,wEAA8C;AAC9C,mEAAyC;AACzC,qEAA2C;AAC3C,+DAAqC;AACrC,iEAAuC;AACvC,kEAAwC;AACxC,oEAA0C;AAC1C,4EAAkD;AAClD,2EAAiD;AACjD,6DAAmC;AACnC,sFAA4D;AAC5D,iFAAuD;AACvD,iEAAuC;AACvC,8DAAoC;AACpC,qEAA2C;AAC3C,yEAA+C;AAC/C,qEAA2C;AAC3C,8EAAoD;AACpD,qEAA2C;AAC3C,sEAA4C;AAC5C,kEAAwC;AACxC,gEAAsC;AACtC,mEAAyC;AACzC,oEAA0C;AAC1C,iEAAuC;AACvC,gEAAsC;AACtC,oEAA0C;AAC1C,+DAAqC;AACrC,sEAA4C;AAC5C,8DAAoC;AACpC,qEAA2C","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./config/interfaces/PlatformJsonMapperSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/ensureContext\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAA0B;AAC1B,oEAA0C;AAC1C,yFAA+D;AAC/D,qFAA2D;AAC3D,qFAA2D;AAC3D,sFAA4D;AAC5D,kFAAwD;AACxD,oEAA0C;AAC1C,wEAA8C;AAC9C,6EAAmD;AACnD,4EAAkD;AAClD,4EAAkD;AAClD,oEAA0C;AAC1C,mEAAyC;AACzC,sEAA4C;AAC5C,uEAA6C;AAC7C,uEAA6C;AAC7C,oEAA0C;AAC1C,mEAAyC;AACzC,wEAA8C;AAC9C,iEAAuC;AACvC,mEAAyC;AACzC,uEAA6C;AAC7C,kEAAwC;AACxC,oEAA0C;AAC1C,wEAA8C;AAC9C,mEAAyC;AACzC,qEAA2C;AAC3C,+DAAqC;AACrC,iEAAuC;AACvC,kEAAwC;AACxC,oEAA0C;AAC1C,4EAAkD;AAClD,2EAAiD;AACjD,6DAAmC;AACnC,sFAA4D;AAC5D,iFAAuD;AACvD,iEAAuC;AACvC,8DAAoC;AACpC,qEAA2C;AAC3C,yEAA+C;AAC/C,qEAA2C;AAC3C,8EAAoD;AACpD,qEAA2C;AAC3C,sEAA4C;AAC5C,kEAAwC;AACxC,gEAAsC;AACtC,mEAAyC;AACzC,oEAA0C;AAC1C,iEAAuC;AACvC,gEAAsC;AACtC,oEAA0C;AAC1C,+DAAqC;AACrC,sEAA4C;AAC5C,8DAAoC;AACpC,0EAAgD;AAChD,qEAA2C","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./config/interfaces/PlatformJsonMapperSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/PlatformProvider\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/ensureContext\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/registerPlatformAdapter\";\nexport * from \"./utils/setResponseHeaders\";\n"]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerPlatformAdapter = void 0;
4
+ const PlatformBuilder_1 = require("../builder/PlatformBuilder");
5
+ const PlatformTest_1 = require("../services/PlatformTest");
6
+ function registerPlatformAdapter(adapter) {
7
+ PlatformTest_1.PlatformTest.adapter = adapter;
8
+ PlatformBuilder_1.PlatformBuilder.adapter = adapter;
9
+ }
10
+ exports.registerPlatformAdapter = registerPlatformAdapter;
11
+ //# sourceMappingURL=registerPlatformAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerPlatformAdapter.js","sourceRoot":"","sources":["../../../src/utils/registerPlatformAdapter.ts"],"names":[],"mappings":";;;AACA,gEAA2D;AAE3D,2DAAsD;AAEtD,SAAgB,uBAAuB,CAAC,OAAmC;IACzE,2BAAY,CAAC,OAAO,GAAG,OAAO,CAAC;IAC/B,iCAAe,CAAC,OAAO,GAAG,OAAO,CAAC;AACpC,CAAC;AAHD,0DAGC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PlatformBuilder} from \"../builder/PlatformBuilder\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\nimport {PlatformTest} from \"../services/PlatformTest\";\n\nexport function registerPlatformAdapter(adapter: Type<PlatformAdapter<any>>) {\n PlatformTest.adapter = adapter;\n PlatformBuilder.adapter = adapter;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAO,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAC,MAAM,EAAiC,sBAAsB,EAAgB,MAAM,UAAU,CAAC;AACtG,OAAO,EAAC,qBAAqB,EAAmC,MAAM,4BAA4B,CAAC;AAOnG,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;A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,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;iBACpE;qBAAM;oBACL,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;oBAC9B,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;iBACrC;aACF;YAED,OAAO;gBACL,GAAG;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,UAAU;gBACb,GAAG;aACJ,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["import {isFunction, isString, nameOf, Type} from \"@tsed/core\";\nimport {colors, InjectorService, ProviderOpts, setLoggerConfiguration, TokenProvider} from \"@tsed/di\";\nimport {getMiddlewaresForHook, PlatformMiddlewareLoadingOptions} from \"@tsed/platform-middlewares\";\nimport {PlatformLayer} from \"@tsed/platform-router\";\nimport type {IncomingMessage, Server, ServerResponse} from \"http\";\nimport type Https from \"https\";\nimport {PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\nimport {Route} from \"../interfaces/Route\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"../services/PlatformAdapter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {createHttpServer} from \"../utils/createHttpServer\";\nimport {createHttpsServer} from \"../utils/createHttpsServer\";\nimport {createInjector} from \"../utils/createInjector\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {getStaticsOptions} from \"../utils/getStaticsOptions\";\nimport {printRoutes} from \"../utils/printRoutes\";\n\n/**\n * @platform\n */\nexport class PlatformBuilder<App = TsED.Application> {\n public static adapter: Type<PlatformAdapter<any>>;\n\n readonly name: string = \"\";\n protected startedAt = new Date();\n protected current = new Date();\n readonly #injector: InjectorService;\n readonly #rootModule: Type<any>;\n readonly #adapter: PlatformAdapter<App>;\n #promise: Promise<this>;\n #servers: (() => Promise<Server | Https.Server>)[];\n #listeners: (Server | Https.Server)[] = [];\n\n protected constructor(adapter: Type<PlatformAdapter<App>> | undefined, module: Type, settings: Partial<TsED.Configuration>) {\n this.#rootModule = module;\n\n const configuration = getConfiguration(settings, module);\n const adapterKlass: Type<PlatformAdapter<App>> = adapter || (PlatformBuilder.adapter as any);\n const name = nameOf(adapterKlass).replace(\"Platform\", \"\").toLowerCase();\n\n configuration.PLATFORM_NAME = name;\n this.name = name;\n\n this.#injector = createInjector({\n adapter: adapterKlass,\n settings: configuration\n });\n\n this.#adapter = this.#injector.get<PlatformAdapter<App>>(PlatformAdapter)!;\n\n this.createHttpServers();\n\n this.#adapter.onInit && this.#adapter.onInit();\n\n this.log(\"Injector created...\");\n }\n\n get injector(): InjectorService {\n return this.#injector;\n }\n\n get rootModule(): any {\n return this.#injector.get(this.#rootModule);\n }\n\n get app(): PlatformApplication<App> {\n return this.injector.get<PlatformApplication<App>>(PlatformApplication)!;\n }\n\n get platform() {\n return this.injector.get<Platform>(Platform)!;\n }\n\n get adapter() {\n return this.#adapter;\n }\n\n /**\n * Return the settings configured by the decorator @@Configuration@@.\n *\n * ```typescript\n * @Configuration({\n * rootDir: Path.resolve(__dirname),\n * port: 8000,\n * httpsPort: 8080,\n * mount: {\n * \"/rest\": \"${rootDir}/controllers/**\\/*.js\"\n * }\n * })\n * export class Server {\n * $onInit(){\n * console.log(this.settings); // {rootDir, port, httpsPort,...}\n * }\n * }\n * ```\n *\n * @returns {PlatformConfiguration}\n */\n get settings() {\n return this.injector.settings;\n }\n\n get logger() {\n return this.injector.logger;\n }\n\n get disableBootstrapLog() {\n return this.settings.get(\"logger.disableBootstrapLog\");\n }\n\n static create<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build(module, {\n httpsPort: false,\n httpPort: false,\n ...settings\n });\n }\n\n static build<App = TsED.Application>(module: Type<any>, {adapter, ...settings}: PlatformBuilderSettings<App>) {\n return new PlatformBuilder(adapter, module, settings);\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build<App>(module, settings).bootstrap();\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => void;\n callback(req: IncomingMessage, res: ServerResponse): void;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n if (req && res) {\n return this.callback()(req, res);\n }\n\n return this.app.callback();\n }\n\n log(...data: any[]) {\n return !this.disableBootstrapLog && this.logger.info(...data, this.diff());\n }\n\n /**\n * Add classes to the components list\n * @param classes\n */\n public addComponents(classes: Type | Type[]) {\n this.settings.set(\"imports\", this.settings.get<any[]>(\"imports\", []).concat(classes));\n\n return this;\n }\n\n /**\n * Add classes decorated by @@Controller@@ to components container.\n *\n * ### Example\n *\n * ```typescript\n * @Controller('/ctrl')\n * class MyController{\n * }\n *\n * platform.addControllers('/rest', [MyController])\n * ```\n *\n * ::: tip\n * If the MyController class isn't decorated, the class will be ignored.\n * :::\n *\n * @param {string} endpoint\n * @param {any[]} controllers\n */\n public addControllers(endpoint: string, controllers: TokenProvider | TokenProvider[]) {\n [].concat(controllers).forEach((token) => {\n this.settings.routes.push({token, route: endpoint});\n });\n }\n\n public async runLifecycle() {\n setLoggerConfiguration(this.injector);\n\n await this.mapTokenMiddlewares();\n\n await this.loadInjector();\n\n this.#adapter.useContext();\n\n await this.loadRoutes();\n\n return this;\n }\n\n async loadInjector() {\n const {injector} = this;\n this.log(\"Build providers\");\n\n await injector.loadModule(this.#rootModule);\n\n this.log(\"Settings and injector loaded...\");\n\n await this.callHook(\"$afterInit\");\n }\n\n async listen(network = true) {\n if (!this.#promise) {\n await this.bootstrap();\n }\n\n await this.callHook(\"$beforeListen\");\n\n if (network) {\n await this.listenServers();\n }\n\n await this.callHook(\"$afterListen\");\n\n await this.ready();\n }\n\n async stop() {\n await this.callHook(\"$onDestroy\");\n await this.injector.destroy();\n\n this.#listeners.map((server) => {\n return new Promise((resolve) => server.close(() => resolve(undefined)));\n });\n }\n\n public async ready() {\n const {startedAt} = this;\n\n await this.callHook(\"$onReady\");\n await this.injector.emit(\"$onServerReady\");\n\n this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);\n }\n\n async callHook(hook: string, ...args: any[]) {\n const {injector} = this;\n\n if (!this.disableBootstrapLog) {\n injector.logger.debug(`\\x1B[1mCall hook ${hook}\\x1B[22m`);\n }\n\n // Load middlewares for the given hook\n this.loadMiddlewaresFor(hook);\n\n // call hooks added by providers\n await injector.emit(hook, ...args);\n }\n\n async loadStatics(hook: string): Promise<void> {\n const statics = this.settings.get<PlatformStaticsSettings>(\"statics\");\n\n getStaticsOptions(statics).forEach(({path, options}) => {\n if (options.hook === hook) {\n this.platform.app.statics(path, options);\n }\n });\n }\n\n useProvider(token: Type<any>, settings?: Partial<ProviderOpts>) {\n this.injector.addProvider(token, settings);\n\n return this;\n }\n\n async bootstrap() {\n this.#promise = this.#promise || this.runLifecycle();\n\n return this.#promise;\n }\n\n protected async loadRoutes() {\n this.#adapter.beforeLoadRoutes && (await this.#adapter.beforeLoadRoutes());\n\n // istanbul ignore next\n if (this.settings.get(\"logger.level\") !== \"off\") {\n const {PlatformLogMiddleware} = await import(\"@tsed/platform-log-middleware\");\n this.app.use(PlatformLogMiddleware);\n }\n\n this.log(\"Load routes\");\n\n if (this.rootModule.$beforeRoutesInit) {\n await this.rootModule.$beforeRoutesInit();\n this.rootModule.$beforeRoutesInit = () => {};\n }\n\n await this.loadStatics(\"$beforeRoutesInit\");\n await this.callHook(\"$beforeRoutesInit\");\n\n const routes = this.injector.settings.get<Route[]>(\"routes\");\n\n this.platform.addRoutes(routes);\n\n await this.callHook(\"$onRoutesInit\");\n\n await this.loadStatics(\"$afterRoutesInit\");\n\n await this.callHook(\"$afterRoutesInit\");\n\n this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());\n\n await this.mapRouters();\n }\n\n protected async mapRouters() {\n const layers = this.platform.getLayers();\n\n this.#adapter.mapLayers(layers);\n\n const rawBody =\n this.settings.get(\"rawBody\") ||\n layers.some(({handlers}) => {\n return handlers.some((handler) => handler.opts?.paramsTypes?.RAW_BODY);\n });\n\n this.settings.set(\"rawBody\", rawBody);\n\n return this.logRoutes(layers.filter((layer) => layer.isProvider()));\n }\n\n protected diff() {\n const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);\n this.current = new Date();\n return ms;\n }\n\n /**\n * Load middlewares from configuration for the given hook\n * @param hook\n * @protected\n */\n protected loadMiddlewaresFor(hook: string): void {\n return getMiddlewaresForHook(hook, this.settings, \"$beforeRoutesInit\").forEach(({use}) => {\n this.app.use(use);\n });\n }\n\n protected createHttpServers() {\n this.#servers = [createHttpServer(this.#injector, this.callback()), createHttpsServer(this.#injector, this.callback())].filter(\n Boolean\n ) as any[];\n }\n\n protected async listenServers(): Promise<void> {\n this.#listeners = await Promise.all(this.#servers.map((cb) => cb && cb()));\n }\n\n protected async logRoutes(layers: PlatformLayer[]) {\n const {logger} = this;\n\n this.log(\"Routes mounted...\");\n\n if (!this.settings.get(\"logger.disableRoutesSummary\") && !this.disableBootstrapLog) {\n const routes: PlatformRouteDetails[] = layers.map((layer) => {\n return {\n url: layer.path,\n method: layer.method,\n name: layer.opts.name || `${layer.provider.className}.constructor()`,\n className: layer.opts.className || layer.provider.className,\n methodClassName: layer.opts.methodClassName || \"\"\n } as PlatformRouteDetails;\n });\n\n logger.info(printRoutes(await this.injector.alterAsync(\"$logRoutes\", routes)));\n }\n }\n\n protected async mapTokenMiddlewares() {\n let middlewares = this.injector.settings.get<PlatformMiddlewareLoadingOptions[]>(\"middlewares\", []);\n const {env} = this.injector.settings;\n const defaultHook = \"$beforeRoutesInit\";\n\n const promises = middlewares.map(async (middleware: PlatformMiddlewareLoadingOptions): Promise<PlatformMiddlewareLoadingOptions> => {\n if (isFunction(middleware)) {\n return {\n env,\n hook: defaultHook,\n use: middleware\n };\n }\n\n if (isString(middleware)) {\n middleware = {env, use: middleware, hook: defaultHook};\n }\n\n let {use, options} = middleware;\n\n if (isString(use)) {\n if ([\"text-parser\", \"raw-parser\", \"json-parser\", \"urlencoded-parser\"].includes(use)) {\n use = this.adapter.bodyParser(use.replace(\"-parser\", \"\"), options);\n } else {\n const mod = await import(use);\n use = (mod.default || mod)(options);\n }\n }\n\n return {\n env,\n hook: defaultHook,\n ...middleware,\n use\n };\n });\n\n middlewares = await Promise.all(promises);\n\n this.injector.settings.set(\"middlewares\", middlewares);\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformBuilder.js","sourceRoot":"","sources":["../../../src/builder/PlatformBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAO,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAC,MAAM,EAAiC,sBAAsB,EAAgB,MAAM,UAAU,CAAC;AACtG,OAAO,EAAC,qBAAqB,EAAmC,MAAM,4BAA4B,CAAC;AAOnG,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAA0B,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EA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AAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["import {isFunction, isString, nameOf, Type} from \"@tsed/core\";\nimport {colors, InjectorService, ProviderOpts, setLoggerConfiguration, TokenProvider} from \"@tsed/di\";\nimport {getMiddlewaresForHook, PlatformMiddlewareLoadingOptions} from \"@tsed/platform-middlewares\";\nimport {PlatformLayer} from \"@tsed/platform-router\";\nimport type {IncomingMessage, Server, ServerResponse} from \"http\";\nimport type Https from \"https\";\nimport {PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\nimport {Route} from \"../interfaces/Route\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"../services/PlatformAdapter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformTest} from \"../services/PlatformTest\";\nimport {createHttpServer} from \"../utils/createHttpServer\";\nimport {createHttpsServer} from \"../utils/createHttpsServer\";\nimport {createInjector} from \"../utils/createInjector\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {getStaticsOptions} from \"../utils/getStaticsOptions\";\nimport {printRoutes} from \"../utils/printRoutes\";\n\n/**\n * @platform\n */\nexport class PlatformBuilder<App = TsED.Application> {\n public static adapter: Type<PlatformAdapter<any>>;\n\n readonly name: string = \"\";\n protected startedAt = new Date();\n protected current = new Date();\n readonly #injector: InjectorService;\n readonly #rootModule: Type<any>;\n readonly #adapter: PlatformAdapter<App>;\n #promise: Promise<this>;\n #servers: (() => Promise<Server | Https.Server>)[];\n #listeners: (Server | Https.Server)[] = [];\n\n protected constructor(adapter: Type<PlatformAdapter<App>> | undefined, module: Type, settings: Partial<TsED.Configuration>) {\n this.#rootModule = module;\n\n const configuration = getConfiguration(settings, module);\n const adapterKlass: Type<PlatformAdapter<App>> = adapter || (PlatformBuilder.adapter as any);\n const name = nameOf(adapterKlass).replace(\"Platform\", \"\").toLowerCase();\n\n configuration.PLATFORM_NAME = name;\n this.name = name;\n\n this.#injector = createInjector({\n adapter: adapterKlass,\n settings: configuration\n });\n\n this.#adapter = this.#injector.get<PlatformAdapter<App>>(PlatformAdapter)!;\n\n this.createHttpServers();\n\n this.#adapter.onInit && this.#adapter.onInit();\n\n this.log(\"Injector created...\");\n }\n\n get injector(): InjectorService {\n return this.#injector;\n }\n\n get rootModule(): any {\n return this.#injector.get(this.#rootModule);\n }\n\n get app(): PlatformApplication<App> {\n return this.injector.get<PlatformApplication<App>>(PlatformApplication)!;\n }\n\n get platform() {\n return this.injector.get<Platform>(Platform)!;\n }\n\n get adapter() {\n return this.#adapter;\n }\n\n /**\n * Return the settings configured by the decorator @@Configuration@@.\n *\n * ```typescript\n * @Configuration({\n * rootDir: Path.resolve(__dirname),\n * port: 8000,\n * httpsPort: 8080,\n * mount: {\n * \"/rest\": \"${rootDir}/controllers/**\\/*.js\"\n * }\n * })\n * export class Server {\n * $onInit(){\n * console.log(this.settings); // {rootDir, port, httpsPort,...}\n * }\n * }\n * ```\n *\n * @returns {PlatformConfiguration}\n */\n get settings() {\n return this.injector.settings;\n }\n\n get logger() {\n return this.injector.logger;\n }\n\n get disableBootstrapLog() {\n return this.settings.get(\"logger.disableBootstrapLog\");\n }\n\n static create<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build(module, {\n httpsPort: false,\n httpPort: false,\n ...settings\n });\n }\n\n static build<App = TsED.Application>(module: Type<any>, {adapter, ...settings}: PlatformBuilderSettings<App>) {\n return new PlatformBuilder(adapter, module, settings);\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>) {\n return this.build<App>(module, settings).bootstrap();\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => void;\n callback(req: IncomingMessage, res: ServerResponse): void;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n if (req && res) {\n return this.callback()(req, res);\n }\n\n return this.app.callback();\n }\n\n log(...data: any[]) {\n return !this.disableBootstrapLog && this.logger.info(...data, this.diff());\n }\n\n /**\n * Add classes to the components list\n * @param classes\n */\n public addComponents(classes: Type | Type[]) {\n this.settings.set(\"imports\", this.settings.get<any[]>(\"imports\", []).concat(classes));\n\n return this;\n }\n\n /**\n * Add classes decorated by @@Controller@@ to components container.\n *\n * ### Example\n *\n * ```typescript\n * @Controller('/ctrl')\n * class MyController{\n * }\n *\n * platform.addControllers('/rest', [MyController])\n * ```\n *\n * ::: tip\n * If the MyController class isn't decorated, the class will be ignored.\n * :::\n *\n * @param {string} endpoint\n * @param {any[]} controllers\n */\n public addControllers(endpoint: string, controllers: TokenProvider | TokenProvider[]) {\n [].concat(controllers).forEach((token) => {\n this.settings.routes.push({token, route: endpoint});\n });\n }\n\n public async runLifecycle() {\n setLoggerConfiguration(this.injector);\n\n await this.mapTokenMiddlewares();\n\n await this.loadInjector();\n\n this.#adapter.useContext();\n\n await this.loadRoutes();\n\n return this;\n }\n\n async loadInjector() {\n const {injector} = this;\n this.log(\"Build providers\");\n\n await injector.loadModule(this.#rootModule);\n\n this.log(\"Settings and injector loaded...\");\n\n await this.callHook(\"$afterInit\");\n }\n\n async listen(network = true) {\n if (!this.#promise) {\n await this.bootstrap();\n }\n\n await this.callHook(\"$beforeListen\");\n\n if (network) {\n await this.listenServers();\n }\n\n await this.callHook(\"$afterListen\");\n\n await this.ready();\n }\n\n async stop() {\n await this.callHook(\"$onDestroy\");\n await this.injector.destroy();\n\n this.#listeners.map((server) => {\n return new Promise((resolve) => server.close(() => resolve(undefined)));\n });\n }\n\n public async ready() {\n const {startedAt} = this;\n\n await this.callHook(\"$onReady\");\n await this.injector.emit(\"$onServerReady\");\n\n this.log(`Started in ${new Date().getTime() - startedAt.getTime()} ms`);\n }\n\n async callHook(hook: string, ...args: any[]) {\n const {injector} = this;\n\n if (!this.disableBootstrapLog) {\n injector.logger.debug(`\\x1B[1mCall hook ${hook}\\x1B[22m`);\n }\n\n // Load middlewares for the given hook\n this.loadMiddlewaresFor(hook);\n\n // call hooks added by providers\n await injector.emit(hook, ...args);\n }\n\n async loadStatics(hook: string): Promise<void> {\n const statics = this.settings.get<PlatformStaticsSettings>(\"statics\");\n\n getStaticsOptions(statics).forEach(({path, options}) => {\n if (options.hook === hook) {\n this.platform.app.statics(path, options);\n }\n });\n }\n\n useProvider(token: Type<any>, settings?: Partial<ProviderOpts>) {\n this.injector.addProvider(token, settings);\n\n return this;\n }\n\n async bootstrap() {\n this.#promise = this.#promise || this.runLifecycle();\n\n return this.#promise;\n }\n\n protected async loadRoutes() {\n this.#adapter.beforeLoadRoutes && (await this.#adapter.beforeLoadRoutes());\n\n // istanbul ignore next\n if (this.settings.get(\"logger.level\") !== \"off\") {\n const {PlatformLogMiddleware} = await import(\"@tsed/platform-log-middleware\");\n this.app.use(PlatformLogMiddleware);\n }\n\n this.log(\"Load routes\");\n\n if (this.rootModule.$beforeRoutesInit) {\n await this.rootModule.$beforeRoutesInit();\n this.rootModule.$beforeRoutesInit = () => {};\n }\n\n await this.loadStatics(\"$beforeRoutesInit\");\n await this.callHook(\"$beforeRoutesInit\");\n\n const routes = this.injector.settings.get<Route[]>(\"routes\");\n\n this.platform.addRoutes(routes);\n\n await this.callHook(\"$onRoutesInit\");\n\n await this.loadStatics(\"$afterRoutesInit\");\n\n await this.callHook(\"$afterRoutesInit\");\n\n this.#adapter.afterLoadRoutes && (await this.#adapter.afterLoadRoutes());\n\n await this.mapRouters();\n }\n\n protected async mapRouters() {\n const layers = this.platform.getLayers();\n\n this.#adapter.mapLayers(layers);\n\n const rawBody =\n this.settings.get(\"rawBody\") ||\n layers.some(({handlers}) => {\n return handlers.some((handler) => handler.opts?.paramsTypes?.RAW_BODY);\n });\n\n this.settings.set(\"rawBody\", rawBody);\n\n return this.logRoutes(layers.filter((layer) => layer.isProvider()));\n }\n\n protected diff() {\n const ms = colors.yellow(`+${new Date().getTime() - this.current.getTime()}ms`);\n this.current = new Date();\n return ms;\n }\n\n /**\n * Load middlewares from configuration for the given hook\n * @param hook\n * @protected\n */\n protected loadMiddlewaresFor(hook: string): void {\n return getMiddlewaresForHook(hook, this.settings, \"$beforeRoutesInit\").forEach(({use}) => {\n this.app.use(use);\n });\n }\n\n protected createHttpServers() {\n this.#servers = [createHttpServer(this.#injector, this.callback()), createHttpsServer(this.#injector, this.callback())].filter(\n Boolean\n ) as any[];\n }\n\n protected async listenServers(): Promise<void> {\n this.#listeners = await Promise.all(this.#servers.map((cb) => cb && cb()));\n }\n\n protected async logRoutes(layers: PlatformLayer[]) {\n const {logger} = this;\n\n this.log(\"Routes mounted...\");\n\n if (!this.settings.get(\"logger.disableRoutesSummary\") && !this.disableBootstrapLog) {\n const routes: PlatformRouteDetails[] = layers.map((layer) => {\n return {\n url: layer.path,\n method: layer.method,\n name: layer.opts.name || `${layer.provider.className}.constructor()`,\n className: layer.opts.className || layer.provider.className,\n methodClassName: layer.opts.methodClassName || \"\"\n } as PlatformRouteDetails;\n });\n\n logger.info(printRoutes(await this.injector.alterAsync(\"$logRoutes\", routes)));\n }\n }\n\n protected async mapTokenMiddlewares() {\n let middlewares = this.injector.settings.get<PlatformMiddlewareLoadingOptions[]>(\"middlewares\", []);\n const {env} = this.injector.settings;\n const defaultHook = \"$beforeRoutesInit\";\n\n const promises = middlewares.map(async (middleware: PlatformMiddlewareLoadingOptions): Promise<PlatformMiddlewareLoadingOptions> => {\n if (isFunction(middleware)) {\n return {\n env,\n hook: defaultHook,\n use: middleware\n };\n }\n\n if (isString(middleware)) {\n middleware = {env, use: middleware, hook: defaultHook};\n }\n\n let {use, options} = middleware;\n\n if (isString(use)) {\n if ([\"text-parser\", \"raw-parser\", \"json-parser\", \"urlencoded-parser\"].includes(use)) {\n use = this.adapter.bodyParser(use.replace(\"-parser\", \"\"), options);\n } else {\n const mod = await import(use);\n use = (mod.default || mod)(options);\n }\n }\n\n return {\n env,\n hook: defaultHook,\n ...middleware,\n use\n };\n });\n\n middlewares = await Promise.all(promises);\n\n this.injector.settings.set(\"middlewares\", middlewares);\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { registerPlatformAdapter } from "../utils/registerPlatformAdapter.js";
2
+ export function PlatformProvider() {
3
+ return (klass) => {
4
+ registerPlatformAdapter(klass);
5
+ };
6
+ }
7
+ //# sourceMappingURL=PlatformProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformProvider.js","sourceRoot":"","sources":["../../../src/decorators/PlatformProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,uBAAuB,EAAC,MAAM,kCAAkC,CAAC;AAEzE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CAAC,KAA4B,EAAE,EAAE;QACtC,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\nimport {registerPlatformAdapter} from \"../utils/registerPlatformAdapter\";\n\nexport function PlatformProvider() {\n return (klass: Type<PlatformAdapter>) => {\n registerPlatformAdapter(klass);\n };\n}\n"]}
package/lib/esm/index.js CHANGED
@@ -9,6 +9,7 @@ export * from "./config/interfaces/PlatformMulterSettings.js";
9
9
  export * from "./config/interfaces/PlatformStaticsSettings.js";
10
10
  export * from "./config/services/PlatformConfiguration.js";
11
11
  export * from "./constants/routerOptions.js";
12
+ export * from "./decorators/PlatformProvider.js";
12
13
  export * from "./decorators/multer/multerFileSize.js";
13
14
  export * from "./decorators/multer/multerOptions.js";
14
15
  export * from "./decorators/multer/multipartFile.js";
@@ -55,5 +56,6 @@ export * from "./utils/getStaticsOptions.js";
55
56
  export * from "./utils/listenServer.js";
56
57
  export * from "./utils/mapReturnedResponse.js";
57
58
  export * from "./utils/printRoutes.js";
59
+ export * from "./utils/registerPlatformAdapter.js";
58
60
  export * from "./utils/setResponseHeaders.js";
59
61
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./config/interfaces/PlatformJsonMapperSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/ensureContext\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./config/interfaces/PlatformJsonMapperSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/PlatformProvider\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/ensureContext\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/registerPlatformAdapter\";\nexport * from \"./utils/setResponseHeaders\";\n"]}
@@ -0,0 +1,7 @@
1
+ import { PlatformBuilder } from "../builder/PlatformBuilder.js";
2
+ import { PlatformTest } from "../services/PlatformTest.js";
3
+ export function registerPlatformAdapter(adapter) {
4
+ PlatformTest.adapter = adapter;
5
+ PlatformBuilder.adapter = adapter;
6
+ }
7
+ //# sourceMappingURL=registerPlatformAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerPlatformAdapter.js","sourceRoot":"","sources":["../../../src/utils/registerPlatformAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAEtD,MAAM,UAAU,uBAAuB,CAAC,OAAmC;IACzE,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC;IAC/B,eAAe,CAAC,OAAO,GAAG,OAAO,CAAC;AACpC,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PlatformBuilder} from \"../builder/PlatformBuilder\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\nimport {PlatformTest} from \"../services/PlatformTest\";\n\nexport function registerPlatformAdapter(adapter: Type<PlatformAdapter<any>>) {\n PlatformTest.adapter = adapter;\n PlatformBuilder.adapter = adapter;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { Type } from "@tsed/core";
2
+ import { PlatformAdapter } from "../services/PlatformAdapter";
3
+ export declare function PlatformProvider(): (klass: Type<PlatformAdapter>) => void;
@@ -9,6 +9,7 @@ export * from "./config/interfaces/PlatformMulterSettings";
9
9
  export * from "./config/interfaces/PlatformStaticsSettings";
10
10
  export * from "./config/services/PlatformConfiguration";
11
11
  export * from "./constants/routerOptions";
12
+ export * from "./decorators/PlatformProvider";
12
13
  export * from "./decorators/multer/multerFileSize";
13
14
  export * from "./decorators/multer/multerOptions";
14
15
  export * from "./decorators/multer/multipartFile";
@@ -55,4 +56,5 @@ export * from "./utils/getStaticsOptions";
55
56
  export * from "./utils/listenServer";
56
57
  export * from "./utils/mapReturnedResponse";
57
58
  export * from "./utils/printRoutes";
59
+ export * from "./utils/registerPlatformAdapter";
58
60
  export * from "./utils/setResponseHeaders";
@@ -0,0 +1,3 @@
1
+ import { Type } from "@tsed/core";
2
+ import { PlatformAdapter } from "../services/PlatformAdapter";
3
+ export declare function registerPlatformAdapter(adapter: Type<PlatformAdapter<any>>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/common",
3
- "version": "7.10.1",
3
+ "version": "7.12.0",
4
4
  "description": "A TypeScript Framework on top of Express",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -62,21 +62,21 @@
62
62
  }
63
63
  ],
64
64
  "dependencies": {
65
- "@tsed/core": "7.10.1",
66
- "@tsed/di": "7.10.1",
67
- "@tsed/exceptions": "7.10.1",
68
- "@tsed/json-mapper": "7.10.1",
65
+ "@tsed/core": "7.12.0",
66
+ "@tsed/di": "7.12.0",
67
+ "@tsed/exceptions": "7.12.0",
68
+ "@tsed/json-mapper": "7.12.0",
69
69
  "@tsed/logger": ">=6.2.2",
70
70
  "@tsed/logger-file": ">=6.2.2",
71
- "@tsed/perf": "7.10.1",
72
- "@tsed/platform-exceptions": "7.10.1",
73
- "@tsed/platform-log-middleware": "7.10.1",
74
- "@tsed/platform-middlewares": "7.10.1",
75
- "@tsed/platform-params": "7.10.1",
76
- "@tsed/platform-response-filter": "7.10.1",
77
- "@tsed/platform-router": "7.10.1",
78
- "@tsed/platform-views": "7.10.1",
79
- "@tsed/schema": "7.10.1",
71
+ "@tsed/perf": "7.12.0",
72
+ "@tsed/platform-exceptions": "7.12.0",
73
+ "@tsed/platform-log-middleware": "7.12.0",
74
+ "@tsed/platform-middlewares": "7.12.0",
75
+ "@tsed/platform-params": "7.12.0",
76
+ "@tsed/platform-response-filter": "7.12.0",
77
+ "@tsed/platform-router": "7.12.0",
78
+ "@tsed/platform-views": "7.12.0",
79
+ "@tsed/schema": "7.12.0",
80
80
  "@types/json-schema": "7.0.11",
81
81
  "tslib": "2.4.0",
82
82
  "uuid": "8.3.2"