@tsed/platform-express 7.0.0-beta.13 → 7.0.0-beta.14
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.
- package/lib/cjs/components/PlatformExpress.js +57 -54
- package/lib/cjs/components/PlatformExpress.js.map +1 -1
- package/lib/cjs/index.js +0 -7
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/components/PlatformExpress.js +58 -55
- package/lib/esm/components/PlatformExpress.js.map +1 -1
- package/lib/esm/index.js +0 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/types/components/PlatformExpress.d.ts +11 -26
- package/lib/types/index.d.ts +0 -7
- package/package.json +13 -13
- package/lib/cjs/decorators/caseSensitive.js +0 -31
- package/lib/cjs/decorators/caseSensitive.js.map +0 -1
- package/lib/cjs/decorators/mergeParams.js +0 -31
- package/lib/cjs/decorators/mergeParams.js.map +0 -1
- package/lib/cjs/decorators/routerSettings.js +0 -32
- package/lib/cjs/decorators/routerSettings.js.map +0 -1
- package/lib/cjs/decorators/strict.js +0 -31
- package/lib/cjs/decorators/strict.js.map +0 -1
- package/lib/cjs/services/PlatformExpressHandler.js +0 -31
- package/lib/cjs/services/PlatformExpressHandler.js.map +0 -1
- package/lib/cjs/services/PlatformExpressRequest.js +0 -12
- package/lib/cjs/services/PlatformExpressRequest.js.map +0 -1
- package/lib/cjs/services/PlatformExpressResponse.js +0 -12
- package/lib/cjs/services/PlatformExpressResponse.js.map +0 -1
- package/lib/esm/decorators/caseSensitive.js +0 -27
- package/lib/esm/decorators/caseSensitive.js.map +0 -1
- package/lib/esm/decorators/mergeParams.js +0 -27
- package/lib/esm/decorators/mergeParams.js.map +0 -1
- package/lib/esm/decorators/routerSettings.js +0 -28
- package/lib/esm/decorators/routerSettings.js.map +0 -1
- package/lib/esm/decorators/strict.js +0 -27
- package/lib/esm/decorators/strict.js.map +0 -1
- package/lib/esm/services/PlatformExpressHandler.js +0 -27
- package/lib/esm/services/PlatformExpressHandler.js.map +0 -1
- package/lib/esm/services/PlatformExpressRequest.js +0 -8
- package/lib/esm/services/PlatformExpressRequest.js.map +0 -1
- package/lib/esm/services/PlatformExpressResponse.js +0 -8
- package/lib/esm/services/PlatformExpressResponse.js.map +0 -1
- package/lib/types/decorators/caseSensitive.d.ts +0 -23
- package/lib/types/decorators/mergeParams.d.ts +0 -23
- package/lib/types/decorators/routerSettings.d.ts +0 -24
- package/lib/types/decorators/strict.d.ts +0 -23
- package/lib/types/services/PlatformExpressHandler.d.ts +0 -9
- package/lib/types/services/PlatformExpressRequest.d.ts +0 -8
- package/lib/types/services/PlatformExpressResponse.d.ts +0 -14
|
@@ -4,32 +4,17 @@ exports.PlatformExpress = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@tsed/common");
|
|
6
6
|
const core_1 = require("@tsed/core");
|
|
7
|
+
const platform_router_1 = require("@tsed/platform-router");
|
|
7
8
|
const express_1 = tslib_1.__importDefault(require("express"));
|
|
8
9
|
const util_1 = require("util");
|
|
9
10
|
const staticsMiddleware_1 = require("../middlewares/staticsMiddleware");
|
|
10
|
-
const PlatformExpressHandler_1 = require("../services/PlatformExpressHandler");
|
|
11
|
-
const PlatformExpressRequest_1 = require("../services/PlatformExpressRequest");
|
|
12
|
-
const PlatformExpressResponse_1 = require("../services/PlatformExpressResponse");
|
|
13
11
|
/**
|
|
14
12
|
* @platform
|
|
15
13
|
* @express
|
|
16
14
|
*/
|
|
17
15
|
class PlatformExpress {
|
|
18
16
|
injector;
|
|
19
|
-
providers = [
|
|
20
|
-
{
|
|
21
|
-
provide: common_1.PlatformHandler,
|
|
22
|
-
useClass: PlatformExpressHandler_1.PlatformExpressHandler
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
provide: common_1.PlatformResponse,
|
|
26
|
-
useClass: PlatformExpressResponse_1.PlatformExpressResponse
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
provide: common_1.PlatformRequest,
|
|
30
|
-
useClass: PlatformExpressRequest_1.PlatformExpressRequest
|
|
31
|
-
}
|
|
32
|
-
];
|
|
17
|
+
providers = [];
|
|
33
18
|
#multer;
|
|
34
19
|
constructor(injector) {
|
|
35
20
|
this.injector = injector;
|
|
@@ -68,43 +53,79 @@ class PlatformExpress {
|
|
|
68
53
|
return true;
|
|
69
54
|
}));
|
|
70
55
|
}
|
|
71
|
-
useRouter() {
|
|
72
|
-
const { logger } = this.injector;
|
|
73
|
-
const app = this.injector.get(common_1.PlatformApplication);
|
|
74
|
-
logger.debug("Mount app router");
|
|
75
|
-
app.getApp().use(app.getRouter());
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
56
|
async beforeLoadRoutes() {
|
|
79
57
|
const injector = this.injector;
|
|
80
58
|
const app = this.injector.get(common_1.PlatformApplication);
|
|
81
59
|
// disable x-powered-by header
|
|
82
60
|
injector.settings.get("env") === core_1.Env.PROD && app.getApp().disable("x-powered-by");
|
|
83
61
|
await this.configureViewsEngine();
|
|
62
|
+
this.useContext();
|
|
84
63
|
}
|
|
85
64
|
async afterLoadRoutes() {
|
|
86
|
-
const injector = this.injector;
|
|
87
65
|
const app = this.injector.get(common_1.PlatformApplication);
|
|
66
|
+
const platformExceptions = this.injector.get(common_1.PlatformExceptions);
|
|
88
67
|
// NOT FOUND
|
|
89
68
|
app.use((req, res, next) => {
|
|
90
|
-
|
|
69
|
+
const $ctx = (0, common_1.getContext)();
|
|
70
|
+
!$ctx.isDone() && platformExceptions.resourceNotFound($ctx);
|
|
91
71
|
});
|
|
92
72
|
// EXCEPTION FILTERS
|
|
93
73
|
app.use((err, req, res, next) => {
|
|
94
|
-
|
|
74
|
+
const $ctx = (0, common_1.getContext)();
|
|
75
|
+
!$ctx.isDone() && platformExceptions.catch(err, $ctx);
|
|
95
76
|
});
|
|
96
77
|
}
|
|
78
|
+
mapLayers(layers) {
|
|
79
|
+
const app = this.getPlatformApplication();
|
|
80
|
+
const rawApp = app.getApp();
|
|
81
|
+
layers.forEach((layer) => {
|
|
82
|
+
switch (layer.method) {
|
|
83
|
+
case "statics":
|
|
84
|
+
rawApp.use(layer.path, this.statics(layer.path, layer.opts));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
rawApp[layer.method](...layer.getArgs());
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
mapHandler(handler, metadata) {
|
|
91
|
+
switch (metadata.type) {
|
|
92
|
+
case platform_router_1.PlatformHandlerType.RAW_ERR_FN:
|
|
93
|
+
return (error, req, res, next) => handler(error, req, res, (0, common_1.bindContext)(next));
|
|
94
|
+
case platform_router_1.PlatformHandlerType.RAW_FN:
|
|
95
|
+
return (req, res, next) => handler(req, res, (0, common_1.bindContext)(next));
|
|
96
|
+
case platform_router_1.PlatformHandlerType.ERR_MIDDLEWARE:
|
|
97
|
+
return async (error, req, res, next) => {
|
|
98
|
+
const $ctx = (0, common_1.getContext)();
|
|
99
|
+
$ctx.next = next;
|
|
100
|
+
$ctx.error = error;
|
|
101
|
+
await handler($ctx);
|
|
102
|
+
};
|
|
103
|
+
default:
|
|
104
|
+
return async (req, res, next) => {
|
|
105
|
+
const $ctx = (0, common_1.getContext)();
|
|
106
|
+
$ctx.next = next;
|
|
107
|
+
await handler($ctx);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
97
111
|
useContext() {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
app.getApp().use(async (request, response, next) => {
|
|
103
|
-
await invoke({ request, response });
|
|
112
|
+
const app = this.getPlatformApplication();
|
|
113
|
+
app.use(async (request, response, next) => {
|
|
114
|
+
const $ctx = (0, common_1.getContext)();
|
|
115
|
+
$ctx.upgrade({ request, response });
|
|
104
116
|
return next();
|
|
105
117
|
});
|
|
106
118
|
return this;
|
|
107
119
|
}
|
|
120
|
+
app() {
|
|
121
|
+
const app = this.injector.settings.get("express.app") || (0, express_1.default)();
|
|
122
|
+
return {
|
|
123
|
+
app,
|
|
124
|
+
callback() {
|
|
125
|
+
return app;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
108
129
|
multipart(options) {
|
|
109
130
|
const m = this.#multer(options);
|
|
110
131
|
const makePromise = (multer, name) => {
|
|
@@ -124,27 +145,6 @@ class PlatformExpress {
|
|
|
124
145
|
makePromise(m, "single");
|
|
125
146
|
return m;
|
|
126
147
|
}
|
|
127
|
-
app() {
|
|
128
|
-
const app = this.injector.settings.get("express.app") || (0, express_1.default)();
|
|
129
|
-
return {
|
|
130
|
-
app,
|
|
131
|
-
callback() {
|
|
132
|
-
return app;
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
router(routerOptions = {}) {
|
|
137
|
-
const options = Object.assign({
|
|
138
|
-
mergeParams: true
|
|
139
|
-
}, this.injector.settings.get("express.router", {}), routerOptions);
|
|
140
|
-
const router = express_1.default.Router(options);
|
|
141
|
-
return {
|
|
142
|
-
router,
|
|
143
|
-
callback() {
|
|
144
|
-
return router;
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
148
|
statics(endpoint, options) {
|
|
149
149
|
const { root, ...props } = options;
|
|
150
150
|
return (0, staticsMiddleware_1.staticsMiddleware)(root, props);
|
|
@@ -167,6 +167,9 @@ class PlatformExpress {
|
|
|
167
167
|
}
|
|
168
168
|
return parser({ ...options, ...additionalOptions });
|
|
169
169
|
}
|
|
170
|
+
getPlatformApplication() {
|
|
171
|
+
return this.injector.get(common_1.PlatformApplication);
|
|
172
|
+
}
|
|
170
173
|
async configureViewsEngine() {
|
|
171
174
|
const injector = this.injector;
|
|
172
175
|
const app = this.injector.get(common_1.PlatformApplication);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../../src/components/PlatformExpress.ts"],"names":[],"mappings":";;;;AAAA,yCAcsB;AACtB,qCAAyD;AAGzD,8DAA+C;AAE/C,+BAA+B;AAE/B,wEAAm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AAQ,EAAE;gBACvB,MAAM,EAAC,aAAa,EAAC,GAAG,gEAAa,sBAAsB,GAAC,CAAC;gBAC7D,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAgB,aAAa,CAAE,CAAC;gBAClE,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;gBAE7B,aAAa,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,EAAC,SAAS,EAAE,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;AAhOD,0CAgOC","sourcesContent":["import {\n createContext,\n InjectorService,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformContext,\n PlatformExceptions,\n PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRequest,\n PlatformResponse,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {Env, isFunction, nameOf, Type} from \"@tsed/core\";\nimport type {PlatformViews} from \"@tsed/platform-views\";\nimport {OptionsJson, OptionsText, OptionsUrlencoded} from \"body-parser\";\nimport Express, {RouterOptions} from \"express\";\nimport type multer from \"multer\";\nimport {promisify} from \"util\";\nimport {PlatformExpressStaticsOptions} from \"../interfaces/PlatformExpressStaticsOptions\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport {PlatformExpressHandler} from \"../services/PlatformExpressHandler\";\nimport {PlatformExpressRequest} from \"../services/PlatformExpressRequest\";\nimport {PlatformExpressResponse} from \"../services/PlatformExpressResponse\";\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, Express.Router> {\n readonly providers = [\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 #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, 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 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 useRouter(): this {\n const {logger} = this.injector;\n const app = this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\n\n logger.debug(\"Mount app router\");\n app.getApp().use(app.getRouter());\n\n return this;\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 injector = this.injector;\n const app = this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\n\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} = this.injector;\n\n logger.debug(\"Mount app context\");\n\n const invoke = createContext(this.injector);\n const app = this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\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 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 app() {\n const app = this.injector.settings.get(\"express.app\") || Express();\n return {\n app,\n callback() {\n return app;\n }\n };\n }\n\n router(routerOptions: Partial<RouterOptions> = {}) {\n const options = Object.assign(\n {\n mergeParams: true\n },\n this.injector.settings.get(\"express.router\", {}),\n routerOptions\n );\n\n const router = Express.Router(options);\n\n return {\n router,\n callback() {\n return router;\n }\n };\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 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"]}
|
|
1
|
+
{"version":3,"file":"PlatformExpress.js","sourceRoot":"","sources":["../../../src/components/PlatformExpress.ts"],"names":[],"mappings":";;;;AAAA,yCAYsB;AACtB,qCAAyD;AACzD,2DAAkG;AAGlG,8DAA8B;AAE9B,+BAA+B;AAE/B,wEAAmE;AAwBnE;;;GAGG;AACH,MAAa,eAAe;IAIJ;IAHb,SAAS,GAAG,EAAE,CAAC;IACxB,OAAO,CA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,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,sBAAsB;gBAC7B,OAAO,EAAE,oEAAoE;gBAC7E,KAAK;aACN,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AAlOD,0CAkOC","sourcesContent":["import {\n bindContext,\n getContext,\n InjectorService,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformContext,\n PlatformExceptions,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {Env, isFunction, nameOf, Type} from \"@tsed/core\";\nimport {PlatformHandlerMetadata, PlatformHandlerType, 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 this.useContext();\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 = getContext()!;\n !$ctx.isDone() && platformExceptions.resourceNotFound($ctx);\n });\n\n // EXCEPTION FILTERS\n app.use((err: any, req: any, res: any, next: any) => {\n const $ctx = getContext()!;\n\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_ERR_FN:\n return (error: unknown, req: any, res: any, next: any) => handler(error, req, res, bindContext(next));\n case PlatformHandlerType.RAW_FN:\n return (req: any, res: any, next: any) => handler(req, res, bindContext(next));\n case PlatformHandlerType.ERR_MIDDLEWARE:\n return async (error: unknown, req: any, res: any, next: any) => {\n const $ctx = getContext<PlatformContext>()!;\n $ctx.next = next;\n $ctx.error = error;\n\n await handler($ctx);\n };\n default:\n return async (req: any, res: any, next: any) => {\n const $ctx = getContext<PlatformContext>()!;\n $ctx.next = next;\n\n await handler($ctx);\n };\n }\n }\n\n useContext(): this {\n const app = this.getPlatformApplication();\n\n app.use(async (request: any, response: any, next: any) => {\n const $ctx = getContext<PlatformContext>()!;\n\n $ctx.upgrade({request, response});\n\n return next();\n });\n\n return this;\n }\n\n app() {\n const app = this.injector.settings.get(\"express.app\") || Express();\n return {\n app,\n callback() {\n return app;\n }\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"]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -6,15 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
tslib_1.__exportStar(require("./exports"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./components/PlatformExpress"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./decorators/caseSensitive"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./decorators/mergeParams"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./decorators/routerSettings"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./decorators/strict"), exports);
|
|
13
9
|
tslib_1.__exportStar(require("./interfaces/PlatformExpressSettings"), exports);
|
|
14
10
|
tslib_1.__exportStar(require("./interfaces/PlatformExpressStaticsOptions"), exports);
|
|
15
11
|
tslib_1.__exportStar(require("./interfaces/interfaces"), exports);
|
|
16
12
|
tslib_1.__exportStar(require("./middlewares/staticsMiddleware"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./services/PlatformExpressHandler"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./services/PlatformExpressRequest"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./services/PlatformExpressResponse"), exports);
|
|
20
13
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAA0B;AAC1B,uEAA6C;AAC7C
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAA0B;AAC1B,uEAA6C;AAC7C,+EAAqD;AACrD,qFAA2D;AAC3D,kEAAwC;AACxC,0EAAgD","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,31 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bindContext, getContext, PlatformApplication, PlatformBuilder, PlatformExceptions } from "@tsed/common";
|
|
2
2
|
import { Env, isFunction, nameOf } from "@tsed/core";
|
|
3
|
+
import { PlatformHandlerType } from "@tsed/platform-router";
|
|
3
4
|
import Express from "express";
|
|
4
5
|
import { promisify } from "util";
|
|
5
6
|
import { staticsMiddleware } from "../middlewares/staticsMiddleware.js";
|
|
6
|
-
import { PlatformExpressHandler } from "../services/PlatformExpressHandler.js";
|
|
7
|
-
import { PlatformExpressRequest } from "../services/PlatformExpressRequest.js";
|
|
8
|
-
import { PlatformExpressResponse } from "../services/PlatformExpressResponse.js";
|
|
9
7
|
/**
|
|
10
8
|
* @platform
|
|
11
9
|
* @express
|
|
12
10
|
*/
|
|
13
11
|
export class PlatformExpress {
|
|
14
12
|
injector;
|
|
15
|
-
providers = [
|
|
16
|
-
{
|
|
17
|
-
provide: PlatformHandler,
|
|
18
|
-
useClass: PlatformExpressHandler
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
provide: PlatformResponse,
|
|
22
|
-
useClass: PlatformExpressResponse
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
provide: PlatformRequest,
|
|
26
|
-
useClass: PlatformExpressRequest
|
|
27
|
-
}
|
|
28
|
-
];
|
|
13
|
+
providers = [];
|
|
29
14
|
#multer;
|
|
30
15
|
constructor(injector) {
|
|
31
16
|
this.injector = injector;
|
|
@@ -64,43 +49,79 @@ export class PlatformExpress {
|
|
|
64
49
|
return true;
|
|
65
50
|
}));
|
|
66
51
|
}
|
|
67
|
-
useRouter() {
|
|
68
|
-
const { logger } = this.injector;
|
|
69
|
-
const app = this.injector.get(PlatformApplication);
|
|
70
|
-
logger.debug("Mount app router");
|
|
71
|
-
app.getApp().use(app.getRouter());
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
52
|
async beforeLoadRoutes() {
|
|
75
53
|
const injector = this.injector;
|
|
76
54
|
const app = this.injector.get(PlatformApplication);
|
|
77
55
|
// disable x-powered-by header
|
|
78
56
|
injector.settings.get("env") === Env.PROD && app.getApp().disable("x-powered-by");
|
|
79
57
|
await this.configureViewsEngine();
|
|
58
|
+
this.useContext();
|
|
80
59
|
}
|
|
81
60
|
async afterLoadRoutes() {
|
|
82
|
-
const injector = this.injector;
|
|
83
61
|
const app = this.injector.get(PlatformApplication);
|
|
62
|
+
const platformExceptions = this.injector.get(PlatformExceptions);
|
|
84
63
|
// NOT FOUND
|
|
85
64
|
app.use((req, res, next) => {
|
|
86
|
-
|
|
65
|
+
const $ctx = getContext();
|
|
66
|
+
!$ctx.isDone() && platformExceptions.resourceNotFound($ctx);
|
|
87
67
|
});
|
|
88
68
|
// EXCEPTION FILTERS
|
|
89
69
|
app.use((err, req, res, next) => {
|
|
90
|
-
|
|
70
|
+
const $ctx = getContext();
|
|
71
|
+
!$ctx.isDone() && platformExceptions.catch(err, $ctx);
|
|
91
72
|
});
|
|
92
73
|
}
|
|
74
|
+
mapLayers(layers) {
|
|
75
|
+
const app = this.getPlatformApplication();
|
|
76
|
+
const rawApp = app.getApp();
|
|
77
|
+
layers.forEach((layer) => {
|
|
78
|
+
switch (layer.method) {
|
|
79
|
+
case "statics":
|
|
80
|
+
rawApp.use(layer.path, this.statics(layer.path, layer.opts));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
rawApp[layer.method](...layer.getArgs());
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
mapHandler(handler, metadata) {
|
|
87
|
+
switch (metadata.type) {
|
|
88
|
+
case PlatformHandlerType.RAW_ERR_FN:
|
|
89
|
+
return (error, req, res, next) => handler(error, req, res, bindContext(next));
|
|
90
|
+
case PlatformHandlerType.RAW_FN:
|
|
91
|
+
return (req, res, next) => handler(req, res, bindContext(next));
|
|
92
|
+
case PlatformHandlerType.ERR_MIDDLEWARE:
|
|
93
|
+
return async (error, req, res, next) => {
|
|
94
|
+
const $ctx = getContext();
|
|
95
|
+
$ctx.next = next;
|
|
96
|
+
$ctx.error = error;
|
|
97
|
+
await handler($ctx);
|
|
98
|
+
};
|
|
99
|
+
default:
|
|
100
|
+
return async (req, res, next) => {
|
|
101
|
+
const $ctx = getContext();
|
|
102
|
+
$ctx.next = next;
|
|
103
|
+
await handler($ctx);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
93
107
|
useContext() {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
app.getApp().use(async (request, response, next) => {
|
|
99
|
-
await invoke({ request, response });
|
|
108
|
+
const app = this.getPlatformApplication();
|
|
109
|
+
app.use(async (request, response, next) => {
|
|
110
|
+
const $ctx = getContext();
|
|
111
|
+
$ctx.upgrade({ request, response });
|
|
100
112
|
return next();
|
|
101
113
|
});
|
|
102
114
|
return this;
|
|
103
115
|
}
|
|
116
|
+
app() {
|
|
117
|
+
const app = this.injector.settings.get("express.app") || Express();
|
|
118
|
+
return {
|
|
119
|
+
app,
|
|
120
|
+
callback() {
|
|
121
|
+
return app;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
104
125
|
multipart(options) {
|
|
105
126
|
const m = this.#multer(options);
|
|
106
127
|
const makePromise = (multer, name) => {
|
|
@@ -120,27 +141,6 @@ export class PlatformExpress {
|
|
|
120
141
|
makePromise(m, "single");
|
|
121
142
|
return m;
|
|
122
143
|
}
|
|
123
|
-
app() {
|
|
124
|
-
const app = this.injector.settings.get("express.app") || Express();
|
|
125
|
-
return {
|
|
126
|
-
app,
|
|
127
|
-
callback() {
|
|
128
|
-
return app;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
router(routerOptions = {}) {
|
|
133
|
-
const options = Object.assign({
|
|
134
|
-
mergeParams: true
|
|
135
|
-
}, this.injector.settings.get("express.router", {}), routerOptions);
|
|
136
|
-
const router = Express.Router(options);
|
|
137
|
-
return {
|
|
138
|
-
router,
|
|
139
|
-
callback() {
|
|
140
|
-
return router;
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
144
|
statics(endpoint, options) {
|
|
145
145
|
const { root, ...props } = options;
|
|
146
146
|
return staticsMiddleware(root, props);
|
|
@@ -163,6 +163,9 @@ export class PlatformExpress {
|
|
|
163
163
|
}
|
|
164
164
|
return parser({ ...options, ...additionalOptions });
|
|
165
165
|
}
|
|
166
|
+
getPlatformApplication() {
|
|
167
|
+
return this.injector.get(PlatformApplication);
|
|
168
|
+
}
|
|
166
169
|
async configureViewsEngine() {
|
|
167
170
|
const injector = this.injector;
|
|
168
171
|
const app = this.injector.get(PlatformApplication);
|
|
@@ -1 +1 @@
|
|
|
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,eAAe,EAGf,eAAe,EACf,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,GAAG,EAAE,UAAU,EAAE,M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B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAA2C,mBAAmB,CAAE,CAAC;QAE9F,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAErE,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE;gBACvB,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;gBAC7D,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAgB,aAAa,CAAE,CAAC;gBAClE,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;gBAE7B,aAAa,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,EAAC,SAAS,EAAE,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 PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRequest,\n PlatformResponse,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {Env, isFunction, nameOf, Type} from \"@tsed/core\";\nimport type {PlatformViews} from \"@tsed/platform-views\";\nimport {OptionsJson, OptionsText, OptionsUrlencoded} from \"body-parser\";\nimport Express, {RouterOptions} from \"express\";\nimport type multer from \"multer\";\nimport {promisify} from \"util\";\nimport {PlatformExpressStaticsOptions} from \"../interfaces/PlatformExpressStaticsOptions\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport {PlatformExpressHandler} from \"../services/PlatformExpressHandler\";\nimport {PlatformExpressRequest} from \"../services/PlatformExpressRequest\";\nimport {PlatformExpressResponse} from \"../services/PlatformExpressResponse\";\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, Express.Router> {\n readonly providers = [\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 #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, 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 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 useRouter(): this {\n const {logger} = this.injector;\n const app = this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\n\n logger.debug(\"Mount app router\");\n app.getApp().use(app.getRouter());\n\n return this;\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 injector = this.injector;\n const app = this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\n\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} = this.injector;\n\n logger.debug(\"Mount app context\");\n\n const invoke = createContext(this.injector);\n const app = this.injector.get<PlatformApplication<Express.Application>>(PlatformApplication)!;\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 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 app() {\n const app = this.injector.settings.get(\"express.app\") || Express();\n return {\n app,\n callback() {\n return app;\n }\n };\n }\n\n router(routerOptions: Partial<RouterOptions> = {}) {\n const options = Object.assign(\n {\n mergeParams: true\n },\n this.injector.settings.get(\"express.router\", {}),\n routerOptions\n );\n\n const router = Express.Router(options);\n\n return {\n router,\n callback() {\n return router;\n }\n };\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 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"]}
|
|
1
|
+
{"version":3,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7B,aAAa,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,EAAC,SAAS,EAAE,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 bindContext,\n getContext,\n InjectorService,\n PlatformAdapter,\n PlatformApplication,\n PlatformBuilder,\n PlatformContext,\n PlatformExceptions,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {Env, isFunction, nameOf, Type} from \"@tsed/core\";\nimport {PlatformHandlerMetadata, PlatformHandlerType, 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 this.useContext();\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 = getContext()!;\n !$ctx.isDone() && platformExceptions.resourceNotFound($ctx);\n });\n\n // EXCEPTION FILTERS\n app.use((err: any, req: any, res: any, next: any) => {\n const $ctx = getContext()!;\n\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_ERR_FN:\n return (error: unknown, req: any, res: any, next: any) => handler(error, req, res, bindContext(next));\n case PlatformHandlerType.RAW_FN:\n return (req: any, res: any, next: any) => handler(req, res, bindContext(next));\n case PlatformHandlerType.ERR_MIDDLEWARE:\n return async (error: unknown, req: any, res: any, next: any) => {\n const $ctx = getContext<PlatformContext>()!;\n $ctx.next = next;\n $ctx.error = error;\n\n await handler($ctx);\n };\n default:\n return async (req: any, res: any, next: any) => {\n const $ctx = getContext<PlatformContext>()!;\n $ctx.next = next;\n\n await handler($ctx);\n };\n }\n }\n\n useContext(): this {\n const app = this.getPlatformApplication();\n\n app.use(async (request: any, response: any, next: any) => {\n const $ctx = getContext<PlatformContext>()!;\n\n $ctx.upgrade({request, response});\n\n return next();\n });\n\n return this;\n }\n\n app() {\n const app = this.injector.settings.get(\"express.app\") || Express();\n return {\n app,\n callback() {\n return app;\n }\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"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -3,15 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export * from "./exports.js";
|
|
5
5
|
export * from "./components/PlatformExpress.js";
|
|
6
|
-
export * from "./decorators/caseSensitive.js";
|
|
7
|
-
export * from "./decorators/mergeParams.js";
|
|
8
|
-
export * from "./decorators/routerSettings.js";
|
|
9
|
-
export * from "./decorators/strict.js";
|
|
10
6
|
export * from "./interfaces/PlatformExpressSettings.js";
|
|
11
7
|
export * from "./interfaces/PlatformExpressStaticsOptions.js";
|
|
12
8
|
export * from "./interfaces/interfaces.js";
|
|
13
9
|
export * from "./middlewares/staticsMiddleware.js";
|
|
14
|
-
export * from "./services/PlatformExpressHandler.js";
|
|
15
|
-
export * from "./services/PlatformExpressRequest.js";
|
|
16
|
-
export * from "./services/PlatformExpressResponse.js";
|
|
17
10
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,10 +1,8 @@
|
|
|
1
|
-
import { InjectorService, PlatformAdapter, PlatformBuilder, PlatformContext,
|
|
1
|
+
import { InjectorService, PlatformAdapter, PlatformBuilder, PlatformContext, PlatformMulter, PlatformMulterSettings, PlatformStaticsOptions } from "@tsed/common";
|
|
2
2
|
import { Type } from "@tsed/core";
|
|
3
|
-
import
|
|
3
|
+
import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
|
|
4
|
+
import Express from "express";
|
|
4
5
|
import { PlatformExpressStaticsOptions } from "../interfaces/PlatformExpressStaticsOptions";
|
|
5
|
-
import { PlatformExpressHandler } from "../services/PlatformExpressHandler";
|
|
6
|
-
import { PlatformExpressRequest } from "../services/PlatformExpressRequest";
|
|
7
|
-
import { PlatformExpressResponse } from "../services/PlatformExpressResponse";
|
|
8
6
|
declare module "express" {
|
|
9
7
|
interface Request {
|
|
10
8
|
id: string;
|
|
@@ -13,8 +11,6 @@ declare module "express" {
|
|
|
13
11
|
}
|
|
14
12
|
declare global {
|
|
15
13
|
namespace TsED {
|
|
16
|
-
interface Router extends Express.Router {
|
|
17
|
-
}
|
|
18
14
|
interface Application extends Express.Application {
|
|
19
15
|
}
|
|
20
16
|
interface StaticsOptions extends PlatformExpressStaticsOptions {
|
|
@@ -29,47 +25,36 @@ declare global {
|
|
|
29
25
|
* @platform
|
|
30
26
|
* @express
|
|
31
27
|
*/
|
|
32
|
-
export declare class PlatformExpress implements PlatformAdapter<Express.Application
|
|
28
|
+
export declare class PlatformExpress implements PlatformAdapter<Express.Application> {
|
|
33
29
|
#private;
|
|
34
30
|
protected injector: InjectorService;
|
|
35
|
-
readonly providers:
|
|
36
|
-
provide: typeof PlatformHandler;
|
|
37
|
-
useClass: typeof PlatformExpressHandler;
|
|
38
|
-
} | {
|
|
39
|
-
provide: typeof PlatformResponse;
|
|
40
|
-
useClass: typeof PlatformExpressResponse;
|
|
41
|
-
} | {
|
|
42
|
-
provide: typeof PlatformRequest;
|
|
43
|
-
useClass: typeof PlatformExpressRequest;
|
|
44
|
-
})[];
|
|
31
|
+
readonly providers: never[];
|
|
45
32
|
constructor(injector: InjectorService);
|
|
46
33
|
/**
|
|
47
34
|
* Create new serverless application. In this mode, the component scan are disabled.
|
|
48
35
|
* @param module
|
|
49
36
|
* @param settings
|
|
50
37
|
*/
|
|
51
|
-
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Express.Application
|
|
38
|
+
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Express.Application>;
|
|
52
39
|
/**
|
|
53
40
|
* Bootstrap a server application
|
|
54
41
|
* @param module
|
|
55
42
|
* @param settings
|
|
56
43
|
*/
|
|
57
|
-
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Express.Application
|
|
44
|
+
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Express.Application>>;
|
|
58
45
|
onInit(): void;
|
|
59
|
-
useRouter(): this;
|
|
60
46
|
beforeLoadRoutes(): Promise<void>;
|
|
61
47
|
afterLoadRoutes(): Promise<void>;
|
|
48
|
+
mapLayers(layers: PlatformLayer[]): void;
|
|
49
|
+
mapHandler(handler: Function, metadata: PlatformHandlerMetadata): (error: unknown, req: any, res: any, next: any) => any;
|
|
62
50
|
useContext(): this;
|
|
63
|
-
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
64
51
|
app(): {
|
|
65
52
|
app: any;
|
|
66
53
|
callback(): any;
|
|
67
54
|
};
|
|
68
|
-
|
|
69
|
-
router: import("express-serve-static-core").Router;
|
|
70
|
-
callback(): import("express-serve-static-core").Router;
|
|
71
|
-
};
|
|
55
|
+
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
72
56
|
statics(endpoint: string, options: PlatformStaticsOptions): (request: any, response: any, next: any) => void;
|
|
73
57
|
bodyParser(type: "json" | "raw" | "text" | "urlencoded", additionalOptions?: any): any;
|
|
58
|
+
private getPlatformApplication;
|
|
74
59
|
private configureViewsEngine;
|
|
75
60
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -3,14 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export * from "./exports";
|
|
5
5
|
export * from "./components/PlatformExpress";
|
|
6
|
-
export * from "./decorators/caseSensitive";
|
|
7
|
-
export * from "./decorators/mergeParams";
|
|
8
|
-
export * from "./decorators/routerSettings";
|
|
9
|
-
export * from "./decorators/strict";
|
|
10
6
|
export * from "./interfaces/PlatformExpressSettings";
|
|
11
7
|
export * from "./interfaces/PlatformExpressStaticsOptions";
|
|
12
8
|
export * from "./interfaces/interfaces";
|
|
13
9
|
export * from "./middlewares/staticsMiddleware";
|
|
14
|
-
export * from "./services/PlatformExpressHandler";
|
|
15
|
-
export * from "./services/PlatformExpressRequest";
|
|
16
|
-
export * from "./services/PlatformExpressResponse";
|