@tstdl/base 0.70.22 → 0.70.25
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/api/client.js +4 -1
- package/api/client.js.map +1 -1
- package/api/gateway.d.ts +1 -2
- package/api/gateway.js +53 -9
- package/api/gateway.js.map +1 -1
- package/api/index.d.ts +1 -0
- package/api/index.js +1 -0
- package/api/index.js.map +1 -1
- package/api/middlewares/index.d.ts +0 -1
- package/api/middlewares/index.js +0 -1
- package/api/middlewares/index.js.map +1 -1
- package/api/module.d.ts +5 -0
- package/api/module.js +10 -0
- package/api/module.js.map +1 -0
- package/http/client/http-client-request.d.ts +3 -1
- package/http/client/http-client-request.js +5 -4
- package/http/client/http-client-request.js.map +1 -1
- package/http/cookie-parser.d.ts +9 -0
- package/http/cookie-parser.js +34 -0
- package/http/cookie-parser.js.map +1 -0
- package/http/index.d.ts +1 -0
- package/http/index.js +1 -0
- package/http/index.js.map +1 -1
- package/http/server/http-server-request.d.ts +2 -0
- package/http/server/http-server-request.js +2 -0
- package/http/server/http-server-request.js.map +1 -1
- package/module/modules/web-server.module.d.ts +9 -4
- package/module/modules/web-server.module.js +19 -2
- package/module/modules/web-server.module.js.map +1 -1
- package/package.json +4 -4
- package/api/middlewares/error-catch.middleware.d.ts +0 -4
- package/api/middlewares/error-catch.middleware.js +0 -43
- package/api/middlewares/error-catch.middleware.js.map +0 -1
package/api/client.js
CHANGED
package/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../source/api/client.ts"],"names":[],"mappings":";;;AAAA,kCAAoD;AAEpD,2CAAkD;AAElD,sCAA0G;AAE1G,0CAAwC;AACxC,oDAA8D;AAC9D,sDAA0D;AAE1D,mCAAuC;AAW1B,QAAA,gBAAgB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAC1C,QAAA,mBAAmB,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;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AC;QAER,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE;YACzC,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,mBAAmB;SAC3B,CAAC,CAAC;KACJ;IAED,OAAO,GAA8B,CAAC;AACxC,CAAC;AAtED,sCAsEC;AAED,KAAK,UAAU,OAAO,CAAC,QAA4B,EAAE,MAA+C;IAClG,IAAI,IAAA,yBAAW,EAAC,MAAM,CAAC,EAAE;QACvB,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC"}
|
package/api/gateway.d.ts
CHANGED
|
@@ -42,8 +42,7 @@ export declare class ApiGateway implements Injectable<ApiGatewayOptions> {
|
|
|
42
42
|
private readonly prefix;
|
|
43
43
|
private readonly apis;
|
|
44
44
|
private readonly middlewares;
|
|
45
|
-
private readonly
|
|
46
|
-
private readonly errorCatchMiddleware;
|
|
45
|
+
private readonly supressedErrors;
|
|
47
46
|
private handler;
|
|
48
47
|
readonly [resolveArgumentType]: ApiGatewayOptions;
|
|
49
48
|
constructor(logger: Logger, options?: ApiGatewayOptions);
|
package/api/gateway.js
CHANGED
|
@@ -26,6 +26,7 @@ const object_1 = require("../utils/object");
|
|
|
26
26
|
const type_guards_1 = require("../utils/type-guards");
|
|
27
27
|
const api_controller_1 = require("./api-controller");
|
|
28
28
|
const middlewares_1 = require("./middlewares");
|
|
29
|
+
const response_1 = require("./response");
|
|
29
30
|
const types_1 = require("./types");
|
|
30
31
|
const UrlPattern = object_1.ForwardRef.create();
|
|
31
32
|
// eslint-disable-next-line no-eval
|
|
@@ -41,8 +42,7 @@ let ApiGateway = ApiGateway_1 = class ApiGateway {
|
|
|
41
42
|
this.prefix = (_a = options === null || options === void 0 ? void 0 : options.prefix) !== null && _a !== void 0 ? _a : 'api/';
|
|
42
43
|
this.apis = new Map();
|
|
43
44
|
this.middlewares = [];
|
|
44
|
-
this.
|
|
45
|
-
this.errorCatchMiddleware = (0, middlewares_1.errorCatchMiddleware)(logger, this.supressedErrorLogs);
|
|
45
|
+
this.supressedErrors = new Set();
|
|
46
46
|
this.updateMiddleware();
|
|
47
47
|
}
|
|
48
48
|
addMiddleware(middleware) {
|
|
@@ -51,7 +51,7 @@ let ApiGateway = ApiGateway_1 = class ApiGateway {
|
|
|
51
51
|
}
|
|
52
52
|
supressErrors(...errorTypes) {
|
|
53
53
|
for (const type of errorTypes) {
|
|
54
|
-
this.
|
|
54
|
+
this.supressedErrors.add(type);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
async registerApiController(controller) {
|
|
@@ -69,10 +69,23 @@ let ApiGateway = ApiGateway_1 = class ApiGateway {
|
|
|
69
69
|
const resource = (endpointDefinition.resource == types_1.rootResource) ? `${this.prefix}${versionPrefix}${base}` : `${this.prefix}${versionPrefix}${base}/${(_a = endpointDefinition.resource) !== null && _a !== void 0 ? _a : name}`;
|
|
70
70
|
const method = (_b = endpointDefinition.method) !== null && _b !== void 0 ? _b : 'GET';
|
|
71
71
|
let resourceApis = this.apis.get(resource);
|
|
72
|
+
console.log(resource);
|
|
72
73
|
if ((0, type_guards_1.isUndefined)(resourceApis)) {
|
|
73
74
|
resourceApis = (0, object_1.lazyObject)({
|
|
74
75
|
resource: { value: resource },
|
|
75
|
-
pattern: {
|
|
76
|
+
pattern: {
|
|
77
|
+
initializer: () => new UrlPattern({
|
|
78
|
+
pathname: resource,
|
|
79
|
+
baseURL: 'http://localhost',
|
|
80
|
+
username: '*',
|
|
81
|
+
password: '*',
|
|
82
|
+
protocol: '*',
|
|
83
|
+
hostname: '*',
|
|
84
|
+
port: '*',
|
|
85
|
+
search: '*',
|
|
86
|
+
hash: '*'
|
|
87
|
+
})
|
|
88
|
+
},
|
|
76
89
|
endpoints: { value: new Map() }
|
|
77
90
|
});
|
|
78
91
|
this.apis.set(resource, resourceApis);
|
|
@@ -83,14 +96,19 @@ let ApiGateway = ApiGateway_1 = class ApiGateway {
|
|
|
83
96
|
}
|
|
84
97
|
}
|
|
85
98
|
async handleHttpServerRequestContext({ request, respond }) {
|
|
86
|
-
const { api, patternResult } = this.getApiMetadata(request.url);
|
|
87
|
-
const endpoint = api.endpoints.get(request.method);
|
|
88
|
-
const response = await this.handler(request, { api, resourcePatternResult: patternResult, endpoint });
|
|
89
99
|
try {
|
|
100
|
+
const { api, patternResult } = this.getApiMetadata(request.url);
|
|
101
|
+
const endpoint = api.endpoints.get(request.method);
|
|
102
|
+
const response = await this.handler(request, { api, resourcePatternResult: patternResult, endpoint });
|
|
90
103
|
await respond(response);
|
|
91
104
|
}
|
|
92
105
|
catch (error) {
|
|
93
106
|
this.logger.error(error, { includeRest: false, includeStack: false });
|
|
107
|
+
try {
|
|
108
|
+
const response = handleApiError(error, this.supressedErrors, this.logger);
|
|
109
|
+
await respond(response);
|
|
110
|
+
}
|
|
111
|
+
catch ( /* ignore */_a) { /* ignore */ }
|
|
94
112
|
}
|
|
95
113
|
}
|
|
96
114
|
getApiMetadata(resource) {
|
|
@@ -103,10 +121,10 @@ let ApiGateway = ApiGateway_1 = class ApiGateway {
|
|
|
103
121
|
}
|
|
104
122
|
return { api, patternResult: result };
|
|
105
123
|
}
|
|
106
|
-
throw new error_1.NotFoundError(`resource ${resource.
|
|
124
|
+
throw new error_1.NotFoundError(`resource ${resource.pathname} not available`);
|
|
107
125
|
}
|
|
108
126
|
updateMiddleware() {
|
|
109
|
-
const middlewares = [
|
|
127
|
+
const middlewares = [middlewares_1.responseTimeMiddleware, middlewares_1.corsMiddleware, middlewares_1.allowedMethodsMiddleware, ...this.middlewares];
|
|
110
128
|
this.handler = (0, middleware_1.composeAsyncMiddleware)(middlewares, async (request, context) => this.middlewareHandler(request, context));
|
|
111
129
|
}
|
|
112
130
|
async middlewareHandler(request, context) {
|
|
@@ -156,4 +174,30 @@ ApiGateway = ApiGateway_1 = __decorate([
|
|
|
156
174
|
__metadata("design:paramtypes", [logger_1.Logger, Object])
|
|
157
175
|
], ApiGateway);
|
|
158
176
|
exports.ApiGateway = ApiGateway;
|
|
177
|
+
function handleApiError(error, supressedErrors, logger) {
|
|
178
|
+
logger.error(error, { includeRest: false, includeStack: false });
|
|
179
|
+
const response = new server_1.HttpServerResponse();
|
|
180
|
+
if (error instanceof Error) {
|
|
181
|
+
const errorConstructor = error.constructor;
|
|
182
|
+
const supressed = supressedErrors.has(errorConstructor);
|
|
183
|
+
if (!supressed) {
|
|
184
|
+
logger.error(error);
|
|
185
|
+
}
|
|
186
|
+
if ((0, response_1.hasErrorHandler)(errorConstructor)) {
|
|
187
|
+
response.statusCode = (0, response_1.getErrorStatusCode)(error);
|
|
188
|
+
response.body = { json: (0, response_1.createErrorResponse)(error) };
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
response.statusCode = 500;
|
|
192
|
+
response.body = { json: (0, response_1.createErrorResponse)('500', 'Internal Server Error') };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const formattedError = (0, helpers_1.formatError)(error, { includeStack: true, includeRest: true, handleBuiltInErrors: true });
|
|
197
|
+
logger.error(formattedError);
|
|
198
|
+
response.statusCode = 500;
|
|
199
|
+
response.body = { json: (0, response_1.createErrorResponse)('500', 'Internal Server Error') };
|
|
200
|
+
}
|
|
201
|
+
return response;
|
|
202
|
+
}
|
|
159
203
|
//# sourceMappingURL=gateway.js.map
|
package/api/gateway.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../source/api/gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,4CAA+F;
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../source/api/gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,4CAA+F;AAE/F,oCAA8E;AAE9E,2CAAmD;AAGnD,sCAAkC;AACl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AAC,KAAK,EAAE,uBAAuB,CAAC,EAAE,CAAC;KAC/E;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/api/index.d.ts
CHANGED
package/api/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./api-controller"), exports);
|
|
|
18
18
|
__exportStar(require("./client"), exports);
|
|
19
19
|
__exportStar(require("./default-error-handlers"), exports);
|
|
20
20
|
__exportStar(require("./gateway"), exports);
|
|
21
|
+
__exportStar(require("./module"), exports);
|
|
21
22
|
__exportStar(require("./response"), exports);
|
|
22
23
|
__exportStar(require("./types"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
package/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,2CAAyB;AACzB,2DAAyC;AACzC,4CAA0B;AAC1B,6CAA2B;AAC3B,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,2CAAyB;AACzB,2DAAyC;AACzC,4CAA0B;AAC1B,2CAAyB;AACzB,6CAA2B;AAC3B,0CAAwB"}
|
package/api/middlewares/index.js
CHANGED
|
@@ -16,6 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./allowed-methods.middleware"), exports);
|
|
18
18
|
__exportStar(require("./cors.middleware"), exports);
|
|
19
|
-
__exportStar(require("./error-catch.middleware"), exports);
|
|
20
19
|
__exportStar(require("./response-time.middleware"), exports);
|
|
21
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/api/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,oDAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/api/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,oDAAkC;AAClC,6DAA2C"}
|
package/api/module.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Type } from "../types";
|
|
2
|
+
import type { ApiController } from './api-controller';
|
|
3
|
+
export declare type ApiControllers = Type<ApiController>[];
|
|
4
|
+
export declare const API_CONTROLLERS: import("../container").InjectionToken<ApiControllers, any>;
|
|
5
|
+
export declare function registerApiControllers(...controllers: (Type<ApiController> | Type<ApiController>[])[]): void;
|
package/api/module.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerApiControllers = exports.API_CONTROLLERS = void 0;
|
|
4
|
+
const container_1 = require("../container");
|
|
5
|
+
exports.API_CONTROLLERS = (0, container_1.injectionToken)('API_CONTROLLERS');
|
|
6
|
+
function registerApiControllers(...controllers) {
|
|
7
|
+
container_1.container.register(exports.API_CONTROLLERS, { useValue: controllers.flatMap((controller) => controller) });
|
|
8
|
+
}
|
|
9
|
+
exports.registerApiControllers = registerApiControllers;
|
|
10
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../source/api/module.ts"],"names":[],"mappings":";;;AAAA,4CAAwD;AAM3C,QAAA,eAAe,GAAG,IAAA,0BAAc,EAAiB,iBAAiB,CAAC,CAAC;AAEjF,SAAgB,sBAAsB,CAAC,GAAG,WAA4D;IACpG,qBAAS,CAAC,QAAQ,CAAC,uBAAe,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AACrG,CAAC;AAFD,wDAEC"}
|
|
@@ -94,6 +94,7 @@ export declare type HttpClientRequestObject<T extends HttpBodyType = HttpBodyTyp
|
|
|
94
94
|
url: string;
|
|
95
95
|
method?: HttpMethod;
|
|
96
96
|
};
|
|
97
|
+
export declare type CredentialsOptions = 'omit' | 'same-origin' | 'include';
|
|
97
98
|
export declare class HttpClientRequest<T extends HttpBodyType = HttpBodyType> implements HttpClientRequestDocs, Disposable {
|
|
98
99
|
private readonly _abortToken;
|
|
99
100
|
url: string;
|
|
@@ -108,11 +109,12 @@ export declare class HttpClientRequest<T extends HttpBodyType = HttpBodyType> im
|
|
|
108
109
|
query: HttpQuery;
|
|
109
110
|
body: HttpRequestBody;
|
|
110
111
|
responseType: T;
|
|
112
|
+
credentials: CredentialsOptions;
|
|
111
113
|
timeout: number;
|
|
112
114
|
context: StringMap;
|
|
113
115
|
get abortToken(): ReadonlyCancellationToken;
|
|
114
116
|
constructor(url: string, method?: HttpMethod, options?: HttpClientRequestOptions<T>);
|
|
115
|
-
constructor(
|
|
117
|
+
constructor(requestObject: HttpClientRequestObject<T>);
|
|
116
118
|
[dispose](): void;
|
|
117
119
|
/** abort the request */
|
|
118
120
|
abort(): void;
|
|
@@ -10,7 +10,7 @@ const http_query_1 = require("../http-query");
|
|
|
10
10
|
const http_url_parameters_1 = require("../http-url-parameters");
|
|
11
11
|
class HttpClientRequest {
|
|
12
12
|
constructor(urlOrObject, method, options) {
|
|
13
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
14
14
|
if ((0, type_guards_1.isString)(urlOrObject)) {
|
|
15
15
|
this.url = urlOrObject;
|
|
16
16
|
this.method = method !== null && method !== void 0 ? method : 'GET';
|
|
@@ -30,9 +30,10 @@ class HttpClientRequest {
|
|
|
30
30
|
this.query = new http_query_1.HttpQuery(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.query);
|
|
31
31
|
this.body = normalizeBody(requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.body);
|
|
32
32
|
this.responseType = (_f = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.responseType) !== null && _f !== void 0 ? _f : 'auto';
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
33
|
+
this.credentials = (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.credentials) !== null && _g !== void 0 ? _g : 'omit';
|
|
34
|
+
this.timeout = (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeout) !== null && _h !== void 0 ? _h : 30000;
|
|
35
|
+
this.context = (_j = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.context) !== null && _j !== void 0 ? _j : {};
|
|
36
|
+
this._abortToken = (_l = (_k = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortToken) === null || _k === void 0 ? void 0 : _k.createChild()) !== null && _l !== void 0 ? _l : new cancellation_token_1.CancellationToken();
|
|
36
37
|
}
|
|
37
38
|
get abortToken() {
|
|
38
39
|
return this._abortToken.asReadonly;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client-request.js","sourceRoot":"","sources":["../../../source/http/client/http-client-request.ts"],"names":[],"mappings":";;;AACA,iDAAuC;AAGvC,uEAA+D;AAC/D,yDAAuE;AAEvE,4CAAwC;AAExC,kDAA8C;AAE9C,8CAA0C;AAE1C,gEAA2D;
|
|
1
|
+
{"version":3,"file":"http-client-request.js","sourceRoot":"","sources":["../../../source/http/client/http-client-request.ts"],"names":[],"mappings":";;;AACA,iDAAuC;AAGvC,uEAA+D;AAC/D,yDAAuE;AAEvE,4CAAwC;AAExC,kDAA8C;AAE9C,8CAA0C;AAE1C,gEAA2D;AAkG3D,MAAa,iBAAiB;IAyB5B,YAAY,WAAgD,EAAE,MAAmB,EAAE,OAAqC;;QACtH,IAAI,IAAA,sBAAQ,EAAC,WAAW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HttpHeaders } from './http-headers';
|
|
2
|
+
export declare class CookieParser {
|
|
3
|
+
private readonly httpHeaders;
|
|
4
|
+
private readonly cookies;
|
|
5
|
+
constructor(httpHeaders: HttpHeaders);
|
|
6
|
+
has(name: string): boolean;
|
|
7
|
+
get(name: string): string | undefined;
|
|
8
|
+
private parseCookies;
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CookieParser = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const object_1 = require("../utils/object");
|
|
6
|
+
class CookieParser {
|
|
7
|
+
constructor(httpHeaders) {
|
|
8
|
+
this.httpHeaders = httpHeaders;
|
|
9
|
+
(0, object_1.lazyProperty)(this, 'cookies', () => this.parseCookies());
|
|
10
|
+
}
|
|
11
|
+
has(name) {
|
|
12
|
+
return this.cookies.has(name);
|
|
13
|
+
}
|
|
14
|
+
get(name) {
|
|
15
|
+
return this.cookies.get(name);
|
|
16
|
+
}
|
|
17
|
+
parseCookies() {
|
|
18
|
+
const cookie = this.httpHeaders.tryGetSingle('Cookie');
|
|
19
|
+
if ((0, utils_1.isUndefined)(cookie)) {
|
|
20
|
+
return new Map();
|
|
21
|
+
}
|
|
22
|
+
const entries = cookie.split(';')
|
|
23
|
+
.map((value) => value.trim())
|
|
24
|
+
.map((value) => {
|
|
25
|
+
const equalsIndex = value.indexOf('=');
|
|
26
|
+
const name = value.slice(0, equalsIndex);
|
|
27
|
+
const cookieValue = value.slice(equalsIndex + 1);
|
|
28
|
+
return [name, cookieValue];
|
|
29
|
+
});
|
|
30
|
+
return new Map(entries);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.CookieParser = CookieParser;
|
|
34
|
+
//# sourceMappingURL=cookie-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-parser.js","sourceRoot":"","sources":["../../source/http/c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js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./cookie-parser"), exports);
|
|
18
19
|
__exportStar(require("./http-headers"), exports);
|
|
19
20
|
__exportStar(require("./http-query"), exports);
|
|
20
21
|
__exportStar(require("./http.error"), exports);
|
package/http/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,iDAA+B;AAC/B,+CAA6B;AAC7B,+CAA6B;AAC7B,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,kDAAgC;AAChC,iDAA+B;AAC/B,+CAA6B;AAC7B,+CAA6B;AAC7B,0CAAwB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StringMap, UndefinableJson } from "../../types";
|
|
2
|
+
import { CookieParser } from '../cookie-parser';
|
|
2
3
|
import type { HttpHeaders } from '../http-headers';
|
|
3
4
|
import type { HttpQuery } from '../http-query';
|
|
4
5
|
import type { HttpMethod } from '../types';
|
|
@@ -14,6 +15,7 @@ export declare class HttpServerRequest {
|
|
|
14
15
|
readonly url: URL;
|
|
15
16
|
readonly method: HttpMethod;
|
|
16
17
|
readonly headers: HttpHeaders;
|
|
18
|
+
readonly cookies: CookieParser;
|
|
17
19
|
readonly query: HttpQuery;
|
|
18
20
|
readonly ip: string;
|
|
19
21
|
context: StringMap;
|
|
@@ -5,12 +5,14 @@ const unsupported_media_type_error_1 = require("../../error/unsupported-media-ty
|
|
|
5
5
|
const encoding_1 = require("../../utils/encoding");
|
|
6
6
|
const stream_reader_1 = require("../../utils/stream/stream-reader");
|
|
7
7
|
const type_guards_1 = require("../../utils/type-guards");
|
|
8
|
+
const cookie_parser_1 = require("../cookie-parser");
|
|
8
9
|
class HttpServerRequest {
|
|
9
10
|
constructor(data) {
|
|
10
11
|
var _a;
|
|
11
12
|
this.url = data.url;
|
|
12
13
|
this.method = data.method;
|
|
13
14
|
this.headers = data.headers;
|
|
15
|
+
this.cookies = new cookie_parser_1.CookieParser(this.headers);
|
|
14
16
|
this.query = data.query;
|
|
15
17
|
this.ip = data.ip;
|
|
16
18
|
this.body = data.body;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-server-request.js","sourceRoot":"","sources":["../../../source/http/server/http-server-request.ts"],"names":[],"mappings":";;;AAAA,2FAAiF;AAEjF,mDAA8C;AAC9C,oEAAgE;AAChE,yDAA+D;
|
|
1
|
+
{"version":3,"file":"http-server-request.js","sourceRoot":"","sources":["../../../source/http/server/http-server-request.ts"],"names":[],"mappings":";;;AAAA,2FAAiF;AAEjF,mDAA8C;AAC9C,oEAAgE;AAChE,yDAA+D;AAC/D,oDAAgD;AAchD,MAAa,iBAAiB;IAgB5B,YAAY,IAA6B;;QACvC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEtB,IAAI,CAAC,OAAO,GAAG,MAAA,IAAI,CAAC,OAAO,mCAAI,EAAE,CAAC;IACpC,CAAC;IAdD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ApiGateway } from "../../api";
|
|
3
|
+
import type { AfterResolve, Injectable } from "../../container";
|
|
4
|
+
import { afterResolve, resolveArgumentType } from "../../container";
|
|
4
5
|
import { HttpServer } from "../../http/server";
|
|
5
6
|
import { Logger } from "../../logger";
|
|
6
7
|
import type { Type } from "../../types";
|
|
@@ -13,11 +14,13 @@ export declare type WebServerModuleConfiguration = {
|
|
|
13
14
|
prefix: 'api/';
|
|
14
15
|
};
|
|
15
16
|
export declare const webServerModuleConfiguration: WebServerModuleConfiguration;
|
|
16
|
-
export declare class WebServerModule extends ModuleBase implements Module, Injectable<WebServerModuleConfiguration
|
|
17
|
+
export declare class WebServerModule extends ModuleBase implements Module, Injectable<WebServerModuleConfiguration>, AfterResolve {
|
|
17
18
|
private readonly config;
|
|
18
19
|
private readonly logger;
|
|
19
20
|
private readonly httpServer;
|
|
20
21
|
private readonly apiGateway;
|
|
22
|
+
private readonly apiControllers;
|
|
23
|
+
private initialized;
|
|
21
24
|
readonly metrics: {
|
|
22
25
|
connectedSockets: {
|
|
23
26
|
type: ModuleMetricType;
|
|
@@ -25,7 +28,9 @@ export declare class WebServerModule extends ModuleBase implements Module, Injec
|
|
|
25
28
|
};
|
|
26
29
|
};
|
|
27
30
|
[resolveArgumentType]: WebServerModuleConfiguration;
|
|
28
|
-
constructor(config: WebServerModuleConfiguration, httpServer: HttpServer, apiGateway: ApiGateway, logger: Logger);
|
|
31
|
+
constructor(config: WebServerModuleConfiguration, httpServer: HttpServer, apiGateway: ApiGateway, logger: Logger, apiControllers?: ApiControllers);
|
|
32
|
+
initialize(): Promise<void>;
|
|
33
|
+
[afterResolve](): Promise<void>;
|
|
29
34
|
registerApiController(controller: Type<ApiController>): Promise<void>;
|
|
30
35
|
protected _run(cancellationToken: ReadonlyCancellationToken): Promise<void>;
|
|
31
36
|
}
|
|
@@ -37,7 +37,7 @@ function getApiGatewayArgument(config) {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
let WebServerModule = class WebServerModule extends module_base_1.ModuleBase {
|
|
40
|
-
constructor(config, httpServer, apiGateway, logger) {
|
|
40
|
+
constructor(config, httpServer, apiGateway, logger, apiControllers = []) {
|
|
41
41
|
super('WebServer');
|
|
42
42
|
this.metrics = {
|
|
43
43
|
connectedSockets: {
|
|
@@ -49,12 +49,27 @@ let WebServerModule = class WebServerModule extends module_base_1.ModuleBase {
|
|
|
49
49
|
this.apiGateway = apiGateway;
|
|
50
50
|
this.config = config;
|
|
51
51
|
this.logger = logger;
|
|
52
|
+
this.apiControllers = apiControllers;
|
|
53
|
+
this.initialized = false;
|
|
54
|
+
}
|
|
55
|
+
async initialize() {
|
|
56
|
+
if (this.initialized) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.initialized = true;
|
|
60
|
+
for (const controller of this.apiControllers) {
|
|
61
|
+
await this.registerApiController(controller);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async [container_1.afterResolve]() {
|
|
65
|
+
await this.initialize();
|
|
52
66
|
}
|
|
53
67
|
async registerApiController(controller) {
|
|
54
68
|
await this.apiGateway.registerApiController(controller);
|
|
55
69
|
}
|
|
56
70
|
async _run(cancellationToken) {
|
|
57
71
|
var e_1, _a;
|
|
72
|
+
await this.initialize();
|
|
58
73
|
await this.httpServer.listen(this.config.port);
|
|
59
74
|
this.logger.info(`listening on port ${this.config.port}`);
|
|
60
75
|
const closePromise = cancellationToken.$set.then(async () => {
|
|
@@ -82,9 +97,11 @@ WebServerModule = __decorate([
|
|
|
82
97
|
__param(0, (0, container_1.injectArg)()),
|
|
83
98
|
__param(2, (0, container_1.forwardArg)(getApiGatewayArgument)),
|
|
84
99
|
__param(3, (0, container_1.resolveArg)('WebServer')),
|
|
100
|
+
__param(4, (0, container_1.inject)(api_1.API_CONTROLLERS)),
|
|
101
|
+
__param(4, (0, container_1.optional)()),
|
|
85
102
|
__metadata("design:paramtypes", [Object, server_1.HttpServer,
|
|
86
103
|
api_1.ApiGateway,
|
|
87
|
-
logger_1.Logger])
|
|
104
|
+
logger_1.Logger, Array])
|
|
88
105
|
], WebServerModule);
|
|
89
106
|
exports.WebServerModule = WebServerModule;
|
|
90
107
|
function configureWebServerModule(config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-server.module.js","sourceRoot":"","sources":["../../../source/module/modules/web-server.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"web-server.module.js","sourceRoot":"","sources":["../../../source/module/modules/web-server.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,mCAAoE;AAEpE,+CAAgI;AAChI,4DAAuD;AACvD,8CAA2C;AAE3C,yCAAkC;AAIlC,sCAA6C;AAC7C,gDAA4C;AAO/B,QAAA,4BAA4B,GAAiC;IACxE,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,MAAM;CACf,CAAC;AAEF,SAAS,qBAAqB,CAAC,MAAoC;IACjE,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;AACJ,CAAC;AAGD,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,wBAAU;IAkB7C,YACe,MAAoC,EACjD,UAAsB,EAC+D,UAAsB,EAClE,MAAc,EAClB,iBAAiC,EAAE;QAExE,KAAK,CAAC,WAAW,CAAC,CAAC;QAhBZ,YAAO,GAAG;YACjB,gBAAgB,EAAE;gBAChB,IAAI,EAAE,yBAAgB,CAAC,KAAK;gBAC5B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB;aACtD;SACF,CAAC;QAaA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI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AAzEY,eAAe;IAD3B,IAAA,qBAAS,EAAC,EAAE,uBAAuB,EAAE,GAAG,EAAE,CAAC,oCAA4B,EAAE,CAAC;IAoBtE,WAAA,IAAA,qBAAS,GAAE,CAAA;IAEX,WAAA,IAAA,sBAAU,EAAmD,qBAAqB,CAAC,CAAA;IACnF,WAAA,IAAA,sBAAU,EAAiB,WAAW,CAAC,CAAA;IACvC,WAAA,IAAA,kBAAM,EAAC,qBAAe,CAAC,CAAA;IAAE,WAAA,IAAA,oBAAQ,GAAE,CAAA;6CAHxB,mBAAU;QAC2E,gBAAU;QAC1D,eAAM;GAtB9C,eAAe,CAyE3B;AAzEY,0CAAe;AA2E5B,SAAgB,wBAAwB,CAAC,MAA8C;;IACrF,oCAA4B,CAAC,IAAI,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,oCAA4B,CAAC,IAAI,CAAC;IACtF,oCAA4B,CAAC,MAAM,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,mCAAI,oCAA4B,CAAC,MAAM,CAAC;AAC9F,CAAC;AAHD,4DAGC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.70.
|
|
3
|
+
"version": "0.70.25",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"@types/minio": "7.0",
|
|
24
24
|
"@types/node": ">=16",
|
|
25
25
|
"@types/yup": "0.29",
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
27
|
-
"@typescript-eslint/parser": "5.
|
|
28
|
-
"eslint": "8.
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "5.15",
|
|
27
|
+
"@typescript-eslint/parser": "5.15",
|
|
28
|
+
"eslint": "8.11",
|
|
29
29
|
"ttypescript": "1.5",
|
|
30
30
|
"typescript": "4.6",
|
|
31
31
|
"typescript-transform-paths": "3.3"
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.errorCatchMiddleware = void 0;
|
|
4
|
-
const response_1 = require("../response");
|
|
5
|
-
const server_1 = require("../../http/server");
|
|
6
|
-
const helpers_1 = require("../../utils/helpers");
|
|
7
|
-
function errorCatchMiddleware(logger, supressedErrors) {
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
9
|
-
async function errorCatchMiddleware(request, next) {
|
|
10
|
-
try {
|
|
11
|
-
const response = await next(request);
|
|
12
|
-
return response;
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
const response = new server_1.HttpServerResponse();
|
|
16
|
-
if (error instanceof Error) {
|
|
17
|
-
const errorConstructor = error.constructor;
|
|
18
|
-
const supressed = supressedErrors.has(errorConstructor);
|
|
19
|
-
if (!supressed) {
|
|
20
|
-
logger.error(error);
|
|
21
|
-
}
|
|
22
|
-
if ((0, response_1.hasErrorHandler)(errorConstructor)) {
|
|
23
|
-
response.statusCode = (0, response_1.getErrorStatusCode)(error);
|
|
24
|
-
response.body = { json: (0, response_1.createErrorResponse)(error) };
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
response.statusCode = 500;
|
|
28
|
-
response.body = { json: (0, response_1.createErrorResponse)('500', 'Internal Server Error') };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
const formattedError = (0, helpers_1.formatError)(error, { includeStack: true, includeRest: true, handleBuiltInErrors: true });
|
|
33
|
-
logger.error(formattedError);
|
|
34
|
-
response.statusCode = 500;
|
|
35
|
-
response.body = { json: (0, response_1.createErrorResponse)('500', 'Internal Server Error') };
|
|
36
|
-
}
|
|
37
|
-
return response;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return errorCatchMiddleware;
|
|
41
|
-
}
|
|
42
|
-
exports.errorCatchMiddleware = errorCatchMiddleware;
|
|
43
|
-
//# sourceMappingURL=error-catch.middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-catch.middleware.js","sourceRoot":"","sources":["../../../source/api/middlewares/error-catch.middleware.ts"],"names":[],"mappings":";;;AAAA,0CAA0F;AAG1F,8CAAmD;AAGnD,iDAA8C;AAG9C,SAAgB,oBAAoB,CAAC,MAAc,EAAE,eAAiC;IACpF,wDAAwD;IACxD,KAAK,UAAU,oBAAoB,CAAC,OAA0B,EAAE,IAA8B;QAC5F,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YACrC,OAAO,QAAQ,CAAC;SACjB;QACD,OAAO,KAAc,EAAE;YACrB,MAAM,QAAQ,GAAG,IAAI,2BAAkB,EAAE,CAAC;YAE1C,IAAI,KAAK,YAAY,KAAK,EAAE;gBAC1B,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAA8C,CAAC;gBAC9E,MAAM,SAAS,GAAG,eAAe,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;gBAExD,IAAI,CAAC,SAAS,EAAE;oBACd,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACrB;gBAED,IAAI,IAAA,0BAAe,EAAC,gBAAgB,CAAC,EAAE;oBACrC,QAAQ,CAAC,UAAU,GAAG,IAAA,6BAAkB,EAAC,KAAoB,CAAC,CAAC;oBAC/D,QAAQ,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,IAAA,8BAAmB,EAAC,KAAK,CAAC,EAAE,CAAC;iBACtD;qBACI;oBACH,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAC;oBAC1B,QAAQ,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,IAAA,8BAAmB,EAAC,KAAK,EAAE,uBAAuB,CAAC,EAAE,CAAC;iBAC/E;aACF;iBACI;gBACH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