@tsed/platform-express 6.84.1 → 6.85.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.
@@ -20,6 +20,17 @@ export declare class PlatformExpress extends PlatformBuilder<Express.Application
20
20
  provide: typeof PlatformRequest;
21
21
  useClass: typeof PlatformExpressRequest;
22
22
  })[];
23
+ /**
24
+ * Create new serverless application. In this mode, the component scan are disabled.
25
+ * @param module
26
+ * @param settings
27
+ */
28
+ static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformExpress;
29
+ /**
30
+ * Bootstrap a server application
31
+ * @param module
32
+ * @param settings
33
+ */
23
34
  static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformExpress>;
24
35
  protected useRouter(): this;
25
36
  protected useContext(): this;
@@ -10,17 +10,35 @@ const services_1 = require("../services");
10
10
  * @express
11
11
  */
12
12
  class PlatformExpress extends common_1.PlatformBuilder {
13
+ /**
14
+ * Create new serverless application. In this mode, the component scan are disabled.
15
+ * @param module
16
+ * @param settings
17
+ */
18
+ static create(module, settings = {}) {
19
+ return this.build(PlatformExpress, module, {
20
+ httpsPort: false,
21
+ httpPort: false,
22
+ ...settings,
23
+ disableComponentsScan: true
24
+ });
25
+ }
26
+ /**
27
+ * Bootstrap a server application
28
+ * @param module
29
+ * @param settings
30
+ */
13
31
  static async bootstrap(module, settings = {}) {
14
- return this.build(PlatformExpress).bootstrap(module, settings);
32
+ return this.build(PlatformExpress, module, settings).bootstrap();
15
33
  }
16
34
  useRouter() {
17
- this.logger.info("Mount app router");
35
+ this.logger.debug("Mount app router");
18
36
  this.app.getApp().use(rawBodyMiddleware_1.rawBodyMiddleware);
19
37
  this.app.getApp().use(this.app.getRouter());
20
38
  return this;
21
39
  }
22
40
  useContext() {
23
- this.logger.info("Mount app context");
41
+ this.logger.debug("Mount app context");
24
42
  const invoke = common_1.createContext(this.injector);
25
43
  this.app.getApp().use(async (request, response, next) => {
26
44
  await invoke({ request, response });
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../src/components/PlatformExpress.ts"],"names":[],"mappings":";;;AAAA,yCAUsB;AACtB,qCAAqC;AAErC,wEAAmE;AACnE,0CAMqB;AAErB;;;GAGG;AACH,MAAa,eAAgB,SAAQ,wBAAoD;IAwBvF,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAiB,EAAE,WAAwC,EAAE;QAClF,OAAO,IAAI,CAAC,KAAK,CAAkB,eAAe,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClF,CAAC;IAES,SAAS;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACrC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,qCAAiB,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;QAE5C,OAAO,IAAI,CAAC;IACd,CAAC;IAES,UAAU;QAClB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAEtC,MAAM,MAAM,GAAG,sBAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE5C,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,OAAY,EAAE,QAAa,EAAE,IAAS,EAAE,EAAE;YACrE,MAAM,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAC,CAAC,CAAC;YAElC,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAES,KAAK,CAAC,UAAU;QACxB,8BAA8B;QAC9B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,UAAG,CAAC,IA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AAC,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3E,CAAC;;AA9EH,0CA+EC;AA9EQ,yBAAS,GAAG;IACjB;QACE,OAAO,EAAE,4BAAmB;QAC5B,QAAQ,EAAE,qCAA0B;KACrC;IACD;QACE,OAAO,EAAE,uBAAc;QACvB,QAAQ,EAAE,gCAAqB;KAChC;IACD;QACE,OAAO,EAAE,wBAAe;QACxB,QAAQ,EAAE,iCAAsB;KACjC;IACD;QACE,OAAO,EAAE,yBAAgB;QACzB,QAAQ,EAAE,kCAAuB;KAClC;IACD;QACE,OAAO,EAAE,wBAAe;QACxB,QAAQ,EAAE,iCAAsB;KACjC;CACF,CAAC","sourcesContent":["import {\n createContext,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter,\n PlatformViews\n} from \"@tsed/common\";\nimport {Env, Type} from \"@tsed/core\";\nimport Express from \"express\";\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 extends PlatformBuilder<Express.Application, Express.Router> {\n static 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 static async bootstrap(module: Type<any>, settings: Partial<TsED.Configuration> = {}): Promise<PlatformExpress> {\n return this.build<PlatformExpress>(PlatformExpress).bootstrap(module, settings);\n }\n\n protected useRouter(): this {\n this.logger.info(\"Mount app router\");\n this.app.getApp().use(rawBodyMiddleware);\n this.app.getApp().use(this.app.getRouter());\n\n return this;\n }\n\n protected useContext(): this {\n this.logger.info(\"Mount app context\");\n\n const invoke = createContext(this.injector);\n\n this.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 protected async loadRoutes(): Promise<void> {\n // disable x-powered-by header\n this.injector.settings.get(\"env\") === Env.PROD && this.app.getApp().disable(\"x-powered-by\");\n\n this.configureViewsEngine();\n\n await super.loadRoutes();\n\n // NOT FOUND\n this.app.use((req: any, res: any, next: any) => {\n !res.headersSent && this.injector.get<PlatformExceptions>(PlatformExceptions)?.resourceNotFound(req.$ctx);\n });\n\n // EXCEPTION FILTERS\n this.app.use((err: any, req: any, res: any, next: any) => {\n !res.headersSent && this.injector.get<PlatformExceptions>(PlatformExceptions)?.catch(err, req.$ctx);\n });\n }\n\n private configureViewsEngine() {\n const platformViews = this.injector.get<PlatformViews>(PlatformViews)!;\n\n platformViews.getEngines().forEach(({extension, engine}) => {\n this.app.getApp().engine(extension, engine.render);\n });\n\n platformViews.viewEngine && this.app.getApp().set(\"view engine\", platformViews.viewEngine);\n platformViews.root && this.app.getApp().set(\"views\", platformViews.root);\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../src/components/PlatformExpress.ts"],"names":[],"mappings":";;;AAAA,yCAUsB;AACtB,qCAAqC;AAErC,wEAAmE;AACnE,0CAMqB;AAErB;;;GAGG;AACH,MAAa,eAAgB,SAAQ,wBAAoD;IAwBvF;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,MAAiB,EAAE,WAAwC,EAAE;QACzE,OAAO,IAAI,CAAC,KAAK,CAAkB,eAAe,EAAE,MAAM,EAAE;YAC1D,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,KAAK;YACf,GAAG,QAAQ;YACX,qBAAqB,EAAE,IAAI;SAC5B,CAAC,CAAC;IACL,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mB;QAC5B,QAAQ,EAAE,qCAA0B;KACrC;IACD;QACE,OAAO,EAAE,uBAAc;QACvB,QAAQ,EAAE,gCAAqB;KAChC;IACD;QACE,OAAO,EAAE,wBAAe;QACxB,QAAQ,EAAE,iCAAsB;KACjC;IACD;QACE,OAAO,EAAE,yBAAgB;QACzB,QAAQ,EAAE,kCAAuB;KAClC;IACD;QACE,OAAO,EAAE,wBAAe;QACxB,QAAQ,EAAE,iCAAsB;KACjC;CACF,CAAC","sourcesContent":["import {\n createContext,\n PlatformApplication,\n PlatformBuilder,\n PlatformExceptions,\n PlatformHandler,\n PlatformRequest,\n PlatformResponse,\n PlatformRouter,\n PlatformViews\n} from \"@tsed/common\";\nimport {Env, Type} from \"@tsed/core\";\nimport Express from \"express\";\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 extends PlatformBuilder<Express.Application, Express.Router> {\n static 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 /**\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 this.build<PlatformExpress>(PlatformExpress, module, {\n httpsPort: false,\n httpPort: false,\n ...settings,\n disableComponentsScan: true\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> = {}): Promise<PlatformExpress> {\n return this.build<PlatformExpress>(PlatformExpress, module, settings).bootstrap();\n }\n\n protected useRouter(): this {\n this.logger.debug(\"Mount app router\");\n this.app.getApp().use(rawBodyMiddleware);\n this.app.getApp().use(this.app.getRouter());\n\n return this;\n }\n\n protected useContext(): this {\n this.logger.debug(\"Mount app context\");\n\n const invoke = createContext(this.injector);\n\n this.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 protected async loadRoutes(): Promise<void> {\n // disable x-powered-by header\n this.injector.settings.get(\"env\") === Env.PROD && this.app.getApp().disable(\"x-powered-by\");\n\n this.configureViewsEngine();\n\n await super.loadRoutes();\n\n // NOT FOUND\n this.app.use((req: any, res: any, next: any) => {\n !res.headersSent && this.injector.get<PlatformExceptions>(PlatformExceptions)?.resourceNotFound(req.$ctx);\n });\n\n // EXCEPTION FILTERS\n this.app.use((err: any, req: any, res: any, next: any) => {\n !res.headersSent && this.injector.get<PlatformExceptions>(PlatformExceptions)?.catch(err, req.$ctx);\n });\n }\n\n private configureViewsEngine() {\n const platformViews = this.injector.get<PlatformViews>(PlatformViews)!;\n\n platformViews.getEngines().forEach(({extension, engine}) => {\n this.app.getApp().engine(extension, engine.render);\n });\n\n platformViews.viewEngine && this.app.getApp().set(\"view engine\", platformViews.viewEngine);\n platformViews.root && this.app.getApp().set(\"views\", platformViews.root);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/platform-express",
3
- "version": "6.84.1",
3
+ "version": "6.85.0",
4
4
  "description": "A TypeScript Framework on top of Express",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/index.js",
@@ -37,7 +37,8 @@
37
37
  "repository": "https://github.com/tsedio/tsed",
38
38
  "scripts": {
39
39
  "build": "tsc --build tsconfig.compile.json",
40
- "start": "ts-node -r tsconfig-paths/register test/app/index.ts"
40
+ "start": "ts-node -r tsconfig-paths/register test/app/index.ts",
41
+ "start:emulate": "ts-node -r tsconfig-paths/register test/app/emulate.ts"
41
42
  },
42
43
  "dependencies": {
43
44
  "express": "^4.17.1",
@@ -45,10 +46,10 @@
45
46
  "tslib": "2.2.0"
46
47
  },
47
48
  "devDependencies": {
48
- "@tsed/common": "6.84.1",
49
- "@tsed/core": "6.84.1",
50
- "@tsed/di": "6.84.1",
51
- "@tsed/platform-test-utils": "6.84.1",
49
+ "@tsed/common": "6.85.0",
50
+ "@tsed/core": "6.85.0",
51
+ "@tsed/di": "6.85.0",
52
+ "@tsed/platform-test-utils": "6.85.0",
52
53
  "@types/body-parser": "1.19.0",
53
54
  "@types/compression": "1.7.0",
54
55
  "@types/cookie-parser": "1.4.2",
@@ -64,13 +65,13 @@
64
65
  "method-override": "3.0.0"
65
66
  },
66
67
  "peerDependencies": {
67
- "@tsed/common": "^6.84.1",
68
- "@tsed/core": "^6.84.1",
69
- "@tsed/di": "^6.84.1",
70
- "@tsed/json-mapper": "^6.84.1",
68
+ "@tsed/common": "^6.85.0",
69
+ "@tsed/core": "^6.85.0",
70
+ "@tsed/di": "^6.85.0",
71
+ "@tsed/json-mapper": "^6.85.0",
71
72
  "@tsed/logger": ">=6.0.0",
72
- "@tsed/openspec": "^6.84.1",
73
- "@tsed/schema": "^6.84.1",
73
+ "@tsed/openspec": "^6.85.0",
74
+ "@tsed/schema": "^6.85.0",
74
75
  "@types/multer": "^1.4.5",
75
76
  "body-parser": "1.19.0"
76
77
  }