@tsed/platform-http 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/.barrelsby.json +5 -0
- package/lib/esm/common/builder/PlatformBuilder.js +308 -0
- package/lib/esm/common/builder/PlatformBuilder.js.map +1 -0
- package/lib/esm/common/config/interfaces/PlatformJsonMapperSettings.js +2 -0
- package/lib/esm/common/config/interfaces/PlatformJsonMapperSettings.js.map +1 -0
- package/lib/esm/common/config/interfaces/PlatformMulterSettings.js +2 -0
- package/lib/esm/common/config/interfaces/PlatformMulterSettings.js.map +1 -0
- package/lib/esm/common/config/interfaces/PlatformRouterSettings.js +2 -0
- package/lib/esm/common/config/interfaces/PlatformRouterSettings.js.map +1 -0
- package/lib/esm/common/config/interfaces/PlatformStaticsSettings.js +2 -0
- package/lib/esm/common/config/interfaces/PlatformStaticsSettings.js.map +1 -0
- package/lib/esm/common/config/services/PlatformConfiguration.js +119 -0
- package/lib/esm/common/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/esm/common/constants/routerOptions.js +2 -0
- package/lib/esm/common/constants/routerOptions.js.map +1 -0
- package/lib/esm/common/decorators/PlatformProvider.js +7 -0
- package/lib/esm/common/decorators/PlatformProvider.js.map +1 -0
- package/lib/esm/common/decorators/multer/multerFileSize.js +32 -0
- package/lib/esm/common/decorators/multer/multerFileSize.js.map +1 -0
- package/lib/esm/common/decorators/multer/multerOptions.js +50 -0
- package/lib/esm/common/decorators/multer/multerOptions.js.map +1 -0
- package/lib/esm/common/decorators/multer/multipartFile.js +75 -0
- package/lib/esm/common/decorators/multer/multipartFile.js.map +1 -0
- package/lib/esm/common/decorators/params/error.js +16 -0
- package/lib/esm/common/decorators/params/error.js.map +1 -0
- package/lib/esm/common/decorators/params/next.js +17 -0
- package/lib/esm/common/decorators/params/next.js.map +1 -0
- package/lib/esm/common/decorators/params/request.js +34 -0
- package/lib/esm/common/decorators/params/request.js.map +1 -0
- package/lib/esm/common/decorators/params/response.js +28 -0
- package/lib/esm/common/decorators/params/response.js.map +1 -0
- package/lib/esm/common/domain/AnyToPromiseWithCtx.js +21 -0
- package/lib/esm/common/domain/AnyToPromiseWithCtx.js.map +1 -0
- package/lib/esm/common/domain/EndpointMetadata.js +2 -0
- package/lib/esm/common/domain/EndpointMetadata.js.map +1 -0
- package/lib/esm/common/domain/PlatformContext.js +69 -0
- package/lib/esm/common/domain/PlatformContext.js.map +1 -0
- package/lib/esm/common/domain/PlatformRouteDetails.js +2 -0
- package/lib/esm/common/domain/PlatformRouteDetails.js.map +1 -0
- package/lib/esm/common/exports.js +5 -0
- package/lib/esm/common/exports.js.map +1 -0
- package/lib/esm/common/index.js +61 -0
- package/lib/esm/common/index.js.map +1 -0
- package/lib/esm/common/interfaces/AfterInit.js +2 -0
- package/lib/esm/common/interfaces/AfterInit.js.map +1 -0
- package/lib/esm/common/interfaces/AfterListen.js +2 -0
- package/lib/esm/common/interfaces/AfterListen.js.map +1 -0
- package/lib/esm/common/interfaces/AfterRoutesInit.js +2 -0
- package/lib/esm/common/interfaces/AfterRoutesInit.js.map +1 -0
- package/lib/esm/common/interfaces/BeforeInit.js +2 -0
- package/lib/esm/common/interfaces/BeforeInit.js.map +1 -0
- package/lib/esm/common/interfaces/BeforeListen.js +2 -0
- package/lib/esm/common/interfaces/BeforeListen.js.map +1 -0
- package/lib/esm/common/interfaces/BeforeRoutesInit.js +2 -0
- package/lib/esm/common/interfaces/BeforeRoutesInit.js.map +1 -0
- package/lib/esm/common/interfaces/HandlerType.js +14 -0
- package/lib/esm/common/interfaces/HandlerType.js.map +1 -0
- package/lib/esm/common/interfaces/IncomingEvent.js +2 -0
- package/lib/esm/common/interfaces/IncomingEvent.js.map +1 -0
- package/lib/esm/common/interfaces/OnReady.js +2 -0
- package/lib/esm/common/interfaces/OnReady.js.map +1 -0
- package/lib/esm/common/interfaces/OnRequest.js +2 -0
- package/lib/esm/common/interfaces/OnRequest.js.map +1 -0
- package/lib/esm/common/interfaces/OnResponse.js +2 -0
- package/lib/esm/common/interfaces/OnResponse.js.map +1 -0
- package/lib/esm/common/interfaces/OnRoutesInit.js +2 -0
- package/lib/esm/common/interfaces/OnRoutesInit.js.map +1 -0
- package/lib/esm/common/interfaces/PlatformRouteOptions.js +2 -0
- package/lib/esm/common/interfaces/PlatformRouteOptions.js.map +1 -0
- package/lib/esm/common/interfaces/ResponseErrorObject.js +2 -0
- package/lib/esm/common/interfaces/ResponseErrorObject.js.map +1 -0
- package/lib/esm/common/interfaces/Route.js +2 -0
- package/lib/esm/common/interfaces/Route.js.map +1 -0
- package/lib/esm/common/middlewares/PlatformAcceptMimesMiddleware.js +36 -0
- package/lib/esm/common/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
- package/lib/esm/common/middlewares/PlatformMulterMiddleware.js +66 -0
- package/lib/esm/common/middlewares/PlatformMulterMiddleware.js.map +1 -0
- package/lib/esm/common/services/Platform.js +73 -0
- package/lib/esm/common/services/Platform.js.map +1 -0
- package/lib/esm/common/services/PlatformAdapter.js +77 -0
- package/lib/esm/common/services/PlatformAdapter.js.map +1 -0
- package/lib/esm/common/services/PlatformApplication.js +41 -0
- package/lib/esm/common/services/PlatformApplication.js.map +1 -0
- package/lib/esm/common/services/PlatformHandler.js +130 -0
- package/lib/esm/common/services/PlatformHandler.js.map +1 -0
- package/lib/esm/common/services/PlatformMiddlewaresChain.js +57 -0
- package/lib/esm/common/services/PlatformMiddlewaresChain.js.map +1 -0
- package/lib/esm/common/services/PlatformRequest.js +141 -0
- package/lib/esm/common/services/PlatformRequest.js.map +1 -0
- package/lib/esm/common/services/PlatformResponse.js +306 -0
- package/lib/esm/common/services/PlatformResponse.js.map +1 -0
- package/lib/esm/common/utils/closeServer.js +4 -0
- package/lib/esm/common/utils/closeServer.js.map +1 -0
- package/lib/esm/common/utils/createContext.js +44 -0
- package/lib/esm/common/utils/createContext.js.map +1 -0
- package/lib/esm/common/utils/createHttpServer.js +13 -0
- package/lib/esm/common/utils/createHttpServer.js.map +1 -0
- package/lib/esm/common/utils/createHttpsServer.js +13 -0
- package/lib/esm/common/utils/createHttpsServer.js.map +1 -0
- package/lib/esm/common/utils/createInjector.js +41 -0
- package/lib/esm/common/utils/createInjector.js.map +1 -0
- package/lib/esm/common/utils/createServer.js +29 -0
- package/lib/esm/common/utils/createServer.js.map +1 -0
- package/lib/esm/common/utils/ensureContext.js +12 -0
- package/lib/esm/common/utils/ensureContext.js.map +1 -0
- package/lib/esm/common/utils/getConfiguration.js +32 -0
- package/lib/esm/common/utils/getConfiguration.js.map +1 -0
- package/lib/esm/common/utils/getStaticsOptions.js +17 -0
- package/lib/esm/common/utils/getStaticsOptions.js.map +1 -0
- package/lib/esm/common/utils/listenServer.js +10 -0
- package/lib/esm/common/utils/listenServer.js.map +1 -0
- package/lib/esm/common/utils/mapReturnedResponse.js +11 -0
- package/lib/esm/common/utils/mapReturnedResponse.js.map +1 -0
- package/lib/esm/common/utils/printRoutes.js +34 -0
- package/lib/esm/common/utils/printRoutes.js.map +1 -0
- package/lib/esm/common/utils/registerPlatformAdapter.js +7 -0
- package/lib/esm/common/utils/registerPlatformAdapter.js.map +1 -0
- package/lib/esm/common/utils/setResponseHeaders.js +25 -0
- package/lib/esm/common/utils/setResponseHeaders.js.map +1 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/testing/FakeAdapter.js +2 -0
- package/lib/esm/testing/FakeAdapter.js.map +1 -0
- package/lib/esm/testing/FakeResponse.js +55 -0
- package/lib/esm/testing/FakeResponse.js.map +1 -0
- package/lib/esm/testing/PlatformTest.js +131 -0
- package/lib/esm/testing/PlatformTest.js.map +1 -0
- package/lib/esm/testing/index.js +6 -0
- package/lib/esm/testing/index.js.map +1 -0
- package/lib/types/common/builder/PlatformBuilder.d.ts +100 -0
- package/lib/types/common/config/interfaces/PlatformJsonMapperSettings.d.ts +10 -0
- package/lib/types/common/config/interfaces/PlatformMulterSettings.d.ts +14 -0
- package/lib/types/common/config/interfaces/PlatformRouterSettings.d.ts +10 -0
- package/lib/types/common/config/interfaces/PlatformStaticsSettings.d.ts +17 -0
- package/lib/types/common/config/services/PlatformConfiguration.d.ts +78 -0
- package/lib/types/common/constants/routerOptions.d.ts +1 -0
- package/lib/types/common/decorators/PlatformProvider.d.ts +3 -0
- package/lib/types/common/decorators/multer/multerFileSize.d.ts +28 -0
- package/lib/types/common/decorators/multer/multerOptions.d.ts +43 -0
- package/lib/types/common/decorators/multer/multipartFile.d.ts +48 -0
- package/lib/types/common/decorators/params/error.d.ts +7 -0
- package/lib/types/common/decorators/params/next.d.ts +22 -0
- package/lib/types/common/decorators/params/request.d.ts +46 -0
- package/lib/types/common/decorators/params/response.d.ts +40 -0
- package/lib/types/common/domain/AnyToPromiseWithCtx.d.ts +10 -0
- package/lib/types/common/domain/EndpointMetadata.d.ts +1 -0
- package/lib/types/common/domain/PlatformContext.d.ts +80 -0
- package/lib/types/common/domain/PlatformRouteDetails.d.ts +7 -0
- package/lib/types/common/exports.d.ts +4 -0
- package/lib/types/common/index.d.ts +60 -0
- package/lib/types/common/interfaces/AfterInit.d.ts +3 -0
- package/lib/types/common/interfaces/AfterListen.d.ts +3 -0
- package/lib/types/common/interfaces/AfterRoutesInit.d.ts +3 -0
- package/lib/types/common/interfaces/BeforeInit.d.ts +3 -0
- package/lib/types/common/interfaces/BeforeListen.d.ts +3 -0
- package/lib/types/common/interfaces/BeforeRoutesInit.d.ts +3 -0
- package/lib/types/common/interfaces/HandlerType.d.ts +12 -0
- package/lib/types/common/interfaces/IncomingEvent.d.ts +6 -0
- package/lib/types/common/interfaces/OnReady.d.ts +3 -0
- package/lib/types/common/interfaces/OnRequest.d.ts +4 -0
- package/lib/types/common/interfaces/OnResponse.d.ts +4 -0
- package/lib/types/common/interfaces/OnRoutesInit.d.ts +3 -0
- package/lib/types/common/interfaces/PlatformRouteOptions.d.ts +15 -0
- package/lib/types/common/interfaces/ResponseErrorObject.d.ts +8 -0
- package/lib/types/common/interfaces/Route.d.ts +10 -0
- package/lib/types/common/middlewares/PlatformAcceptMimesMiddleware.d.ts +10 -0
- package/lib/types/common/middlewares/PlatformMulterMiddleware.d.ts +24 -0
- package/lib/types/common/services/Platform.d.ts +25 -0
- package/lib/types/common/services/PlatformAdapter.d.ts +89 -0
- package/lib/types/common/services/PlatformApplication.d.ts +29 -0
- package/lib/types/common/services/PlatformHandler.d.ts +39 -0
- package/lib/types/common/services/PlatformMiddlewaresChain.d.ts +17 -0
- package/lib/types/common/services/PlatformRequest.d.ts +111 -0
- package/lib/types/common/services/PlatformResponse.d.ts +175 -0
- package/lib/types/common/utils/closeServer.d.ts +7 -0
- package/lib/types/common/utils/createContext.d.ts +10 -0
- package/lib/types/common/utils/createHttpServer.d.ts +4 -0
- package/lib/types/common/utils/createHttpsServer.d.ts +4 -0
- package/lib/types/common/utils/createInjector.d.ts +8 -0
- package/lib/types/common/utils/createServer.d.ts +17 -0
- package/lib/types/common/utils/ensureContext.d.ts +2 -0
- package/lib/types/common/utils/getConfiguration.d.ts +2 -0
- package/lib/types/common/utils/getStaticsOptions.d.ts +5 -0
- package/lib/types/common/utils/listenServer.d.ts +8 -0
- package/lib/types/common/utils/mapReturnedResponse.d.ts +4 -0
- package/lib/types/common/utils/printRoutes.d.ts +2 -0
- package/lib/types/common/utils/registerPlatformAdapter.d.ts +3 -0
- package/lib/types/common/utils/setResponseHeaders.d.ts +5 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/testing/FakeAdapter.d.ts +1 -0
- package/lib/types/testing/FakeResponse.d.ts +22 -0
- package/lib/types/testing/PlatformTest.d.ts +61 -0
- package/lib/types/testing/index.d.ts +5 -0
- package/package.json +111 -0
- package/readme.md +226 -0
- package/vitest.config.mts +21 -0
|
@@ -0,0 +1,306 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformResponse.js","sourceRoot":"","sources":["../../../../src/common/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,aAAa,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,SAAS,MAAM,WAAW,CAAC;AAyBlC;;;GAGG;AAGI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAG3B,YAAqB,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;IAAG,CAAC;IAE9C;;OAEG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AAI,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closeServer.js","sourceRoot":"","sources":["../../../../src/common/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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../../src/common/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,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AI,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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../../src/common/utils/createHttpServer.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,eAAqC;IAC/F,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAqB,aAAa,CAAC,CAAC;IAEpE,OAAO,YAAY,CAAC,QAAQ,EAAE;QAC5B,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC;QAC9B,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,IAAI,CAAC,MAAM;QAClB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,eAAe,CAAC;KAC9D,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Https from "https";
|
|
2
|
+
import { createServer } from "./createServer.js";
|
|
3
|
+
export function createHttpsServer(injector, requestListener) {
|
|
4
|
+
const { settings } = injector;
|
|
5
|
+
const httpsOptions = settings.get("httpsOptions");
|
|
6
|
+
return createServer(injector, {
|
|
7
|
+
type: "https",
|
|
8
|
+
token: Https.Server,
|
|
9
|
+
port: settings.get("httpsPort"),
|
|
10
|
+
server: () => Https.createServer(httpsOptions, requestListener)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=createHttpsServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../../src/common/utils/createHttpsServer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C,MAAM,UAAU,iBAAiB,CAAC,QAAyB,EAAE,eAAsC;IACjG,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAElD,OAAO,YAAY,CAAC,QAAQ,EAAE;QAC5B,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC;QAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,eAAe,CAAC;KAChE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { toMap } from "@tsed/core";
|
|
2
|
+
import { injector, setLoggerConfiguration } from "@tsed/di";
|
|
3
|
+
import { $log } from "@tsed/logger";
|
|
4
|
+
import { PlatformConfiguration } from "../config/services/PlatformConfiguration.js";
|
|
5
|
+
import { Platform } from "../services/Platform.js";
|
|
6
|
+
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
7
|
+
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
8
|
+
import { PlatformHandler } from "../services/PlatformHandler.js";
|
|
9
|
+
import { PlatformRequest } from "../services/PlatformRequest.js";
|
|
10
|
+
import { PlatformResponse } from "../services/PlatformResponse.js";
|
|
11
|
+
$log.name = "TSED";
|
|
12
|
+
const DEFAULT_PROVIDERS = [
|
|
13
|
+
{ provide: PlatformHandler },
|
|
14
|
+
{ provide: PlatformResponse },
|
|
15
|
+
{ provide: PlatformRequest },
|
|
16
|
+
{ provide: PlatformApplication },
|
|
17
|
+
{ provide: Platform }
|
|
18
|
+
];
|
|
19
|
+
export function createInjector({ adapter, settings = {} }) {
|
|
20
|
+
const inj = injector();
|
|
21
|
+
inj.addProvider(PlatformConfiguration);
|
|
22
|
+
inj.settings = inj.invoke(PlatformConfiguration);
|
|
23
|
+
inj.logger = $log;
|
|
24
|
+
inj.settings.set(settings);
|
|
25
|
+
if (adapter) {
|
|
26
|
+
inj.addProvider(PlatformAdapter, {
|
|
27
|
+
useClass: adapter
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
inj.invoke(PlatformAdapter);
|
|
31
|
+
inj.alias(PlatformAdapter, "PlatformAdapter");
|
|
32
|
+
setLoggerConfiguration(inj);
|
|
33
|
+
const instance = inj.get(PlatformAdapter);
|
|
34
|
+
instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];
|
|
35
|
+
toMap(instance.providers, "provide").forEach((provider, token) => {
|
|
36
|
+
inj.addProvider(token, provider);
|
|
37
|
+
});
|
|
38
|
+
inj.invoke(PlatformApplication);
|
|
39
|
+
return inj;
|
|
40
|
+
}
|
|
41
|
+
//# source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AC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE3B,IAAI,OAAO,EAAE,CAAC;QACZ,GAAG,CAAC,WAAW,CAAC,eAAe,EAAE;YAC/B,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC5B,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;IAE9C,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAE5B,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAkB,eAAe,CAAE,CAAC;IAE5D,QAAQ,CAAC,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEnE,KAAK,CAAoB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAClF,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAEhC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getHostInfoFromPort } from "@tsed/core";
|
|
2
|
+
import { ProviderScope } from "@tsed/di";
|
|
3
|
+
import { listenServer } from "./listenServer.js";
|
|
4
|
+
export function createServer(injector, { token, type, port, server: get, listen }) {
|
|
5
|
+
const { settings } = injector;
|
|
6
|
+
const server = port !== false ? get() : null;
|
|
7
|
+
injector.addProvider(token, {
|
|
8
|
+
scope: ProviderScope.SINGLETON,
|
|
9
|
+
useValue: server
|
|
10
|
+
});
|
|
11
|
+
injector.invoke(token);
|
|
12
|
+
if (server) {
|
|
13
|
+
const hostInfo = getHostInfoFromPort(type, port);
|
|
14
|
+
return async () => {
|
|
15
|
+
const url = `${hostInfo.protocol}://${hostInfo.address}:${port}`;
|
|
16
|
+
injector.logger.debug(`Start server on ${url}`);
|
|
17
|
+
await (listen ? listen(hostInfo) : listenServer(server, hostInfo));
|
|
18
|
+
const address = server.address();
|
|
19
|
+
if (address && typeof address !== "string") {
|
|
20
|
+
hostInfo.address = address.address;
|
|
21
|
+
hostInfo.port = address.port;
|
|
22
|
+
}
|
|
23
|
+
injector.logger.info(`Listen server on ${hostInfo.toString()}`);
|
|
24
|
+
settings.set(`${type}Port`, `${hostInfo.address}:${hostInfo.port}`);
|
|
25
|
+
return server;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=createServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createServer.js","sourceRoot":"","sources":["../../../../src/common/utils/createServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAyB,MAAM,YAAY,CAAC;AACvE,OAAO,EAAkB,aAAa,EAAgB,MAAM,UAAU,CAAC;AAKvE,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAY/C,MAAM,UAAU,YAAY,CAC1B,QAAyB,EACzB,EAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAsB;IAE7D,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAE7C,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE;QAC1B,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEvB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEjD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC,QAAQ,MAAM,QAAQ,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;YACjE,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC;YAEhD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;YAEnE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;YAEjC,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAC3C,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;gBACnC,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAC/B,CAAC;YAED,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAChE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAEpE,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getContext } from "@tsed/di";
|
|
2
|
+
export function ensureContext(request, cb, fallback) {
|
|
3
|
+
const $ctx = getContext();
|
|
4
|
+
if ($ctx) {
|
|
5
|
+
return cb($ctx);
|
|
6
|
+
}
|
|
7
|
+
if (!request?.$ctx && fallback) {
|
|
8
|
+
return fallback();
|
|
9
|
+
}
|
|
10
|
+
return request.$ctx.runInContext(() => cb(request.$ctx));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ensureContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureContext.js","sourceRoot":"","sources":["../../../../src/common/utils/ensureContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAIpC,MAAM,UAAU,aAAa,CAAC,OAAY,EAAE,EAAkC,EAAE,QAAqB;IACnG,MAAM,IAAI,GAAG,UAAU,EAAmB,CAAC;IAE3C,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC/B,OAAO,QAAQ,EAAE,CAAC;IACpB,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Env, Store } from "@tsed/core";
|
|
2
|
+
import { mergeMount, ProviderScope, ProviderType } from "@tsed/di";
|
|
3
|
+
export function getConfiguration(configuration = {}, module = null) {
|
|
4
|
+
if (configuration.$$resolved) {
|
|
5
|
+
return configuration;
|
|
6
|
+
}
|
|
7
|
+
const store = module ? Store.from(module).get("configuration") || {} : {};
|
|
8
|
+
const env = configuration.env || store.env || process.env.NODE_ENV || Env.DEV;
|
|
9
|
+
return {
|
|
10
|
+
$$resolved: true,
|
|
11
|
+
env,
|
|
12
|
+
httpPort: 8080,
|
|
13
|
+
httpsPort: false,
|
|
14
|
+
...store,
|
|
15
|
+
...configuration,
|
|
16
|
+
scopes: {
|
|
17
|
+
[ProviderType.CONTROLLER]: ProviderScope.SINGLETON,
|
|
18
|
+
...store.scopes,
|
|
19
|
+
...configuration.scopes
|
|
20
|
+
},
|
|
21
|
+
mount: mergeMount(store.mount, configuration.mount),
|
|
22
|
+
logger: {
|
|
23
|
+
debug: false,
|
|
24
|
+
level: env === Env.TEST ? "off" : "info",
|
|
25
|
+
logRequest: true,
|
|
26
|
+
...store.logger,
|
|
27
|
+
...configuration.logger,
|
|
28
|
+
jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=getConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../../src/common/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAEjE,MAAM,UAAU,gBAAgB,CAAC,gBAAqB,EAAE,EAAE,SAA2B,IAAI;IACvF,IAAI,aAAa,CAAC,UAAU,EAAE,CAAC;QAC7B,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAK,OAAO,CAAC,GAAG,CAAC,QAAgB,IAAI,GAAG,CAAC,GAAG,CAAC;IAEvF,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,GAAG,KAAK;QACR,GAAG,aAAa;QAChB,MAAM,EAAE;YACN,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS;YAClD,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;SACxB;QACD,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC;QACnD,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACxC,UAAU,EAAE,IAAI;YAChB,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;YACvB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getValue } from "@tsed/core";
|
|
2
|
+
function mapOptions(options) {
|
|
3
|
+
const opts = typeof options === "string" ? { root: options } : options;
|
|
4
|
+
return {
|
|
5
|
+
...opts,
|
|
6
|
+
hook: getValue(opts, "hook", "$afterRoutesInit")
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function getStaticsOptions(statics) {
|
|
10
|
+
return Object.entries(statics || {}).reduce((statics, [path, items]) => {
|
|
11
|
+
[].concat(items).forEach((options) => {
|
|
12
|
+
statics.push({ path, options: mapOptions(options) });
|
|
13
|
+
});
|
|
14
|
+
return statics;
|
|
15
|
+
}, []);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=getStaticsOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStaticsOptions.js","sourceRoot":"","sources":["../../../../src/common/utils/getStaticsOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAIpC,SAAS,UAAU,CAAC,OAAY;IAC9B,MAAM,IAAI,GAA2B,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7F,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,CAAC;KACjD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAiC;IACjE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CACzC,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QACzB,EAAE,CAAC,MAAM,CAAC,KAAY,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1C,OAAO,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC,EACD,EAAuD,CACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function listenServer(server, hostInfo) {
|
|
2
|
+
const { address, port } = hostInfo;
|
|
3
|
+
const promise = new Promise((resolve, reject) => {
|
|
4
|
+
server.on("listening", resolve);
|
|
5
|
+
server.on("error", reject);
|
|
6
|
+
});
|
|
7
|
+
server.listen(port, address);
|
|
8
|
+
return promise;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=listenServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listenServer.js","sourceRoot":"","sources":["../../../../src/common/utils/listenServer.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,YAAY,CAAC,MAAsD,EAAE,QAAgD;IACnI,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC;IAEjC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAc,CAAC,CAAC;IAEpC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ignore
|
|
3
|
+
*/
|
|
4
|
+
export function mapReturnedResponse({ use, collection, ...options }) {
|
|
5
|
+
return {
|
|
6
|
+
...options,
|
|
7
|
+
type: options.type || use,
|
|
8
|
+
collectionType: options.collectionType || collection
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=mapReturnedResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapReturnedResponse.js","sourceRoot":"","sources":["../../../../src/common/utils/mapReturnedResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAC,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,EAAM;IACpE,OAAO;QACL,GAAG,OAAO;QACV,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,GAAG;QACzB,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,UAAU;KACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { $log, colorize } from "@tsed/logger";
|
|
2
|
+
export function printRoutes(routes) {
|
|
3
|
+
const mapColor = {
|
|
4
|
+
GET: "green",
|
|
5
|
+
POST: "yellow",
|
|
6
|
+
PUT: "blue",
|
|
7
|
+
DELETE: "red",
|
|
8
|
+
PATCH: "magenta",
|
|
9
|
+
ALL: "cyan",
|
|
10
|
+
STATICS: "white"
|
|
11
|
+
};
|
|
12
|
+
const list = routes.map((route) => {
|
|
13
|
+
const method = route.method.toUpperCase();
|
|
14
|
+
return {
|
|
15
|
+
...route,
|
|
16
|
+
method: {
|
|
17
|
+
length: method.length,
|
|
18
|
+
toString: () => {
|
|
19
|
+
return colorize(method, mapColor[method]);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
const str = $log.drawTable(list, {
|
|
25
|
+
padding: 1,
|
|
26
|
+
header: {
|
|
27
|
+
method: "Method",
|
|
28
|
+
url: "Endpoint",
|
|
29
|
+
name: "Class method"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return "\n" + str.trim();
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=printRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printRoutes.js","sourceRoot":"","sources":["../../../../src/common/utils/printRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAI5C,MAAM,UAAU,WAAW,CAAC,MAA8B;IACxD,MAAM,QAAQ,GAA4B;QACxC,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,MAAM;QACX,OAAO,EAAE,OAAO;KACjB,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAE1C,OAAO;YACL,GAAG,KAAK;YACR,MAAM,EAAE;gBACN,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,QAAQ,EAAE,GAAG,EAAE;oBACb,OAAO,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC5C,CAAC;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QAC/B,OAAO,EAAE,CAAC;QACV,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,cAAc;SACrB;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PlatformTest } from "../../testing/PlatformTest.js";
|
|
2
|
+
import { PlatformBuilder } from "../builder/PlatformBuilder.js";
|
|
3
|
+
export function registerPlatformAdapter(adapter) {
|
|
4
|
+
PlatformTest.adapter = adapter;
|
|
5
|
+
PlatformBuilder.adapter = adapter;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=registerPlatformAdapter.js.map
|