@tsed/platform-express 7.0.0-beta.2 → 7.0.0-beta.20

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.
Files changed (96) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +9 -0
  3. package/lib/cjs/components/PlatformExpress.js +126 -66
  4. package/lib/cjs/components/PlatformExpress.js.map +1 -1
  5. package/lib/cjs/exports.js +7 -0
  6. package/lib/cjs/exports.js.map +1 -0
  7. package/lib/cjs/index.js +9 -12
  8. package/lib/cjs/index.js.map +1 -1
  9. package/lib/cjs/interfaces/PlatformExpressSettings.js.map +1 -1
  10. package/lib/cjs/interfaces/interfaces.js +3 -0
  11. package/lib/cjs/interfaces/interfaces.js.map +1 -0
  12. package/lib/cjs/middlewares/staticsMiddleware.js +1 -1
  13. package/lib/cjs/middlewares/staticsMiddleware.js.map +1 -1
  14. package/lib/cjs/package.json +3 -0
  15. package/lib/esm/components/PlatformExpress.js +126 -48
  16. package/lib/esm/components/PlatformExpress.js.map +1 -1
  17. package/lib/esm/exports.js +5 -0
  18. package/lib/esm/exports.js.map +1 -0
  19. package/lib/esm/index.js +9 -12
  20. package/lib/esm/index.js.map +1 -1
  21. package/lib/esm/interfaces/PlatformExpressSettings.js.map +1 -1
  22. package/lib/esm/interfaces/interfaces.js +2 -0
  23. package/lib/esm/interfaces/interfaces.js.map +1 -0
  24. package/lib/esm/package.json +3 -0
  25. package/lib/types/components/PlatformExpress.d.ts +40 -22
  26. package/lib/types/exports.d.ts +1 -0
  27. package/lib/types/index.d.ts +8 -3
  28. package/lib/types/interfaces/PlatformExpressSettings.d.ts +15 -1
  29. package/lib/types/interfaces/{index.d.ts → interfaces.d.ts} +6 -4
  30. package/package.json +64 -26
  31. package/readme.md +3 -4
  32. package/tsconfig.compile.esm.json +1 -12
  33. package/lib/cjs/decorators/caseSensitive.js +0 -31
  34. package/lib/cjs/decorators/caseSensitive.js.map +0 -1
  35. package/lib/cjs/decorators/index.js +0 -8
  36. package/lib/cjs/decorators/index.js.map +0 -1
  37. package/lib/cjs/decorators/mergeParams.js +0 -31
  38. package/lib/cjs/decorators/mergeParams.js.map +0 -1
  39. package/lib/cjs/decorators/routerSettings.js +0 -32
  40. package/lib/cjs/decorators/routerSettings.js.map +0 -1
  41. package/lib/cjs/decorators/strict.js +0 -31
  42. package/lib/cjs/decorators/strict.js.map +0 -1
  43. package/lib/cjs/interfaces/index.js +0 -6
  44. package/lib/cjs/interfaces/index.js.map +0 -1
  45. package/lib/cjs/middlewares/rawBodyMiddleware.js +0 -27
  46. package/lib/cjs/middlewares/rawBodyMiddleware.js.map +0 -1
  47. package/lib/cjs/services/PlatformExpressApplication.js +0 -32
  48. package/lib/cjs/services/PlatformExpressApplication.js.map +0 -1
  49. package/lib/cjs/services/PlatformExpressHandler.js +0 -31
  50. package/lib/cjs/services/PlatformExpressHandler.js.map +0 -1
  51. package/lib/cjs/services/PlatformExpressRequest.js +0 -12
  52. package/lib/cjs/services/PlatformExpressRequest.js.map +0 -1
  53. package/lib/cjs/services/PlatformExpressResponse.js +0 -12
  54. package/lib/cjs/services/PlatformExpressResponse.js.map +0 -1
  55. package/lib/cjs/services/PlatformExpressRouter.js +0 -34
  56. package/lib/cjs/services/PlatformExpressRouter.js.map +0 -1
  57. package/lib/cjs/services/index.js +0 -9
  58. package/lib/cjs/services/index.js.map +0 -1
  59. package/lib/esm/decorators/caseSensitive.js +0 -27
  60. package/lib/esm/decorators/caseSensitive.js.map +0 -1
  61. package/lib/esm/decorators/index.js +0 -5
  62. package/lib/esm/decorators/index.js.map +0 -1
  63. package/lib/esm/decorators/mergeParams.js +0 -27
  64. package/lib/esm/decorators/mergeParams.js.map +0 -1
  65. package/lib/esm/decorators/routerSettings.js +0 -28
  66. package/lib/esm/decorators/routerSettings.js.map +0 -1
  67. package/lib/esm/decorators/strict.js +0 -27
  68. package/lib/esm/decorators/strict.js.map +0 -1
  69. package/lib/esm/interfaces/index.js +0 -3
  70. package/lib/esm/interfaces/index.js.map +0 -1
  71. package/lib/esm/middlewares/rawBodyMiddleware.js +0 -22
  72. package/lib/esm/middlewares/rawBodyMiddleware.js.map +0 -1
  73. package/lib/esm/services/PlatformExpressApplication.js +0 -29
  74. package/lib/esm/services/PlatformExpressApplication.js.map +0 -1
  75. package/lib/esm/services/PlatformExpressHandler.js +0 -27
  76. package/lib/esm/services/PlatformExpressHandler.js.map +0 -1
  77. package/lib/esm/services/PlatformExpressRequest.js +0 -8
  78. package/lib/esm/services/PlatformExpressRequest.js.map +0 -1
  79. package/lib/esm/services/PlatformExpressResponse.js +0 -8
  80. package/lib/esm/services/PlatformExpressResponse.js.map +0 -1
  81. package/lib/esm/services/PlatformExpressRouter.js +0 -31
  82. package/lib/esm/services/PlatformExpressRouter.js.map +0 -1
  83. package/lib/esm/services/index.js +0 -6
  84. package/lib/esm/services/index.js.map +0 -1
  85. package/lib/types/decorators/caseSensitive.d.ts +0 -23
  86. package/lib/types/decorators/index.d.ts +0 -4
  87. package/lib/types/decorators/mergeParams.d.ts +0 -23
  88. package/lib/types/decorators/routerSettings.d.ts +0 -24
  89. package/lib/types/decorators/strict.d.ts +0 -23
  90. package/lib/types/middlewares/rawBodyMiddleware.d.ts +0 -4
  91. package/lib/types/services/PlatformExpressApplication.d.ts +0 -24
  92. package/lib/types/services/PlatformExpressHandler.d.ts +0 -9
  93. package/lib/types/services/PlatformExpressRequest.d.ts +0 -22
  94. package/lib/types/services/PlatformExpressResponse.d.ts +0 -14
  95. package/lib/types/services/PlatformExpressRouter.d.ts +0 -18
  96. package/lib/types/services/index.d.ts +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../../src/components/PlatformExpress.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EAEb,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EA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C,OAAO,KAAK,EAAE;YACd,uBAAuB;YACvB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,sBAAsB;gBAC7B,OAAO,EAAE,oEAAoE;gBAC7E,KAAK;aACN,CAAC,CAAC;SACJ;IACH,CAAC;CACF","sourcesContent":["import Express from \"express\";\nimport type {PlatformViews} from \"@tsed/platform-views\";\nimport {\n createContext,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter\n} from \"@tsed/common\";\nimport {Env, Type} from \"@tsed/core\";\nimport {rawBodyMiddleware} from \"../middlewares/rawBodyMiddleware\";\nimport {\n PlatformExpressApplication,\n PlatformExpressHandler,\n PlatformExpressRequest,\n PlatformExpressResponse,\n PlatformExpressRouter\n} from \"../services\";\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpress implements PlatformAdapter<Express.Application, Express.Router> {\n readonly providers = [\n {\n provide: PlatformApplication,\n useClass: PlatformExpressApplication\n },\n {\n provide: PlatformRouter,\n useClass: PlatformExpressRouter\n },\n {\n provide: PlatformHandler,\n useClass: PlatformExpressHandler\n },\n {\n provide: PlatformResponse,\n useClass: PlatformExpressResponse\n },\n {\n provide: PlatformRequest,\n useClass: PlatformExpressRequest\n }\n ];\n\n constructor(private platform: PlatformBuilder<Express.Application, Express.Router>) {}\n\n /**\n * Create new serverless application. In this mode, the component scan are disabled.\n * @param module\n * @param settings\n */\n static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.create<Express.Application, Express.Router>(module, {\n ...settings,\n adapter: PlatformExpress\n });\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.bootstrap<Express.Application, Express.Router>(module, {\n ...settings,\n adapter: PlatformExpress\n });\n }\n\n useRouter(): this {\n const {logger, app} = this.platform;\n\n logger.debug(\"Mount app router\");\n app.getApp().use(rawBodyMiddleware);\n app.getApp().use(app.getRouter());\n\n return this;\n }\n\n async beforeLoadRoutes() {\n const {injector, app} = this.platform;\n // disable x-powered-by header\n injector.settings.get(\"env\") === Env.PROD && app.getApp().disable(\"x-powered-by\");\n\n await this.configureViewsEngine();\n }\n\n async afterLoadRoutes() {\n const {injector, app} = this.platform;\n // NOT FOUND\n app.use((req: any, res: any, next: any) => {\n !res.headersSent && injector.get<PlatformExceptions>(PlatformExceptions)?.resourceNotFound(req.$ctx);\n });\n\n // EXCEPTION FILTERS\n app.use((err: any, req: any, res: any, next: any) => {\n !res.headersSent && injector.get<PlatformExceptions>(PlatformExceptions)?.catch(err, req.$ctx);\n });\n }\n\n useContext(): this {\n const {logger, app, injector} = this.platform;\n\n logger.debug(\"Mount app context\");\n\n const invoke = createContext(injector);\n\n app.getApp().use(async (request: any, response: any, next: any) => {\n await invoke({request, response});\n\n return next();\n });\n\n return this;\n }\n\n private async configureViewsEngine() {\n const {settings, injector, app} = this.platform;\n try {\n const {exists, disabled} = settings.get(\"views\") || {};\n\n if (exists && !disabled) {\n const {PlatformViews} = await import(\"@tsed/platform-views\");\n const platformViews = injector.get<PlatformViews>(PlatformViews)!;\n const express = app.getApp();\n\n platformViews.getEngines().forEach(({extension, engine}) => {\n express.engine(extension, engine.render);\n });\n\n platformViews.viewEngine && express.set(\"view engine\", platformViews.viewEngine);\n platformViews.root && express.set(\"views\", platformViews.root);\n }\n } catch (error) {\n // istanbul ignore next\n injector.logger.warn({\n event: \"PLATFORM_VIEWS_ERROR\",\n message: \"Unable to configure the PlatformViews service on your environment.\",\n error\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../../src/components/PlatformExpress.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAGb,mBAAmB,EACnB,eAAe,EAEf,kBAAkB,EAClB,mBAAmB,EAInB,YAAY,EACb,MAAM,cAAc,CAAC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AE,MAAM,EAAC,EAAE,EAAE;oBACzD,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC3C,CAAC,CAAC,CAAC;gBAEH,aAAa,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;gBACjF,aAAa,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAChE;SACF;QAAC,OAAO,KAAK,EAAE;YACd,uBAAuB;YACvB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,sBAAsB;gBAC7B,OAAO,EAAE,oEAAoE;gBAC7E,KAAK;aACN,CAAC,CAAC;SACJ;IACH,CAAC;CACF","sourcesContent":["import {\n createContext,\n InjectorService,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformContext,\n PlatformExceptions,\n PlatformHandlerType,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformStaticsOptions,\n runInContext\n} from \"@tsed/common\";\nimport {Env, isFunction, nameOf, Type} from \"@tsed/core\";\nimport {PlatformHandlerMetadata, PlatformLayer} from \"@tsed/platform-router\";\nimport type {PlatformViews} from \"@tsed/platform-views\";\nimport {OptionsJson, OptionsText, OptionsUrlencoded} from \"body-parser\";\nimport Express from \"express\";\nimport type multer from \"multer\";\nimport {promisify} from \"util\";\nimport {PlatformExpressStaticsOptions} from \"../interfaces/PlatformExpressStaticsOptions\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\n\ndeclare module \"express\" {\n export interface Request {\n id: string;\n $ctx: PlatformContext;\n }\n}\n\ndeclare global {\n namespace TsED {\n // export interface Router extends Express.Router {}\n\n export interface Application extends Express.Application {}\n\n export interface StaticsOptions extends PlatformExpressStaticsOptions {}\n\n export interface Request extends Express.Request {\n id: string;\n $ctx: PlatformContext;\n }\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpress implements PlatformAdapter<Express.Application> {\n readonly providers = [];\n #multer: typeof multer;\n\n constructor(protected injector: InjectorService) {\n import(\"multer\").then(({default: multer}) => (this.#multer = multer));\n }\n\n /**\n * Create new serverless application. In this mode, the component scan are disabled.\n * @param module\n * @param settings\n */\n static create(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.create<Express.Application>(module, {\n ...settings,\n adapter: PlatformExpress\n });\n }\n\n /**\n * Bootstrap a server application\n * @param module\n * @param settings\n */\n static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}) {\n return PlatformBuilder.bootstrap<Express.Application>(module, {\n ...settings,\n adapter: PlatformExpress\n });\n }\n\n onInit() {\n const middlewares = this.injector.settings.get(\"middlewares\", []);\n\n this.injector.settings.set(\n \"middlewares\",\n middlewares.filter((middleware) => {\n const name = nameOf(middleware);\n if ([\"textParser\", \"jsonParser\", \"rawParser\", \"urlencodedParser\"].includes(name)) {\n this.injector.settings.set(`express.bodyParser.${name.replace(\"Parser\", \"\")}`, () => middleware);\n return false;\n }\n\n return true;\n })\n );\n }\n\n async beforeLoadRoutes() {\n const injector = this.injector;\n const app = this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\n\n // disable x-powered-by header\n injector.settings.get(\"env\") === Env.PROD && app.getApp().disable(\"x-powered-by\");\n\n await this.configureViewsEngine();\n }\n\n async afterLoadRoutes() {\n const app = this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\n const platformExceptions = this.injector.get<PlatformExceptions>(PlatformExceptions)!;\n\n // NOT FOUND\n app.use((req: any, res: any, next: any) => {\n const {$ctx} = req;\n !$ctx.isDone() && platformExceptions?.resourceNotFound(req.$ctx);\n });\n\n // EXCEPTION FILTERS\n app.use((err: any, req: any, res: any, next: any) => {\n const {$ctx} = req;\n !$ctx.isDone() && platformExceptions?.catch(err, $ctx);\n });\n }\n\n mapLayers(layers: PlatformLayer[]) {\n const app = this.getPlatformApplication();\n const rawApp: any = app.getApp();\n\n layers.forEach((layer) => {\n switch (layer.method) {\n case \"statics\":\n rawApp.use(layer.path, this.statics(layer.path as string, layer.opts as any));\n return;\n }\n\n rawApp[layer.method](...layer.getArgs());\n });\n }\n\n mapHandler(handler: Function, metadata: PlatformHandlerMetadata) {\n switch (metadata.type) {\n case PlatformHandlerType.RAW_FN:\n case PlatformHandlerType.RAW_ERR_FN:\n return handler;\n case PlatformHandlerType.ERR_MIDDLEWARE:\n return async (error: unknown, req: any, res: any, next: any) => {\n return runInContext(req.$ctx, () => {\n const {$ctx} = req;\n\n $ctx.next = next;\n $ctx.error = error;\n\n return handler($ctx);\n });\n };\n default:\n return (req: any, res: any, next: any) => {\n return runInContext(req.$ctx, () => {\n req.$ctx.next = next;\n handler(req.$ctx);\n });\n };\n }\n }\n\n useContext(): this {\n const app = this.getPlatformApplication();\n const invoke = createContext(this.injector);\n\n this.injector.logger.debug(\"Mount app context\");\n\n app.use(async (request: any, response: any, next: any) => {\n const $ctx = await invoke({request, response});\n await $ctx.start();\n\n $ctx.response.getRes().on(\"finish\", () => $ctx.finish());\n\n return runInContext($ctx, next);\n });\n\n return this;\n }\n\n app() {\n const app = this.injector.settings.get(\"express.app\") || Express();\n\n return {\n app,\n callback: () => app\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n const m = this.#multer(options);\n\n const makePromise = (multer: any, name: string) => {\n // istanbul ignore next\n if (!multer[name]) return;\n\n const fn = multer[name];\n\n multer[name] = function apply(...args: any[]) {\n const middleware = Reflect.apply(fn, this, args);\n\n return (req: any, res: any) => promisify(middleware)(req, res);\n };\n };\n\n makePromise(m, \"any\");\n makePromise(m, \"array\");\n makePromise(m, \"fields\");\n makePromise(m, \"none\");\n makePromise(m, \"single\");\n\n return m;\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions) {\n const {root, ...props} = options;\n\n return staticsMiddleware(root, props);\n }\n\n bodyParser(type: \"json\" | \"raw\" | \"text\" | \"urlencoded\", additionalOptions: any = {}): any {\n const opts = this.injector.settings.get(`express.bodyParser.${type}`);\n let parser: any = Express[type];\n let options: OptionsJson & OptionsText & OptionsUrlencoded = {};\n\n if (isFunction(opts)) {\n parser = opts;\n options = {};\n }\n\n switch (type) {\n case \"urlencoded\":\n options.extended = true;\n break;\n case \"raw\":\n options.type = () => true;\n break;\n }\n\n return parser({...options, ...additionalOptions});\n }\n\n private getPlatformApplication() {\n return this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\n }\n\n private async configureViewsEngine() {\n const injector = this.injector;\n const app = this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\n\n try {\n const {exists, disabled} = this.injector.settings.get(\"views\") || {};\n\n if (exists && !disabled) {\n const {PlatformViews} = await import(\"@tsed/platform-views\");\n const platformViews = injector.get<PlatformViews>(PlatformViews)!;\n const express = app.getApp();\n\n platformViews.getEngines().forEach(({extension, engine}) => {\n express.engine(extension, engine.render);\n });\n\n platformViews.viewEngine && express.set(\"view engine\", platformViews.viewEngine);\n platformViews.root && express.set(\"views\", platformViews.root);\n }\n } catch (error) {\n // istanbul ignore next\n injector.logger.warn({\n event: \"PLATFORM_VIEWS_ERROR\",\n message: \"Unable to configure the PlatformViews service on your environment.\",\n error\n });\n }\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { PlatformBuilder, PlatformTest } from "@tsed/common";
2
+ import { PlatformExpress } from "./components/PlatformExpress.js";
3
+ PlatformTest.adapter = PlatformExpress;
4
+ PlatformBuilder.adapter = PlatformExpress;
5
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,YAAY,CAAC,OAAO,GAAG,eAAsB,CAAC;AAC9C,eAAe,CAAC,OAAO,GAAG,eAAsB,CAAC","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\nimport {PlatformExpress} from \"./components/PlatformExpress\";\n\nPlatformTest.adapter = PlatformExpress as any;\nPlatformBuilder.adapter = PlatformExpress as any;\n"]}
package/lib/esm/index.js CHANGED
@@ -1,13 +1,10 @@
1
- import { PlatformBuilder, PlatformTest } from "@tsed/common";
2
- import { PlatformExpress } from "./components/PlatformExpress";
3
- PlatformTest.adapter = PlatformExpress;
4
- PlatformBuilder.adapter = PlatformExpress;
5
- // interfaces
6
- export * from "./interfaces";
7
- // decorators
8
- export * from "./decorators";
9
- // services
10
- export * from "./services";
11
- // components
12
- export * from "./components/PlatformExpress";
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./exports.js";
5
+ export * from "./components/PlatformExpress.js";
6
+ export * from "./interfaces/PlatformExpressSettings.js";
7
+ export * from "./interfaces/PlatformExpressStaticsOptions.js";
8
+ export * from "./interfaces/interfaces.js";
9
+ export * from "./middlewares/staticsMiddleware.js";
13
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,YAAY,CAAC,OAAO,GAAG,eAAsB,CAAC;AAC9C,eAAe,CAAC,OAAO,GAAG,eAAsB,CAAC;AAEjD,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,aAAa;AACb,cAAc,cAAc,CAAC;AAE7B,WAAW;AACX,cAAc,YAAY,CAAC;AAE3B,aAAa;AACb,cAAc,8BAA8B,CAAC","sourcesContent":["import {PlatformBuilder, PlatformTest} from \"@tsed/common\";\n\nimport {PlatformExpress} from \"./components/PlatformExpress\";\n\nPlatformTest.adapter = PlatformExpress as any;\nPlatformBuilder.adapter = PlatformExpress as any;\n\n// interfaces\nexport * from \"./interfaces\";\n\n// decorators\nexport * from \"./decorators\";\n\n// services\nexport * from \"./services\";\n\n// components\nexport * from \"./components/PlatformExpress\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./components/PlatformExpress\";\nexport * from \"./interfaces/PlatformExpressSettings\";\nexport * from \"./interfaces/PlatformExpressStaticsOptions\";\nexport * from \"./interfaces/interfaces\";\nexport * from \"./middlewares/staticsMiddleware\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformExpressSettings.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformExpressSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {RouterOptions} from \"express\";\n\nexport interface PlatformExpressSettings {\n /**\n * Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).\n */\n router?: RouterOptions;\n\n app?: Express.Application;\n}\n"]}
1
+ {"version":3,"file":"PlatformExpressSettings.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformExpressSettings.ts"],"names":[],"mappings":"","sourcesContent":["import type {RouterOptions} from \"express\";\nimport type {OptionsJson, OptionsText, Options, OptionsUrlencoded} from \"body-parser\";\nimport type {NextHandleFunction} from \"connect\";\n\nexport interface PlatformExpressSettings {\n /**\n * Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).\n */\n router?: RouterOptions;\n /**\n * Express application\n */\n app?: Express.Application;\n\n /**\n * body parser configuration\n */\n bodyParser?: {\n json?: ((opts?: OptionsJson) => NextHandleFunction) | OptionsJson;\n text?: ((opts?: OptionsText) => NextHandleFunction) | OptionsText;\n raw?: ((opts?: Options) => NextHandleFunction) | Options;\n urlencoded?: ((opts?: OptionsUrlencoded) => NextHandleFunction) | OptionsUrlencoded;\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {NextFunction as ENext, Request as EReq, Response as ERes} from \"express\";\nimport {PlatformExpressSettings} from \"./PlatformExpressSettings\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Express platform application.\n */\n express: PlatformExpressSettings;\n }\n\n export interface NextFunction extends ENext {}\n\n export interface Response extends ERes {}\n export interface Request extends EReq {}\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -1,42 +1,60 @@
1
- import Express from "express";
2
- import { PlatformAdapter, PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
1
+ import { InjectorService, PlatformAdapter, PlatformBuilder, PlatformContext, PlatformMulter, PlatformMulterSettings, PlatformStaticsOptions } from "@tsed/common";
3
2
  import { Type } from "@tsed/core";
4
- import { PlatformExpressHandler, PlatformExpressRequest, PlatformExpressResponse, PlatformExpressRouter } from "../services";
3
+ import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
4
+ import Express from "express";
5
+ import { PlatformExpressStaticsOptions } from "../interfaces/PlatformExpressStaticsOptions";
6
+ declare module "express" {
7
+ interface Request {
8
+ id: string;
9
+ $ctx: PlatformContext;
10
+ }
11
+ }
12
+ declare global {
13
+ namespace TsED {
14
+ interface Application extends Express.Application {
15
+ }
16
+ interface StaticsOptions extends PlatformExpressStaticsOptions {
17
+ }
18
+ interface Request extends Express.Request {
19
+ id: string;
20
+ $ctx: PlatformContext;
21
+ }
22
+ }
23
+ }
5
24
  /**
6
25
  * @platform
7
26
  * @express
8
27
  */
9
- export declare class PlatformExpress implements PlatformAdapter<Express.Application, Express.Router> {
10
- private platform;
11
- readonly providers: ({
12
- provide: typeof PlatformRouter;
13
- useClass: typeof PlatformExpressRouter;
14
- } | {
15
- provide: typeof PlatformHandler;
16
- useClass: typeof PlatformExpressHandler;
17
- } | {
18
- provide: typeof PlatformResponse;
19
- useClass: typeof PlatformExpressResponse;
20
- } | {
21
- provide: typeof PlatformRequest;
22
- useClass: typeof PlatformExpressRequest;
23
- })[];
24
- constructor(platform: PlatformBuilder<Express.Application, Express.Router>);
28
+ export declare class PlatformExpress implements PlatformAdapter<Express.Application> {
29
+ #private;
30
+ protected injector: InjectorService;
31
+ readonly providers: never[];
32
+ constructor(injector: InjectorService);
25
33
  /**
26
34
  * Create new serverless application. In this mode, the component scan are disabled.
27
35
  * @param module
28
36
  * @param settings
29
37
  */
30
- static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Express.Application, Express.Router>;
38
+ static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Express.Application>;
31
39
  /**
32
40
  * Bootstrap a server application
33
41
  * @param module
34
42
  * @param settings
35
43
  */
36
- static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Express.Application, Express.Router>>;
37
- useRouter(): this;
44
+ static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Express.Application>>;
45
+ onInit(): void;
38
46
  beforeLoadRoutes(): Promise<void>;
39
47
  afterLoadRoutes(): Promise<void>;
48
+ mapLayers(layers: PlatformLayer[]): void;
49
+ mapHandler(handler: Function, metadata: PlatformHandlerMetadata): Function;
40
50
  useContext(): this;
51
+ app(): {
52
+ app: any;
53
+ callback: () => any;
54
+ };
55
+ multipart(options: PlatformMulterSettings): PlatformMulter;
56
+ statics(endpoint: string, options: PlatformStaticsOptions): (request: any, response: any, next: any) => void;
57
+ bodyParser(type: "json" | "raw" | "text" | "urlencoded", additionalOptions?: any): any;
58
+ private getPlatformApplication;
41
59
  private configureViewsEngine;
42
60
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,9 @@
1
- export * from "./interfaces";
2
- export * from "./decorators";
3
- export * from "./services";
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./exports";
4
5
  export * from "./components/PlatformExpress";
6
+ export * from "./interfaces/PlatformExpressSettings";
7
+ export * from "./interfaces/PlatformExpressStaticsOptions";
8
+ export * from "./interfaces/interfaces";
9
+ export * from "./middlewares/staticsMiddleware";
@@ -1,9 +1,23 @@
1
1
  /// <reference types="express-serve-static-core" />
2
- import { RouterOptions } from "express";
2
+ import type { RouterOptions } from "express";
3
+ import type { OptionsJson, OptionsText, Options, OptionsUrlencoded } from "body-parser";
4
+ import type { NextHandleFunction } from "connect";
3
5
  export interface PlatformExpressSettings {
4
6
  /**
5
7
  * Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).
6
8
  */
7
9
  router?: RouterOptions;
10
+ /**
11
+ * Express application
12
+ */
8
13
  app?: Express.Application;
14
+ /**
15
+ * body parser configuration
16
+ */
17
+ bodyParser?: {
18
+ json?: ((opts?: OptionsJson) => NextHandleFunction) | OptionsJson;
19
+ text?: ((opts?: OptionsText) => NextHandleFunction) | OptionsText;
20
+ raw?: ((opts?: Options) => NextHandleFunction) | Options;
21
+ urlencoded?: ((opts?: OptionsUrlencoded) => NextHandleFunction) | OptionsUrlencoded;
22
+ };
9
23
  }
@@ -1,7 +1,5 @@
1
- import Express from "express";
1
+ import { NextFunction as ENext, Request as EReq, Response as ERes } from "express";
2
2
  import { PlatformExpressSettings } from "./PlatformExpressSettings";
3
- export * from "./PlatformExpressSettings";
4
- export * from "./PlatformExpressStaticsOptions";
5
3
  declare global {
6
4
  namespace TsED {
7
5
  interface Configuration {
@@ -10,7 +8,11 @@ declare global {
10
8
  */
11
9
  express: PlatformExpressSettings;
12
10
  }
13
- interface NextFunction extends Express.NextFunction {
11
+ interface NextFunction extends ENext {
12
+ }
13
+ interface Response extends ERes {
14
+ }
15
+ interface Request extends EReq {
14
16
  }
15
17
  }
16
18
  }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@tsed/platform-express",
3
- "version": "7.0.0-beta.2",
3
+ "version": "7.0.0-beta.20",
4
4
  "description": "A TypeScript Framework on top of Express",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/cjs/index.js",
8
+ "module": "./lib/esm/index.js",
8
9
  "typings": "./lib/types/index.d.ts",
9
10
  "exports": {
10
11
  "types": "./lib/types/index.d.ts",
@@ -13,11 +14,13 @@
13
14
  "default": "./lib/esm/index.js"
14
15
  },
15
16
  "scripts": {
16
- "build": "yarn run build:esm && yarn run build:cjs",
17
+ "build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
17
18
  "build:cjs": "tsc --build tsconfig.compile.json",
18
19
  "build:esm": "tsc --build tsconfig.compile.esm.json",
20
+ "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
19
21
  "start": "ts-node -r tsconfig-paths/register test/app/index.ts",
20
- "start:emulate": "ts-node -r tsconfig-paths/register test/app/emulate.ts"
22
+ "start:emulate": "ts-node -r tsconfig-paths/register test/app/emulate.ts",
23
+ "test": "cross-env NODE_ENV=test yarn jest --max-workers=2 --testTimeout 10000"
21
24
  },
22
25
  "keywords": [
23
26
  "Express",
@@ -46,41 +49,76 @@
46
49
  "bugs": {
47
50
  "url": "https://github.com/tsedio/tsed/issues"
48
51
  },
49
- "homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/platform/platform-express",
52
+ "homepage": "https://github.com/tsedio/tsed/tree/beta/packages/platform/platform-express",
50
53
  "repository": "https://github.com/tsedio/tsed",
51
54
  "dependencies": {
52
- "express": "^4.17.1",
53
- "multer": "^1.4.2",
54
- "tslib": "2.2.0"
55
+ "express": "^4.18.1",
56
+ "multer": "^1.4.5-lts.1",
57
+ "tslib": "2.4.0"
55
58
  },
56
59
  "devDependencies": {
57
- "@tsed/common": "7.0.0-beta.2",
58
- "@tsed/core": "7.0.0-beta.2",
59
- "@tsed/di": "7.0.0-beta.2",
60
- "@tsed/platform-test-utils": "7.0.0-beta.2",
61
- "@types/body-parser": "1.19.0",
62
- "@types/compression": "1.7.0",
60
+ "@tsed/common": "7.0.0-beta.20",
61
+ "@tsed/core": "7.0.0-beta.20",
62
+ "@tsed/di": "7.0.0-beta.20",
63
+ "@tsed/platform-test-utils": "7.0.0-beta.20",
64
+ "@tsed/platform-views": "7.0.0-beta.20",
65
+ "@types/body-parser": "1.19.2",
66
+ "@types/compression": "1.7.2",
63
67
  "@types/cookie-parser": "1.4.2",
64
68
  "@types/express": "^4.17.7",
65
- "@types/express-session": "1.17.0",
66
- "@types/method-override": "0.0.31",
69
+ "@types/express-session": "1.17.4",
70
+ "@types/method-override": "0.0.32",
67
71
  "@types/multer": "^1.4.3",
68
- "body-parser": "1.19.0",
72
+ "body-parser": "1.19.2",
69
73
  "compression": "1.7.4",
70
- "cookie-parser": "1.4.5",
74
+ "cookie-parser": "1.4.6",
71
75
  "cors": "2.8.5",
72
- "express-session": "1.17.1",
76
+ "express-session": "1.17.2",
73
77
  "method-override": "3.0.0"
74
78
  },
75
79
  "peerDependencies": {
76
- "@tsed/common": "^7.0.0-beta.2",
77
- "@tsed/core": "^7.0.0-beta.2",
78
- "@tsed/di": "^7.0.0-beta.2",
79
- "@tsed/json-mapper": "^7.0.0-beta.2",
80
- "@tsed/logger": ">=6.0.0",
81
- "@tsed/openspec": "^7.0.0-beta.2",
82
- "@tsed/schema": "^7.0.0-beta.2",
80
+ "@tsed/common": "^7.0.0-beta.20",
81
+ "@tsed/core": "^7.0.0-beta.20",
82
+ "@tsed/di": "^7.0.0-beta.20",
83
+ "@tsed/json-mapper": "^7.0.0-beta.20",
84
+ "@tsed/logger": ">=6.2.0",
85
+ "@tsed/openspec": "^7.0.0-beta.20",
86
+ "@tsed/platform-views": "^7.0.0-beta.20",
87
+ "@tsed/schema": "^7.0.0-beta.20",
83
88
  "@types/multer": "^1.4.5",
84
- "body-parser": "1.19.0"
89
+ "body-parser": "^1.19.0",
90
+ "multer": "^1.4.5-lts.1"
91
+ },
92
+ "peerDependenciesMeta": {
93
+ "@tsed/common": {
94
+ "optional": false
95
+ },
96
+ "@tsed/core": {
97
+ "optional": false
98
+ },
99
+ "@tsed/di": {
100
+ "optional": false
101
+ },
102
+ "@tsed/json-mapper": {
103
+ "optional": false
104
+ },
105
+ "@tsed/openspec": {
106
+ "optional": false
107
+ },
108
+ "@tsed/platform-views": {
109
+ "optional": true
110
+ },
111
+ "@tsed/schema": {
112
+ "optional": false
113
+ },
114
+ "@tsed/logger": {
115
+ "optional": false
116
+ },
117
+ "multer": {
118
+ "optional": false
119
+ }
120
+ },
121
+ "publishConfig": {
122
+ "tag": "beta"
85
123
  }
86
124
  }
package/readme.md CHANGED
@@ -11,7 +11,8 @@
11
11
  [![npm version](https://badge.fury.io/js/%40tsed%2Fcommon.svg)](https://badge.fury.io/js/%40tsed%2Fcommon)
12
12
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
13
13
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
14
- [![backers](https://opencollective.com/tsed/tiers/badge.svg)](https://opencollective.com/tsed)
14
+ [![github](https://img.shields.io/static/v1?label=Github%20sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/romakita)
15
+ [![opencollective](https://img.shields.io/static/v1?label=OpenCollective%20sponsor&message=%E2%9D%A4&logo=OpenCollective&color=%23fe8e86)](https://opencollective.com/tsed)
15
16
 
16
17
  </div>
17
18
 
@@ -44,14 +45,12 @@ Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
44
45
 
45
46
  <a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
46
47
 
47
-
48
48
  ## Backers
49
49
 
50
50
  Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
51
51
 
52
52
  <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
53
53
 
54
-
55
54
  ## Sponsors
56
55
 
57
56
  Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
@@ -60,7 +59,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
60
59
 
61
60
  The MIT License (MIT)
62
61
 
63
- Copyright (c) 2016 - 2018 Romain Lenzotti
62
+ Copyright (c) 2016 - 2022 Romain Lenzotti
64
63
 
65
64
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66
65
 
@@ -8,16 +8,5 @@
8
8
  "declaration": true,
9
9
  "declarationDir": "./lib/types"
10
10
  },
11
- "exclude": [
12
- "node_modules",
13
- "test",
14
- "lib",
15
- "benchmark",
16
- "coverage",
17
- "spec",
18
- "**/*.benchmark.ts",
19
- "**/*.spec.ts",
20
- "keys",
21
- "jest.config.js"
22
- ]
11
+ "exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
23
12
  }
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CaseSensitive = void 0;
4
- const routerSettings_1 = require("./routerSettings");
5
- /**
6
- * Specify the behavior of the router controller.
7
- *
8
- * ```typescript
9
- * @Controller("/")
10
- * @CaseSensitive(true)
11
- * class MyCtrl {
12
- *
13
- * }
14
- * ```
15
- *
16
- * Property | Description | Default
17
- * ---|---|---
18
- * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
19
- * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
20
- * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
21
- *
22
- * @param caseSensitive
23
- * @returns {Function}
24
- * @decorator
25
- * @express
26
- */
27
- function CaseSensitive(caseSensitive) {
28
- return (0, routerSettings_1.RouterSettings)({ caseSensitive });
29
- }
30
- exports.CaseSensitive = CaseSensitive;
31
- //# sourceMappingURL=caseSensitive.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"caseSensitive.js","sourceRoot":"","sources":["../../../src/decorators/caseSensitive.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,aAAa,CAAC,aAAsB;IAClD,OAAO,IAAA,+BAAc,EAAC,EAAC,aAAa,EAAC,CAAC,CAAC;AACzC,CAAC;AAFD,sCAEC","sourcesContent":["import {RouterSettings} from \"./routerSettings\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @CaseSensitive(true)\n * class MyCtrl {\n *\n * }\n * ```\n *\n * Property | Description | Default\n * ---|---|---\n * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.\n * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false\n * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.\n *\n * @param caseSensitive\n * @returns {Function}\n * @decorator\n * @express\n */\nexport function CaseSensitive(caseSensitive: boolean) {\n return RouterSettings({caseSensitive});\n}\n"]}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./routerSettings"), exports);
5
- (0, tslib_1.__exportStar)(require("./caseSensitive"), exports);
6
- (0, tslib_1.__exportStar)(require("./mergeParams"), exports);
7
- (0, tslib_1.__exportStar)(require("./strict"), exports);
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,gEAAiC;AACjC,+DAAgC;AAChC,6DAA8B;AAC9B,wDAAyB","sourcesContent":["export * from \"./routerSettings\";\nexport * from \"./caseSensitive\";\nexport * from \"./mergeParams\";\nexport * from \"./strict\";\n"]}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MergeParams = void 0;
4
- const routerSettings_1 = require("./routerSettings");
5
- /**
6
- * Specify the behavior of the router controller.
7
- *
8
- * ```typescript
9
- * @Controller("/")
10
- * @MergeParams(true)
11
- * class MyCtrl {
12
- *
13
- * }
14
- * ```
15
- *
16
- * Property | Description | Default
17
- * ---|---|---
18
- * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
19
- * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
20
- * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
21
- *
22
- * @param mergeParams
23
- * @returns {Function}
24
- * @decorator
25
- * @express
26
- */
27
- function MergeParams(mergeParams = true) {
28
- return (0, routerSettings_1.RouterSettings)({ mergeParams });
29
- }
30
- exports.MergeParams = MergeParams;
31
- //# sourceMappingURL=mergeParams.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeParams.js","sourceRoot":"","sources":["../../../src/decorators/mergeParams.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,WAAW,CAAC,cAAuB,IAAI;IACrD,OAAO,IAAA,+BAAc,EAAC,EAAC,WAAW,EAAC,CAAC,CAAC;AACvC,CAAC;AAFD,kCAEC","sourcesContent":["import {RouterSettings} from \"./routerSettings\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @MergeParams(true)\n * class MyCtrl {\n *\n * }\n * ```\n *\n * Property | Description | Default\n * ---|---|---\n * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.\n * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false\n * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.\n *\n * @param mergeParams\n * @returns {Function}\n * @decorator\n * @express\n */\nexport function MergeParams(mergeParams: boolean = true) {\n return RouterSettings({mergeParams});\n}\n"]}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RouterSettings = void 0;
4
- const common_1 = require("@tsed/common");
5
- const core_1 = require("@tsed/core");
6
- /**
7
- * Specify the behavior of the router controller.
8
- *
9
- * ```typescript
10
- * @Controller("/")
11
- * @RouterSettings({mergeParams: true})
12
- * class MyCtrl {
13
- *
14
- * }
15
- * ```
16
- *
17
- * Property | Description | Default
18
- * ---|---|---
19
- * caseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
20
- * mergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
21
- * strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
22
- *
23
- * @returns {(target:any)=>void}
24
- * @decorator
25
- * @param routerOptions
26
- * @express
27
- */
28
- function RouterSettings(routerOptions) {
29
- return (0, core_1.StoreMerge)(common_1.ROUTER_OPTIONS, routerOptions);
30
- }
31
- exports.RouterSettings = RouterSettings;
32
- //# sourceMappingURL=routerSettings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routerSettings.js","sourceRoot":"","sources":["../../../src/decorators/routerSettings.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAC5C,qCAAsC;AAGtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,cAAc,CAAC,aAA4B;IACzD,OAAO,IAAA,iBAAU,EAAC,uBAAc,EAAE,aAAa,CAAC,CAAC;AACnD,CAAC;AAFD,wCAEC","sourcesContent":["import {ROUTER_OPTIONS} from \"@tsed/common\";\nimport {StoreMerge} from \"@tsed/core\";\nimport {RouterOptions} from \"express\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @RouterSettings({mergeParams: true})\n * class MyCtrl {\n *\n * }\n * ```\n *\n * Property | Description | Default\n * ---|---|---\n * caseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.\n * mergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false\n * strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.\n *\n * @returns {(target:any)=>void}\n * @decorator\n * @param routerOptions\n * @express\n */\nexport function RouterSettings(routerOptions: RouterOptions): Function {\n return StoreMerge(ROUTER_OPTIONS, routerOptions);\n}\n"]}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Strict = void 0;
4
- const routerSettings_1 = require("./routerSettings");
5
- /**
6
- * Specify the behavior of the router controller.
7
- *
8
- * ```typescript
9
- * @Controller("/")
10
- * @Strict(true)
11
- * class MyCtrl {
12
- *
13
- * }
14
- * ```
15
- *
16
- * Property | Description | Default
17
- * ---|---|---
18
- * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
19
- * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
20
- * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
21
- *
22
- * @param strict
23
- * @returns {Function}
24
- * @decorator
25
- * @express
26
- */
27
- function Strict(strict) {
28
- return (0, routerSettings_1.RouterSettings)({ strict });
29
- }
30
- exports.Strict = Strict;
31
- //# sourceMappingURL=strict.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strict.js","sourceRoot":"","sources":["../../../src/decorators/strict.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,MAAM,CAAC,MAAe;IACpC,OAAO,IAAA,+BAAc,EAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC","sourcesContent":["import {RouterSettings} from \"./routerSettings\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @Strict(true)\n * class MyCtrl {\n *\n * }\n * ```\n *\n * Property | Description | Default\n * ---|---|---\n * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.\n * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false\n * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.\n *\n * @param strict\n * @returns {Function}\n * @decorator\n * @express\n */\nexport function Strict(strict: boolean) {\n return RouterSettings({strict});\n}\n"]}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./PlatformExpressSettings"), exports);
5
- (0, tslib_1.__exportStar)(require("./PlatformExpressStaticsOptions"), exports);
6
- //# sourceMappingURL=index.js.map