@tsed/common 8.0.0-beta.1 → 8.0.0-beta.10
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/esm/index.js +12 -63
- package/lib/esm/index.js.map +1 -1
- package/lib/types/index.d.ts +12 -63
- package/package.json +11 -32
- package/readme.md +3 -3
- package/vitest.config.mts +5 -5
- package/.barrelsby.json +0 -5
- package/lib/esm/builder/PlatformBuilder.js +0 -308
- package/lib/esm/builder/PlatformBuilder.js.map +0 -1
- package/lib/esm/config/interfaces/PlatformJsonMapperSettings.js +0 -2
- package/lib/esm/config/interfaces/PlatformJsonMapperSettings.js.map +0 -1
- package/lib/esm/config/interfaces/PlatformMulterSettings.js +0 -2
- package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +0 -1
- package/lib/esm/config/interfaces/PlatformRouterSettings.js +0 -2
- package/lib/esm/config/interfaces/PlatformRouterSettings.js.map +0 -1
- package/lib/esm/config/interfaces/PlatformStaticsSettings.js +0 -2
- package/lib/esm/config/interfaces/PlatformStaticsSettings.js.map +0 -1
- package/lib/esm/config/services/PlatformConfiguration.js +0 -119
- package/lib/esm/config/services/PlatformConfiguration.js.map +0 -1
- package/lib/esm/constants/routerOptions.js +0 -2
- package/lib/esm/constants/routerOptions.js.map +0 -1
- package/lib/esm/decorators/PlatformProvider.js +0 -7
- package/lib/esm/decorators/PlatformProvider.js.map +0 -1
- package/lib/esm/decorators/multer/multerFileSize.js +0 -31
- package/lib/esm/decorators/multer/multerFileSize.js.map +0 -1
- package/lib/esm/decorators/multer/multerOptions.js +0 -49
- package/lib/esm/decorators/multer/multerOptions.js.map +0 -1
- package/lib/esm/decorators/multer/multipartFile.js +0 -74
- package/lib/esm/decorators/multer/multipartFile.js.map +0 -1
- package/lib/esm/decorators/params/error.js +0 -16
- package/lib/esm/decorators/params/error.js.map +0 -1
- package/lib/esm/decorators/params/next.js +0 -17
- package/lib/esm/decorators/params/next.js.map +0 -1
- package/lib/esm/decorators/params/request.js +0 -34
- package/lib/esm/decorators/params/request.js.map +0 -1
- package/lib/esm/decorators/params/response.js +0 -28
- package/lib/esm/decorators/params/response.js.map +0 -1
- package/lib/esm/domain/AnyToPromiseWithCtx.js +0 -21
- package/lib/esm/domain/AnyToPromiseWithCtx.js.map +0 -1
- package/lib/esm/domain/EndpointMetadata.js +0 -2
- package/lib/esm/domain/EndpointMetadata.js.map +0 -1
- package/lib/esm/domain/PlatformContext.js +0 -69
- package/lib/esm/domain/PlatformContext.js.map +0 -1
- package/lib/esm/domain/PlatformRouteDetails.js +0 -2
- package/lib/esm/domain/PlatformRouteDetails.js.map +0 -1
- package/lib/esm/exports.js +0 -10
- package/lib/esm/exports.js.map +0 -1
- package/lib/esm/interfaces/AfterInit.js +0 -2
- package/lib/esm/interfaces/AfterInit.js.map +0 -1
- package/lib/esm/interfaces/AfterListen.js +0 -2
- package/lib/esm/interfaces/AfterListen.js.map +0 -1
- package/lib/esm/interfaces/AfterRoutesInit.js +0 -2
- package/lib/esm/interfaces/AfterRoutesInit.js.map +0 -1
- package/lib/esm/interfaces/BeforeInit.js +0 -2
- package/lib/esm/interfaces/BeforeInit.js.map +0 -1
- package/lib/esm/interfaces/BeforeListen.js +0 -2
- package/lib/esm/interfaces/BeforeListen.js.map +0 -1
- package/lib/esm/interfaces/BeforeRoutesInit.js +0 -2
- package/lib/esm/interfaces/BeforeRoutesInit.js.map +0 -1
- package/lib/esm/interfaces/HandlerType.js +0 -14
- package/lib/esm/interfaces/HandlerType.js.map +0 -1
- package/lib/esm/interfaces/IncomingEvent.js +0 -2
- package/lib/esm/interfaces/IncomingEvent.js.map +0 -1
- package/lib/esm/interfaces/OnReady.js +0 -2
- package/lib/esm/interfaces/OnReady.js.map +0 -1
- package/lib/esm/interfaces/OnRequest.js +0 -2
- package/lib/esm/interfaces/OnRequest.js.map +0 -1
- package/lib/esm/interfaces/OnResponse.js +0 -2
- package/lib/esm/interfaces/OnResponse.js.map +0 -1
- package/lib/esm/interfaces/OnRoutesInit.js +0 -2
- package/lib/esm/interfaces/OnRoutesInit.js.map +0 -1
- package/lib/esm/interfaces/PlatformRouteOptions.js +0 -2
- package/lib/esm/interfaces/PlatformRouteOptions.js.map +0 -1
- package/lib/esm/interfaces/ResponseErrorObject.js +0 -2
- package/lib/esm/interfaces/ResponseErrorObject.js.map +0 -1
- package/lib/esm/interfaces/Route.js +0 -2
- package/lib/esm/interfaces/Route.js.map +0 -1
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +0 -36
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +0 -1
- package/lib/esm/middlewares/PlatformMulterMiddleware.js +0 -66
- package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +0 -1
- package/lib/esm/services/FakeAdapter.js +0 -2
- package/lib/esm/services/FakeAdapter.js.map +0 -1
- package/lib/esm/services/FakeResponse.js +0 -55
- package/lib/esm/services/FakeResponse.js.map +0 -1
- package/lib/esm/services/Platform.js +0 -73
- package/lib/esm/services/Platform.js.map +0 -1
- package/lib/esm/services/PlatformAdapter.js +0 -77
- package/lib/esm/services/PlatformAdapter.js.map +0 -1
- package/lib/esm/services/PlatformApplication.js +0 -41
- package/lib/esm/services/PlatformApplication.js.map +0 -1
- package/lib/esm/services/PlatformHandler.js +0 -130
- package/lib/esm/services/PlatformHandler.js.map +0 -1
- package/lib/esm/services/PlatformMiddlewaresChain.js +0 -57
- package/lib/esm/services/PlatformMiddlewaresChain.js.map +0 -1
- package/lib/esm/services/PlatformRequest.js +0 -141
- package/lib/esm/services/PlatformRequest.js.map +0 -1
- package/lib/esm/services/PlatformResponse.js +0 -306
- package/lib/esm/services/PlatformResponse.js.map +0 -1
- package/lib/esm/services/PlatformTest.js +0 -137
- package/lib/esm/services/PlatformTest.js.map +0 -1
- package/lib/esm/utils/closeServer.js +0 -4
- package/lib/esm/utils/closeServer.js.map +0 -1
- package/lib/esm/utils/createContext.js +0 -44
- package/lib/esm/utils/createContext.js.map +0 -1
- package/lib/esm/utils/createHttpServer.js +0 -13
- package/lib/esm/utils/createHttpServer.js.map +0 -1
- package/lib/esm/utils/createHttpsServer.js +0 -13
- package/lib/esm/utils/createHttpsServer.js.map +0 -1
- package/lib/esm/utils/createInjector.js +0 -41
- package/lib/esm/utils/createInjector.js.map +0 -1
- package/lib/esm/utils/createServer.js +0 -29
- package/lib/esm/utils/createServer.js.map +0 -1
- package/lib/esm/utils/ensureContext.js +0 -12
- package/lib/esm/utils/ensureContext.js.map +0 -1
- package/lib/esm/utils/getConfiguration.js +0 -32
- package/lib/esm/utils/getConfiguration.js.map +0 -1
- package/lib/esm/utils/getStaticsOptions.js +0 -17
- package/lib/esm/utils/getStaticsOptions.js.map +0 -1
- package/lib/esm/utils/listenServer.js +0 -10
- package/lib/esm/utils/listenServer.js.map +0 -1
- package/lib/esm/utils/mapReturnedResponse.js +0 -11
- package/lib/esm/utils/mapReturnedResponse.js.map +0 -1
- package/lib/esm/utils/printRoutes.js +0 -34
- package/lib/esm/utils/printRoutes.js.map +0 -1
- package/lib/esm/utils/registerPlatformAdapter.js +0 -7
- package/lib/esm/utils/registerPlatformAdapter.js.map +0 -1
- package/lib/esm/utils/setResponseHeaders.js +0 -25
- package/lib/esm/utils/setResponseHeaders.js.map +0 -1
- package/lib/types/builder/PlatformBuilder.d.ts +0 -100
- package/lib/types/config/interfaces/PlatformJsonMapperSettings.d.ts +0 -10
- package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +0 -14
- package/lib/types/config/interfaces/PlatformRouterSettings.d.ts +0 -10
- package/lib/types/config/interfaces/PlatformStaticsSettings.d.ts +0 -17
- package/lib/types/config/services/PlatformConfiguration.d.ts +0 -67
- package/lib/types/constants/routerOptions.d.ts +0 -1
- package/lib/types/decorators/PlatformProvider.d.ts +0 -3
- package/lib/types/decorators/multer/multerFileSize.d.ts +0 -27
- package/lib/types/decorators/multer/multerOptions.d.ts +0 -42
- package/lib/types/decorators/multer/multipartFile.d.ts +0 -47
- package/lib/types/decorators/params/error.d.ts +0 -7
- package/lib/types/decorators/params/next.d.ts +0 -22
- package/lib/types/decorators/params/request.d.ts +0 -46
- package/lib/types/decorators/params/response.d.ts +0 -40
- package/lib/types/domain/AnyToPromiseWithCtx.d.ts +0 -10
- package/lib/types/domain/EndpointMetadata.d.ts +0 -1
- package/lib/types/domain/PlatformContext.d.ts +0 -80
- package/lib/types/domain/PlatformRouteDetails.d.ts +0 -7
- package/lib/types/exports.d.ts +0 -9
- package/lib/types/interfaces/AfterInit.d.ts +0 -3
- package/lib/types/interfaces/AfterListen.d.ts +0 -3
- package/lib/types/interfaces/AfterRoutesInit.d.ts +0 -3
- package/lib/types/interfaces/BeforeInit.d.ts +0 -3
- package/lib/types/interfaces/BeforeListen.d.ts +0 -3
- package/lib/types/interfaces/BeforeRoutesInit.d.ts +0 -3
- package/lib/types/interfaces/HandlerType.d.ts +0 -12
- package/lib/types/interfaces/IncomingEvent.d.ts +0 -6
- package/lib/types/interfaces/OnReady.d.ts +0 -3
- package/lib/types/interfaces/OnRequest.d.ts +0 -4
- package/lib/types/interfaces/OnResponse.d.ts +0 -4
- package/lib/types/interfaces/OnRoutesInit.d.ts +0 -3
- package/lib/types/interfaces/PlatformRouteOptions.d.ts +0 -15
- package/lib/types/interfaces/ResponseErrorObject.d.ts +0 -8
- package/lib/types/interfaces/Route.d.ts +0 -10
- package/lib/types/middlewares/PlatformAcceptMimesMiddleware.d.ts +0 -10
- package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +0 -24
- package/lib/types/services/FakeAdapter.d.ts +0 -1
- package/lib/types/services/FakeResponse.d.ts +0 -22
- package/lib/types/services/Platform.d.ts +0 -25
- package/lib/types/services/PlatformAdapter.d.ts +0 -89
- package/lib/types/services/PlatformApplication.d.ts +0 -29
- package/lib/types/services/PlatformHandler.d.ts +0 -39
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +0 -17
- package/lib/types/services/PlatformRequest.d.ts +0 -111
- package/lib/types/services/PlatformResponse.d.ts +0 -175
- package/lib/types/services/PlatformTest.d.ts +0 -60
- package/lib/types/utils/closeServer.d.ts +0 -7
- package/lib/types/utils/createContext.d.ts +0 -10
- package/lib/types/utils/createHttpServer.d.ts +0 -4
- package/lib/types/utils/createHttpsServer.d.ts +0 -4
- package/lib/types/utils/createInjector.d.ts +0 -9
- package/lib/types/utils/createServer.d.ts +0 -17
- package/lib/types/utils/ensureContext.d.ts +0 -2
- package/lib/types/utils/getConfiguration.d.ts +0 -2
- package/lib/types/utils/getStaticsOptions.d.ts +0 -5
- package/lib/types/utils/listenServer.d.ts +0 -8
- package/lib/types/utils/mapReturnedResponse.d.ts +0 -4
- package/lib/types/utils/printRoutes.d.ts +0 -2
- package/lib/types/utils/registerPlatformAdapter.d.ts +0 -3
- package/lib/types/utils/setResponseHeaders.d.ts +0 -5
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Injectable, ProviderScope, Scope } from "@tsed/di";
|
|
3
|
-
/**
|
|
4
|
-
* Platform Request abstraction layer.
|
|
5
|
-
* @platform
|
|
6
|
-
*/
|
|
7
|
-
let PlatformRequest = class PlatformRequest {
|
|
8
|
-
constructor($ctx) {
|
|
9
|
-
this.$ctx = $ctx;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* The current @@PlatformResponse@@.
|
|
13
|
-
*/
|
|
14
|
-
get response() {
|
|
15
|
-
return this.$ctx.response;
|
|
16
|
-
}
|
|
17
|
-
get raw() {
|
|
18
|
-
return this.$ctx.event.request;
|
|
19
|
-
}
|
|
20
|
-
get secure() {
|
|
21
|
-
return this.raw.secure;
|
|
22
|
-
}
|
|
23
|
-
get host() {
|
|
24
|
-
return this.get("host");
|
|
25
|
-
}
|
|
26
|
-
get protocol() {
|
|
27
|
-
return this.raw.protocol;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Get the url of the request.
|
|
31
|
-
*
|
|
32
|
-
* Is equivalent of `express.response.originalUrl || express.response.url`.
|
|
33
|
-
*/
|
|
34
|
-
get url() {
|
|
35
|
-
return this.raw.originalUrl || this.raw.url;
|
|
36
|
-
}
|
|
37
|
-
get headers() {
|
|
38
|
-
return this.raw.headers;
|
|
39
|
-
}
|
|
40
|
-
get method() {
|
|
41
|
-
return this.raw.method;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Contains key-value pairs of data submitted in the request body. By default, it is `undefined`, and is populated when you use
|
|
45
|
-
* `body-parsing` middleware such as `express.json()` or `express.urlencoded()`.
|
|
46
|
-
*/
|
|
47
|
-
get body() {
|
|
48
|
-
return this.raw.body;
|
|
49
|
-
}
|
|
50
|
-
get rawBody() {
|
|
51
|
-
return this.raw.rawBody || this.raw.body;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* When using `cookie-parser` middleware, this property is an object that contains cookies sent by the request.
|
|
55
|
-
* If the request contains no cookies, it defaults to `{}`.
|
|
56
|
-
*/
|
|
57
|
-
get cookies() {
|
|
58
|
-
return this.raw.cookies;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* This property is an object containing properties mapped to the named route `parameters`.
|
|
62
|
-
* For example, if you have the route `/user/:name`, then the `name` property is available as `req.params.name`.
|
|
63
|
-
* This object defaults to `{}`.
|
|
64
|
-
*/
|
|
65
|
-
get params() {
|
|
66
|
-
return this.raw.params;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* This property is an object containing a property for each query string parameter in the route.
|
|
70
|
-
* When query parser is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
|
|
71
|
-
*/
|
|
72
|
-
get query() {
|
|
73
|
-
return this.raw.query;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* This property is an object containing a property for each session attributes set by any code.
|
|
77
|
-
* It requires to install a middleware like express-session to work.
|
|
78
|
-
*/
|
|
79
|
-
get session() {
|
|
80
|
-
return this.raw.session;
|
|
81
|
-
}
|
|
82
|
-
get files() {
|
|
83
|
-
return this.raw.files;
|
|
84
|
-
}
|
|
85
|
-
get route() {
|
|
86
|
-
return this.$ctx.handlerMetadata?.path;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Return the original request framework instance
|
|
90
|
-
*/
|
|
91
|
-
get request() {
|
|
92
|
-
return this.getRequest();
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Return the original request node.js instance
|
|
96
|
-
*/
|
|
97
|
-
get req() {
|
|
98
|
-
return this.getReq();
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Returns the HTTP request header specified by field. The match is case-insensitive.
|
|
102
|
-
*
|
|
103
|
-
* ```typescript
|
|
104
|
-
* request.get('Content-Type') // => "text/plain"
|
|
105
|
-
* ```
|
|
106
|
-
*
|
|
107
|
-
* @param name
|
|
108
|
-
*/
|
|
109
|
-
get(name) {
|
|
110
|
-
return this.raw.get(name);
|
|
111
|
-
}
|
|
112
|
-
getHeader(name) {
|
|
113
|
-
return this.get(name);
|
|
114
|
-
}
|
|
115
|
-
accepts(mime) {
|
|
116
|
-
// @ts-ignore
|
|
117
|
-
return this.raw.accepts(mime);
|
|
118
|
-
}
|
|
119
|
-
isAborted() {
|
|
120
|
-
return this.raw.aborted;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Return the Framework response object (express, koa, etc...)
|
|
124
|
-
*/
|
|
125
|
-
getRequest() {
|
|
126
|
-
return this.raw;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Return the Node.js response object
|
|
130
|
-
*/
|
|
131
|
-
getReq() {
|
|
132
|
-
return this.$ctx.event.request;
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
PlatformRequest = __decorate([
|
|
136
|
-
Injectable(),
|
|
137
|
-
Scope(ProviderScope.INSTANCE),
|
|
138
|
-
__metadata("design:paramtypes", [Function])
|
|
139
|
-
], PlatformRequest);
|
|
140
|
-
export { PlatformRequest };
|
|
141
|
-
//# sourceMappingURL=PlatformRequest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformRequest.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AAe1D;;;GAGG;AAGI,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAAqB,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;IAAG,CAAC;IAE9C;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAc,CAAC;IACxC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAC9C,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IAC3C,CAAC;IAED;;;OAGG;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C;CACF,CAAA;AAhKY,eAAe;IAF3B,UAAU,EAAE;IACZ,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC;;GACjB,eAAe,CAgK3B"}
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { isArray, isBoolean, isNumber, isStream, isString } from "@tsed/core";
|
|
3
|
-
import { Injectable, ProviderScope, Scope } from "@tsed/di";
|
|
4
|
-
import { getStatusMessage } from "@tsed/schema";
|
|
5
|
-
import encodeUrl from "encodeurl";
|
|
6
|
-
/**
|
|
7
|
-
* Platform Response abstraction layer.
|
|
8
|
-
* @platform
|
|
9
|
-
*/
|
|
10
|
-
let PlatformResponse = class PlatformResponse {
|
|
11
|
-
constructor($ctx) {
|
|
12
|
-
this.$ctx = $ctx;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The current @@PlatformRequest@@.
|
|
16
|
-
*/
|
|
17
|
-
get request() {
|
|
18
|
-
return this.$ctx.request;
|
|
19
|
-
}
|
|
20
|
-
get raw() {
|
|
21
|
-
return this.$ctx.event.response;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Get the current statusCode
|
|
25
|
-
*/
|
|
26
|
-
get statusCode() {
|
|
27
|
-
return this.raw.statusCode;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* An object that contains response local variables scoped to the request, and therefore available only to the view(s) rendered during that request / response cycle (if any). Otherwise, this property is identical to app.locals.
|
|
31
|
-
*
|
|
32
|
-
* This property is useful for exposing request-level information such as the request path name, authenticated user, user settings, and so on.
|
|
33
|
-
*/
|
|
34
|
-
get locals() {
|
|
35
|
-
return this.raw.locals;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Return the original response framework instance
|
|
39
|
-
*/
|
|
40
|
-
get response() {
|
|
41
|
-
return this.getResponse();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Return the original response node.js instance
|
|
45
|
-
*/
|
|
46
|
-
get res() {
|
|
47
|
-
return this.getRes();
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Returns the HTTP response header specified by field. The match is case-insensitive.
|
|
51
|
-
*
|
|
52
|
-
* ```typescript
|
|
53
|
-
* response.get('Content-Type') // => "text/plain"
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* @param name
|
|
57
|
-
*/
|
|
58
|
-
get(name) {
|
|
59
|
-
return this.raw.get(name);
|
|
60
|
-
}
|
|
61
|
-
getHeaders() {
|
|
62
|
-
return this.raw.getHeaders();
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Return the Framework response object (express, koa, etc...)
|
|
66
|
-
*/
|
|
67
|
-
getResponse() {
|
|
68
|
-
return this.raw;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Return the Node.js response object
|
|
72
|
-
*/
|
|
73
|
-
getRes() {
|
|
74
|
-
return this.raw;
|
|
75
|
-
}
|
|
76
|
-
hasStatus() {
|
|
77
|
-
return this.statusCode !== 200;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Sets the HTTP status for the response.
|
|
81
|
-
*
|
|
82
|
-
* @param status
|
|
83
|
-
*/
|
|
84
|
-
status(status) {
|
|
85
|
-
this.raw.status(status);
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Set header `field` to `val`, or pass
|
|
90
|
-
* an object of header fields.
|
|
91
|
-
*
|
|
92
|
-
* Examples:
|
|
93
|
-
* ```typescript
|
|
94
|
-
* response.setHeaders({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* Aliased as `res.header()`.
|
|
98
|
-
*/
|
|
99
|
-
setHeaders(headers) {
|
|
100
|
-
// apply headers
|
|
101
|
-
Object.entries(headers).forEach(([key, item]) => {
|
|
102
|
-
this.setHeader(key, item);
|
|
103
|
-
});
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
setHeader(key, item) {
|
|
107
|
-
this.raw.set(key, this.formatHeader(key, item));
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Set `Content-Type` response header with `type` through `mime.lookup()`
|
|
112
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
113
|
-
*
|
|
114
|
-
* Examples:
|
|
115
|
-
*
|
|
116
|
-
* res.type('.html');
|
|
117
|
-
* res.type('html');
|
|
118
|
-
* res.type('json');
|
|
119
|
-
* res.type('application/json');
|
|
120
|
-
* res.type('png');
|
|
121
|
-
*/
|
|
122
|
-
contentType(contentType) {
|
|
123
|
-
this.raw.contentType(contentType);
|
|
124
|
-
return this;
|
|
125
|
-
}
|
|
126
|
-
contentLength(length) {
|
|
127
|
-
this.setHeader("Content-Length", length);
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
getContentLength() {
|
|
131
|
-
if (this.get("Content-Length")) {
|
|
132
|
-
return parseInt(this.get("Content-Length"), 10) || 0;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
getContentType() {
|
|
136
|
-
return (this.get("Content-Type") || "").split(";")[0];
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Sets the HTTP response Content-Disposition header field to “attachment”.
|
|
140
|
-
* If a filename is given, then it sets the Content-Type based on the extension name via res.type(), and sets the Content-Disposition “filename=” parameter.
|
|
141
|
-
*
|
|
142
|
-
* ```typescript
|
|
143
|
-
* res.attachment()
|
|
144
|
-
* // Content-Disposition: attachment
|
|
145
|
-
*
|
|
146
|
-
* res.attachment('path/to/logo.png')
|
|
147
|
-
* // Content-Disposition: attachment; filename="logo.png"
|
|
148
|
-
* // Content-Type: image/png
|
|
149
|
-
* ```
|
|
150
|
-
*
|
|
151
|
-
* @param filename
|
|
152
|
-
*/
|
|
153
|
-
attachment(filename) {
|
|
154
|
-
this.raw.attachment(filename);
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an [HTTP status code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
|
|
159
|
-
* If not specified, status defaults to `302 Found`.
|
|
160
|
-
*
|
|
161
|
-
* @param status
|
|
162
|
-
* @param url
|
|
163
|
-
*/
|
|
164
|
-
redirect(status, url) {
|
|
165
|
-
status = status || 302;
|
|
166
|
-
this.location(url);
|
|
167
|
-
// Set location header
|
|
168
|
-
url = this.get("Location");
|
|
169
|
-
const txt = `${getStatusMessage(status)}. Redirecting to ${url}`;
|
|
170
|
-
this.status(status);
|
|
171
|
-
if (this.request.method === "HEAD") {
|
|
172
|
-
this.end();
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
this.setHeader("Content-Length", Buffer.byteLength(txt)).end(txt);
|
|
176
|
-
}
|
|
177
|
-
return this;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Sets the response Location HTTP header to the specified path parameter.
|
|
181
|
-
*
|
|
182
|
-
* @param location
|
|
183
|
-
*/
|
|
184
|
-
location(location) {
|
|
185
|
-
this.setHeader("Location", location);
|
|
186
|
-
return this;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Stream the given data.
|
|
190
|
-
*
|
|
191
|
-
* @param data
|
|
192
|
-
*/
|
|
193
|
-
stream(data) {
|
|
194
|
-
data.pipe(this.raw);
|
|
195
|
-
return this;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Renders a view and sends the rendered HTML string to the client.
|
|
199
|
-
*
|
|
200
|
-
* @param path
|
|
201
|
-
* @param options
|
|
202
|
-
*/
|
|
203
|
-
async render(path, options = {}) {
|
|
204
|
-
const { PlatformViews } = await import("@tsed/platform-views");
|
|
205
|
-
const platformViews = await this.$ctx.injector.lazyInvoke(PlatformViews);
|
|
206
|
-
return platformViews.render(path, {
|
|
207
|
-
...this.locals,
|
|
208
|
-
...options
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Send any data to your consumer.
|
|
213
|
-
*
|
|
214
|
-
* This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.
|
|
215
|
-
* It chooses the better way to send the data.
|
|
216
|
-
*
|
|
217
|
-
* @param data
|
|
218
|
-
*/
|
|
219
|
-
body(data) {
|
|
220
|
-
this.data = data;
|
|
221
|
-
if (data === undefined) {
|
|
222
|
-
this.end();
|
|
223
|
-
return this;
|
|
224
|
-
}
|
|
225
|
-
if (isStream(data)) {
|
|
226
|
-
this.stream(data);
|
|
227
|
-
return this;
|
|
228
|
-
}
|
|
229
|
-
if (Buffer.isBuffer(data)) {
|
|
230
|
-
this.buffer(data);
|
|
231
|
-
return this;
|
|
232
|
-
}
|
|
233
|
-
if (isBoolean(data) || isNumber(data) || isString(data) || data === null) {
|
|
234
|
-
this.end(data);
|
|
235
|
-
return this;
|
|
236
|
-
}
|
|
237
|
-
this.json(data);
|
|
238
|
-
return this;
|
|
239
|
-
}
|
|
240
|
-
getBody() {
|
|
241
|
-
return this.data;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Add a listener to handler the end of the request/response.
|
|
245
|
-
* @param cb
|
|
246
|
-
*/
|
|
247
|
-
onEnd(cb) {
|
|
248
|
-
const res = this.getRes();
|
|
249
|
-
res.on("finish", cb);
|
|
250
|
-
return this;
|
|
251
|
-
}
|
|
252
|
-
isDone() {
|
|
253
|
-
if (this.$ctx.isFinished()) {
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
const res = this.getRes();
|
|
257
|
-
return Boolean(this.isHeadersSent() || res.writableEnded || res.writableFinished);
|
|
258
|
-
}
|
|
259
|
-
isHeadersSent() {
|
|
260
|
-
return this.getRes().headersSent;
|
|
261
|
-
}
|
|
262
|
-
cookie(name, value, opts) {
|
|
263
|
-
if (value === null) {
|
|
264
|
-
this.raw.clearCookie(name);
|
|
265
|
-
return this;
|
|
266
|
-
}
|
|
267
|
-
this.raw.cookie(name, value, opts);
|
|
268
|
-
const cookie = this.raw.get("set-cookie");
|
|
269
|
-
if (!isArray(value)) {
|
|
270
|
-
this.raw.set("set-cookie", [].concat(cookie));
|
|
271
|
-
}
|
|
272
|
-
return this;
|
|
273
|
-
}
|
|
274
|
-
formatHeader(key, item) {
|
|
275
|
-
if (key.toLowerCase() === "location") {
|
|
276
|
-
// "back" is an alias for the referrer
|
|
277
|
-
if (item === "back") {
|
|
278
|
-
item = this.request.get("Referrer") || "/";
|
|
279
|
-
}
|
|
280
|
-
item = encodeUrl(String(item));
|
|
281
|
-
}
|
|
282
|
-
return item;
|
|
283
|
-
}
|
|
284
|
-
json(data) {
|
|
285
|
-
this.raw.json(data);
|
|
286
|
-
return this;
|
|
287
|
-
}
|
|
288
|
-
buffer(data) {
|
|
289
|
-
if (!this.getContentType()) {
|
|
290
|
-
this.contentType("application/octet-stream");
|
|
291
|
-
}
|
|
292
|
-
this.contentLength(data.length);
|
|
293
|
-
this.end(data);
|
|
294
|
-
}
|
|
295
|
-
end(data) {
|
|
296
|
-
// data = await this.$ctx.injector.alter("$onResponse", data, this.$ctx);
|
|
297
|
-
this.raw.send(data);
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
PlatformResponse = __decorate([
|
|
301
|
-
Injectable(),
|
|
302
|
-
Scope(ProviderScope.INSTANCE),
|
|
303
|
-
__metadata("design:paramtypes", [Function])
|
|
304
|
-
], PlatformResponse);
|
|
305
|
-
export { PlatformResponse };
|
|
306
|
-
//# sourceMappingURL=PlatformResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformResponse.js","sourceRoot":"","sources":["../../../src/services/PlatformResponse.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAC,UAAU,EAAE,aA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ACtB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEpB,OAAO,IAAI,CAAC;IACd,CAAC;IAES,MAAM,CAAC,IAAS;QACxB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;YAC3B,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAES,GAAG,CAAC,IAAsB;QAClC,yEAAyE;QAEzE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;CACF,CAAA;AApWY,gBAAgB;IAF5B,UAAU,EAAE;IACZ,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC;;GACjB,gBAAgB,CAoW5B"}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { DITest } from "@tsed/di";
|
|
2
|
-
import accepts from "accepts";
|
|
3
|
-
import { PlatformBuilder } from "../builder/PlatformBuilder.js";
|
|
4
|
-
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
5
|
-
import { createInjector } from "../utils/createInjector.js";
|
|
6
|
-
import { getConfiguration } from "../utils/getConfiguration.js";
|
|
7
|
-
import { FakeResponse } from "./FakeResponse.js";
|
|
8
|
-
import { PlatformApplication } from "./PlatformApplication.js";
|
|
9
|
-
/**
|
|
10
|
-
* @platform
|
|
11
|
-
*/
|
|
12
|
-
export class PlatformTest extends DITest {
|
|
13
|
-
static async create(settings = {}) {
|
|
14
|
-
DITest.injector = PlatformTest.createInjector(getConfiguration(settings));
|
|
15
|
-
await DITest.createContainer();
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Create a new injector with the right default services
|
|
19
|
-
*/
|
|
20
|
-
static createInjector(settings = {}) {
|
|
21
|
-
return createInjector({
|
|
22
|
-
settings: DITest.configure({ httpPort: false, httpsPort: false, ...settings })
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Load the server silently without listening port and configure it on test profile.
|
|
27
|
-
* @decorator
|
|
28
|
-
* @param mod
|
|
29
|
-
* @param listen
|
|
30
|
-
* @param settings
|
|
31
|
-
* @returns {Promise<void>}
|
|
32
|
-
*/
|
|
33
|
-
static bootstrap(mod, { listen, ...settings } = {}) {
|
|
34
|
-
return async function before() {
|
|
35
|
-
let instance;
|
|
36
|
-
const adapter = settings.platform || settings.adapter || PlatformTest.adapter;
|
|
37
|
-
/* istanbul ignore next */
|
|
38
|
-
if (!adapter) {
|
|
39
|
-
throw new Error("Platform adapter is not specified. Have you added at least `import @tsed/platform-express` (or equivalent) on your Server.ts ?");
|
|
40
|
-
}
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
settings = DITest.configure(settings);
|
|
43
|
-
settings.adapter = adapter;
|
|
44
|
-
const configuration = getConfiguration(settings, mod);
|
|
45
|
-
const disableComponentsScan = configuration.disableComponentsScan || !!process.env.WEBPACK;
|
|
46
|
-
if (!disableComponentsScan) {
|
|
47
|
-
const { importProviders } = await import("@tsed/components-scan");
|
|
48
|
-
await importProviders(configuration);
|
|
49
|
-
}
|
|
50
|
-
instance = await PlatformBuilder.build(mod, configuration).bootstrap();
|
|
51
|
-
await instance.listen(!!listen);
|
|
52
|
-
// used by inject method
|
|
53
|
-
DITest.injector = instance.injector;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* It injects services into the test function where you can alter, spy on, and manipulate them.
|
|
58
|
-
*
|
|
59
|
-
* The inject function has two parameters
|
|
60
|
-
*
|
|
61
|
-
* * an array of Service dependency injection tokens,
|
|
62
|
-
* * a test function whose parameters correspond exactly to each item in the injection token array.
|
|
63
|
-
*
|
|
64
|
-
* @param targets
|
|
65
|
-
* @param func
|
|
66
|
-
*/
|
|
67
|
-
static inject(targets, func) {
|
|
68
|
-
return async () => {
|
|
69
|
-
if (!DITest.hasInjector()) {
|
|
70
|
-
await PlatformTest.create();
|
|
71
|
-
}
|
|
72
|
-
const injector = DITest.injector;
|
|
73
|
-
const deps = [];
|
|
74
|
-
for (const target of targets) {
|
|
75
|
-
deps.push(injector.has(target) ? injector.get(target) : await injector.invoke(target));
|
|
76
|
-
}
|
|
77
|
-
return func(...deps);
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Return the raw application (express or koa).
|
|
82
|
-
* Use this callback with SuperTest.
|
|
83
|
-
*
|
|
84
|
-
* ```typescript
|
|
85
|
-
* let request: SuperTest.Agent;
|
|
86
|
-
* beforeEach(PlatformTest.bootstrap(Server, {
|
|
87
|
-
* mount: {
|
|
88
|
-
* "/rest": [ProductsController]
|
|
89
|
-
* }
|
|
90
|
-
* }));
|
|
91
|
-
* beforeEach(() => {
|
|
92
|
-
* request = SuperTest(PlatformTest.callback());
|
|
93
|
-
* });
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
static callback() {
|
|
97
|
-
return DITest.injector.get(PlatformApplication)?.callback();
|
|
98
|
-
}
|
|
99
|
-
static createRequest(options = {}) {
|
|
100
|
-
return {
|
|
101
|
-
headers: {},
|
|
102
|
-
method: "GET",
|
|
103
|
-
url: "/",
|
|
104
|
-
query: {},
|
|
105
|
-
get(key) {
|
|
106
|
-
return this.headers[key.toLowerCase()];
|
|
107
|
-
},
|
|
108
|
-
accepts(mime) {
|
|
109
|
-
return accepts(this).types([].concat(mime));
|
|
110
|
-
},
|
|
111
|
-
...options
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
static createResponse(options = {}) {
|
|
115
|
-
return new FakeResponse(options);
|
|
116
|
-
}
|
|
117
|
-
static createRequestContext(options = {}) {
|
|
118
|
-
const event = {
|
|
119
|
-
...options.event,
|
|
120
|
-
request: options?.request?.request || options?.event?.request || PlatformTest.createRequest(),
|
|
121
|
-
response: options?.response?.response || options?.event?.response || PlatformTest.createResponse()
|
|
122
|
-
};
|
|
123
|
-
const $ctx = new PlatformContext({
|
|
124
|
-
id: "id",
|
|
125
|
-
injector: DITest.injector,
|
|
126
|
-
logger: DITest.injector.logger,
|
|
127
|
-
url: "/",
|
|
128
|
-
...options,
|
|
129
|
-
event
|
|
130
|
-
});
|
|
131
|
-
if (options.endpoint) {
|
|
132
|
-
$ctx.endpoint = options.endpoint;
|
|
133
|
-
}
|
|
134
|
-
return $ctx;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=PlatformTest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformTest.js","sourceRoot":"","sources":["../../../src/services/PlatformTest.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAkB,MAAM,UAAU,CAAC;AACjD,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAC,eAAe,EAAyB,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM;IAGtC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAwC,EAAE;QAC5D,MAAM,CAAC,QAAQ,GAAG,YAAY,CAAC,cAAc,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1E,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,WAAgB,EAAE;QACtC,OAAO,cAAc,CAAC;YACpB,QAAQ,EAAE,MAAM,CAA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AC,cAAc,CAAC,UAAe,EAAE;QACrC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,oBAAoB,CAAC,UAAiD,EAAE;QAC7E,MAAM,KAAK,GAAG;YACZ,GAAG,OAAO,CAAC,KAAK;YAChB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,YAAY,CAAC,aAAa,EAAE;YAC7F,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,IAAI,OAAO,EAAE,KAAK,EAAE,QAAQ,IAAI,YAAY,CAAC,cAAc,EAAE;SACnG,CAAC;QAEF,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC;YAC/B,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;YAC9B,GAAG,EAAE,GAAG;YACR,GAAG,OAAO;YACV,KAAK;SACN,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACnC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"closeServer.js","sourceRoot":"","sources":["../../../src/utils/closeServer.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,WAAW,CAAC,MAAsD;IAChF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { v4 } from "uuid";
|
|
2
|
-
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
3
|
-
import { PlatformRequest } from "../services/PlatformRequest.js";
|
|
4
|
-
import { PlatformResponse } from "../services/PlatformResponse.js";
|
|
5
|
-
function defaultReqIdBuilder(req) {
|
|
6
|
-
return req.get("x-request-id") || v4().split("-").join("");
|
|
7
|
-
}
|
|
8
|
-
function mapIgnoreUrlPatterns(ignoreUrlPatterns) {
|
|
9
|
-
return ignoreUrlPatterns.map((pattern) => (typeof pattern === "string" ? new RegExp(pattern, "gi") : pattern));
|
|
10
|
-
}
|
|
11
|
-
export function buildIgnoreLog(ignoreUrlPatterns) {
|
|
12
|
-
if (ignoreUrlPatterns) {
|
|
13
|
-
ignoreUrlPatterns = mapIgnoreUrlPatterns(ignoreUrlPatterns);
|
|
14
|
-
return (ignore, data, url) => ignoreUrlPatterns?.find((reg) => !!url.match(reg));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Create the TsED context to wrap request, response, injector, etc...
|
|
19
|
-
* @param injector
|
|
20
|
-
* @ignore
|
|
21
|
-
*/
|
|
22
|
-
export function createContext(injector) {
|
|
23
|
-
const ResponseKlass = injector.getProvider(PlatformResponse)?.useClass;
|
|
24
|
-
const RequestKlass = injector.getProvider(PlatformRequest)?.useClass;
|
|
25
|
-
const { reqIdBuilder = defaultReqIdBuilder, ...loggerOptions } = injector.settings.logger;
|
|
26
|
-
const opts = {
|
|
27
|
-
...loggerOptions,
|
|
28
|
-
logger: injector.logger,
|
|
29
|
-
injector,
|
|
30
|
-
ResponseKlass,
|
|
31
|
-
RequestKlass
|
|
32
|
-
};
|
|
33
|
-
const ignoreLog = buildIgnoreLog(loggerOptions.ignoreUrlPatterns);
|
|
34
|
-
return function invokeContext(event) {
|
|
35
|
-
const $ctx = new PlatformContext({
|
|
36
|
-
...opts,
|
|
37
|
-
event,
|
|
38
|
-
id: reqIdBuilder(event.request)
|
|
39
|
-
});
|
|
40
|
-
ignoreLog && $ctx.logger.alterIgnoreLog((ignore, data) => ignoreLog(ignore, data, $ctx.url));
|
|
41
|
-
return $ctx;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=createContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../src/utils/createContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAC,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAEjE,SAAS,mBAAmB,CAAC,GAAQ;IACnC,OAAO,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,oBAAoB,CAAC,iBAAwB;IACpD,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAwB,EAAE,EAAE,CAAC,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAClI,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,iBAAoC;IACjE,IAAI,iBAAiB,EAAE,CAAC;QACtB,iBAAiB,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QAC5D,OAAO,CAAC,MAAe,EAAE,IAAS,EAAE,GAAW,EAAE,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACzG,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAAyB;IACrD,MAAM,aAAa,GAAG,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC;IACvE,MAAM,YAAY,GAAG,QAAQ,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC;IACrE,MAAM,EAAC,YAAY,GAAG,mBAAmB,EAAE,GAAG,aAAa,EAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;IAExF,MAAM,IAAI,GAAG;QACX,GAAG,aAAa;QAChB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,QAAQ;QACR,aAAa;QACb,YAAY;KACb,CAAC;IAEF,MAAM,SAAS,GAAG,cAAc,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAElE,OAAO,SAAS,aAAa,CAAC,KAAoB;QAChD,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC;YAC/B,GAAG,IAAI;YACP,KAAK;YACL,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;SAChC,CAAC,CAAC;QAEH,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAE7F,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import Http from "http";
|
|
2
|
-
import { createServer } from "./createServer.js";
|
|
3
|
-
export function createHttpServer(injector, requestListener) {
|
|
4
|
-
const { settings } = injector;
|
|
5
|
-
const httpOptions = settings.get("httpOptions");
|
|
6
|
-
return createServer(injector, {
|
|
7
|
-
port: settings.get("httpPort"),
|
|
8
|
-
type: "http",
|
|
9
|
-
token: Http.Server,
|
|
10
|
-
server: () => Http.createServer(httpOptions, requestListener)
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=createHttpServer.js.map
|