quantum-flow 1.21.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -12
- package/dist/app/aws/lambda.js +15 -18
- package/dist/app/aws/lambda.js.map +1 -1
- package/dist/app/http/Application.d.ts +2 -3
- package/dist/app/http/Application.js +70 -118
- package/dist/app/http/Application.js.map +1 -1
- package/dist/app/http/index.d.ts +0 -1
- package/dist/app/http/index.js.map +1 -1
- package/dist/app/plugin.js +2 -2
- package/dist/app/plugin.js.map +1 -1
- package/dist/core/Controller.d.ts +10 -5
- package/dist/core/Controller.js +33 -120
- package/dist/core/Controller.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/types/common.d.ts +15 -52
- package/dist/types/common.js.map +1 -1
- package/dist/types/controller.d.ts +3 -2
- package/dist/types/error.d.ts +4 -0
- package/dist/types/error.js.map +1 -1
- package/dist/types/http.d.ts +6 -11
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/lambda.d.ts +2 -1
- package/dist/types/plugins.d.ts +4 -3
- package/dist/types/request.d.ts +65 -0
- package/dist/types/request.js +3 -0
- package/dist/types/request.js.map +1 -0
- package/dist/types/response.d.ts +49 -0
- package/dist/types/response.js +3 -0
- package/dist/types/response.js.map +1 -0
- package/dist/utils/controller.d.ts +5 -6
- package/dist/utils/controller.js +7 -9
- package/dist/utils/controller.js.map +1 -1
- package/dist/utils/cors.d.ts +2 -2
- package/dist/utils/cors.js.map +1 -1
- package/dist/utils/error/apperror.d.ts +4 -7
- package/dist/utils/error/apperror.js +10 -13
- package/dist/utils/error/apperror.js.map +1 -1
- package/dist/utils/error/dependencyFailed.d.ts +7 -0
- package/dist/utils/error/dependencyFailed.js +17 -0
- package/dist/utils/error/dependencyFailed.js.map +1 -0
- package/dist/utils/error/duplicateEntry.d.ts +7 -0
- package/dist/utils/error/duplicateEntry.js +17 -0
- package/dist/utils/error/duplicateEntry.js.map +1 -0
- package/dist/utils/error/forbidden.d.ts +7 -0
- package/dist/utils/error/forbidden.js +17 -0
- package/dist/utils/error/forbidden.js.map +1 -0
- package/dist/utils/error/index.d.ts +6 -0
- package/dist/utils/error/index.js +6 -0
- package/dist/utils/error/index.js.map +1 -1
- package/dist/utils/error/invalidState.d.ts +7 -0
- package/dist/utils/error/invalidState.js +17 -0
- package/dist/utils/error/invalidState.js.map +1 -0
- package/dist/utils/error/rateLimit.d.ts +7 -0
- package/dist/utils/error/rateLimit.js +17 -0
- package/dist/utils/error/rateLimit.js.map +1 -0
- package/dist/utils/error/serviceUnavailable.d.ts +7 -0
- package/dist/utils/error/serviceUnavailable.js +17 -0
- package/dist/utils/error/serviceUnavailable.js.map +1 -0
- package/dist/utils/headers.d.ts +2 -2
- package/dist/utils/headers.js.map +1 -1
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lambda.d.ts +2 -1
- package/dist/utils/lambda.js +28 -48
- package/dist/utils/lambda.js.map +1 -1
- package/dist/utils/parsers.d.ts +3 -1
- package/dist/utils/parsers.js +106 -23
- package/dist/utils/parsers.js.map +1 -1
- package/dist/utils/request/factory.d.ts +18 -0
- package/dist/utils/request/factory.js +141 -0
- package/dist/utils/request/factory.js.map +1 -0
- package/dist/utils/request/helpers.d.ts +3 -0
- package/dist/utils/request/helpers.js +35 -0
- package/dist/utils/request/helpers.js.map +1 -0
- package/dist/utils/request/index.d.ts +2 -0
- package/dist/utils/request/index.js +19 -0
- package/dist/utils/request/index.js.map +1 -0
- package/dist/utils/request/request.d.ts +103 -0
- package/dist/utils/request/request.js +218 -0
- package/dist/utils/request/request.js.map +1 -0
- package/dist/utils/response/factory.d.ts +13 -0
- package/dist/utils/response/factory.js +20 -0
- package/dist/utils/response/factory.js.map +1 -0
- package/dist/utils/response/index.d.ts +2 -0
- package/dist/utils/response/index.js +19 -0
- package/dist/utils/response/index.js.map +1 -0
- package/dist/utils/response/response.d.ts +46 -0
- package/dist/utils/response/response.js +269 -0
- package/dist/utils/response/response.js.map +1 -0
- package/dist/utils/routeWalker.d.ts +2 -0
- package/dist/utils/routeWalker.js +115 -0
- package/dist/utils/routeWalker.js.map +1 -0
- package/dist/utils/sanitize.d.ts +2 -2
- package/dist/utils/sanitize.js.map +1 -1
- package/package.json +1 -1
package/dist/core/Controller.js
CHANGED
|
@@ -52,150 +52,63 @@ function Controller(config, middlewares = []) {
|
|
|
52
52
|
sse;
|
|
53
53
|
executeControllerMethod = _utils_1.executeControllerMethod;
|
|
54
54
|
getControllerMethods = _utils_1.getControllerMethods;
|
|
55
|
+
routePrefix;
|
|
56
|
+
middlewares = [];
|
|
57
|
+
interceptor;
|
|
58
|
+
subControllers = [];
|
|
59
|
+
errorHandler;
|
|
60
|
+
cors;
|
|
61
|
+
sanitizers;
|
|
55
62
|
constructor(...args) {
|
|
56
63
|
super(...args);
|
|
57
64
|
this.lookupWS();
|
|
58
65
|
this.lookupSSE();
|
|
59
66
|
}
|
|
60
67
|
handleRequest = async (request, response) => {
|
|
61
|
-
const middlewares =
|
|
68
|
+
const middlewares = this.middlewares
|
|
62
69
|
.concat(Reflect.getMetadata(_constants_1.MIDDLEWARES, proto))
|
|
63
70
|
.concat(Reflect.getMetadata(_constants_1.USE_MIDDLEWARE, constructor))
|
|
64
71
|
.filter((el) => !!el);
|
|
72
|
+
const routePrefix = this.routePrefix ?? Reflect.getMetadata(_constants_1.ROUTE_PREFIX, proto) ?? '/';
|
|
73
|
+
const interceptor = this.interceptor ?? Reflect.getMetadata(_constants_1.INTERCEPTOR, proto);
|
|
74
|
+
const subControllers = this.subControllers.concat(Reflect.getMetadata(_constants_1.CONTROLLERS, proto)) ?? [];
|
|
75
|
+
const errorHandler = this.errorHandler ?? Reflect.getMetadata(_constants_1.CATCH, constructor);
|
|
76
|
+
const cors = this.cors ?? Reflect.getMetadata(_constants_1.CORS_METADATA, proto);
|
|
77
|
+
const sanitizers = this.sanitizers ?? Reflect.getMetadata(_constants_1.SANITIZE, proto) ?? [];
|
|
65
78
|
const context = {
|
|
66
79
|
controllerInstance: this,
|
|
67
80
|
controllerMeta: {
|
|
68
|
-
routePrefix
|
|
81
|
+
routePrefix,
|
|
69
82
|
middlewares,
|
|
70
|
-
interceptor
|
|
71
|
-
subControllers
|
|
72
|
-
errorHandler
|
|
73
|
-
cors
|
|
74
|
-
sanitizers
|
|
83
|
+
interceptor,
|
|
84
|
+
subControllers,
|
|
85
|
+
errorHandler,
|
|
86
|
+
cors,
|
|
87
|
+
sanitizers,
|
|
75
88
|
},
|
|
76
89
|
path: (request.requestUrl.pathname ?? '').replace(/^\/+/g, ''),
|
|
77
90
|
method: request.method.toUpperCase(),
|
|
78
91
|
middlewareChain: [],
|
|
79
92
|
interceptorChain: [],
|
|
80
93
|
sanitizersChain: [],
|
|
81
|
-
corsChain: [
|
|
82
|
-
errorHandlerChain: [
|
|
83
|
-
subPath:
|
|
94
|
+
corsChain: [cors],
|
|
95
|
+
errorHandlerChain: [errorHandler],
|
|
96
|
+
subPath: routePrefix,
|
|
84
97
|
};
|
|
85
|
-
return this.routeWalker(context, request, response);
|
|
86
|
-
};
|
|
87
|
-
async routeWalker(context, request, response) {
|
|
88
|
-
const { controllerInstance, controllerMeta, path, method, subPath } = context;
|
|
89
|
-
for (const SubController of controllerMeta.subControllers) {
|
|
90
|
-
const subInstance = new SubController();
|
|
91
|
-
const middlewares = []
|
|
92
|
-
.concat(Reflect.getMetadata(_constants_1.MIDDLEWARES, SubController.prototype))
|
|
93
|
-
.concat(Reflect.getMetadata(_constants_1.USE_MIDDLEWARE, SubController))
|
|
94
|
-
.filter((el) => !!el);
|
|
95
|
-
const sanitizers = []
|
|
96
|
-
.concat(Reflect.getMetadata(_constants_1.SANITIZE, SubController.prototype))
|
|
97
|
-
.concat(Reflect.getMetadata(_constants_1.SANITIZE, SubController))
|
|
98
|
-
.filter((el) => !!el);
|
|
99
|
-
const subMeta = {
|
|
100
|
-
routePrefix: Reflect.getMetadata(_constants_1.ROUTE_PREFIX, SubController.prototype) || '',
|
|
101
|
-
middlewares,
|
|
102
|
-
interceptor: Reflect.getMetadata(_constants_1.INTERCEPTOR, SubController.prototype),
|
|
103
|
-
errorHandler: Reflect.getMetadata(_constants_1.CATCH, SubController),
|
|
104
|
-
subControllers: Reflect.getMetadata(_constants_1.CONTROLLERS, SubController.prototype) || [],
|
|
105
|
-
cors: Reflect.getMetadata(_constants_1.CORS_METADATA, SubController.prototype) || [],
|
|
106
|
-
sanitizers,
|
|
107
|
-
};
|
|
108
|
-
const fullSubPath = [subPath, subMeta.routePrefix]
|
|
109
|
-
.filter(Boolean)
|
|
110
|
-
.join('/')
|
|
111
|
-
.replace(/\/+/g, '/');
|
|
112
|
-
if ((0, _utils_1.pathStartsWithPrefix)(path, fullSubPath)) {
|
|
113
|
-
const walkerData = {
|
|
114
|
-
...context,
|
|
115
|
-
subPath: fullSubPath,
|
|
116
|
-
controllerInstance: subInstance,
|
|
117
|
-
controllerMeta: subMeta,
|
|
118
|
-
path,
|
|
119
|
-
middlewareChain: [...context.middlewareChain, ...controllerMeta.middlewares],
|
|
120
|
-
sanitizersChain: [...context.sanitizersChain, ...controllerMeta.sanitizers],
|
|
121
|
-
errorHandlerChain: [...context.errorHandlerChain, subMeta.errorHandler].filter((el) => !!el),
|
|
122
|
-
interceptorChain: [...context.interceptorChain, controllerMeta.interceptor].filter((el) => !!el),
|
|
123
|
-
corsChain: [...context.corsChain, subMeta.cors].filter((el) => !!el),
|
|
124
|
-
};
|
|
125
|
-
return this.routeWalker(walkerData, request, response);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const routeMatch = (0, _utils_1.findRouteInController)(controllerInstance, subPath, path, method);
|
|
129
|
-
if (!routeMatch) {
|
|
130
|
-
return {};
|
|
131
|
-
}
|
|
132
|
-
let data;
|
|
133
98
|
try {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.
|
|
138
|
-
|
|
139
|
-
.filter((el) => !!el)
|
|
140
|
-
.reduce((acc, conf) => {
|
|
141
|
-
const cors = (0, _utils_1.handleCORS)(request, response, conf);
|
|
142
|
-
return {
|
|
143
|
-
permitted: acc.permitted && cors.permitted,
|
|
144
|
-
continue: acc.continue && cors.continue,
|
|
145
|
-
};
|
|
146
|
-
}, { permitted: true, continue: true });
|
|
147
|
-
if (!handledCors.permitted) {
|
|
148
|
-
response.statusCode = 403;
|
|
149
|
-
data = 'Cors: Origin not allowed';
|
|
150
|
-
return { routeMatch, data };
|
|
151
|
-
}
|
|
152
|
-
if (!handledCors.continue && handledCors.permitted) {
|
|
153
|
-
response.statusCode = 204;
|
|
154
|
-
return { routeMatch };
|
|
155
|
-
}
|
|
156
|
-
const controllerMiddlewares = [...context.middlewareChain, ...controllerMeta.middlewares];
|
|
157
|
-
const controllerSanitizers = [
|
|
158
|
-
...context.sanitizersChain,
|
|
159
|
-
...controllerMeta.sanitizers,
|
|
160
|
-
].filter((el) => !!el);
|
|
161
|
-
await (0, _utils_1.applyMiddlewaresVsSanitizers)(request, response, {
|
|
162
|
-
sanitizers: [controllerSanitizers, sanitizers],
|
|
163
|
-
middlewares: [controllerMiddlewares, middlewares],
|
|
164
|
-
});
|
|
165
|
-
data = await (0, _utils_1.getResponse)({
|
|
166
|
-
interceptors: [...context.interceptorChain, controllerMeta.interceptor].filter((el) => !!el),
|
|
167
|
-
controllerInstance,
|
|
168
|
-
name,
|
|
169
|
-
response: response,
|
|
170
|
-
request: request,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
let catched = error;
|
|
175
|
-
let statusCode = error.status ?? error.statusCode ?? 500;
|
|
176
|
-
catched.status = statusCode;
|
|
177
|
-
for (const handler of context.errorHandlerChain?.reverse() || []) {
|
|
178
|
-
try {
|
|
179
|
-
catched = await Promise.resolve(handler(catched, request, response))
|
|
180
|
-
.then((resp) => {
|
|
181
|
-
statusCode = 200;
|
|
182
|
-
return resp;
|
|
183
|
-
})
|
|
184
|
-
.catch((err) => {
|
|
185
|
-
statusCode = err.status ?? err.statusCode ?? statusCode;
|
|
186
|
-
return err;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
catch (errs) { }
|
|
99
|
+
const done = await (0, _utils_1.routeWalker)(context, request, response);
|
|
100
|
+
if (!done) {
|
|
101
|
+
response.status = 404;
|
|
102
|
+
response.data = 'Route not found';
|
|
103
|
+
return false;
|
|
190
104
|
}
|
|
191
|
-
|
|
192
|
-
data = catched;
|
|
105
|
+
return true;
|
|
193
106
|
}
|
|
194
|
-
|
|
195
|
-
response.
|
|
107
|
+
catch (err) {
|
|
108
|
+
response.error(err);
|
|
109
|
+
return true;
|
|
196
110
|
}
|
|
197
|
-
|
|
198
|
-
}
|
|
111
|
+
};
|
|
199
112
|
lookupWS() {
|
|
200
113
|
const connection = this.getWSHandlers('connection');
|
|
201
114
|
const message = this.getWSHandlers('message');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Controller.js","sourceRoot":"","sources":["../../src/core/Controller.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Controller.js","sourceRoot":"","sources":["../../src/core/Controller.ts"],"names":[],"mappings":";;AAqDA,gCAqKC;AA1ND,uDAAuD;AACvD,2CAYoB;AAgBpB,mCAAoF;AACpF,4BAA0B;AAE1B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,UAAU,CACxB,MAAiC,EACjC,cAAoC,EAAE;IAEtC,uCAAuC;IACvC,MAAM,WAAW,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IACxE,MAAM,WAAW,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IAChF,MAAM,q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index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This module provides centralized exports for controller and endpoint decorators,
|
|
5
5
|
* as well as related types and utility functions used throughout the core framework.
|
|
6
6
|
*/
|
|
7
|
-
export {
|
|
7
|
+
export { AppError, CORSConfig, ErrorCB, InterceptorCB, IRequest, IResponse, IWebSocketService, MiddlewareCB, MultipartFile, WebSocketClient, WebSocketEvent, WebSocketMessage, } from '../types/index.js';
|
|
8
8
|
export { SANITIZER } from '../utils/index.js';
|
|
9
9
|
export * from './Controller';
|
|
10
10
|
export * from './decorators';
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAoBA,iCAAmC;AAA1B,mGAAA,SAAS,OAAA;AAClB,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B"}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,50 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
statusCode?: number;
|
|
6
|
-
status: number;
|
|
7
|
-
data?: any;
|
|
8
|
-
messages?: string[];
|
|
9
|
-
errors?: Array<{
|
|
10
|
-
message: string;
|
|
11
|
-
}>;
|
|
12
|
-
}
|
|
13
|
-
type Request = {
|
|
14
|
-
requestUrl: URL;
|
|
15
|
-
method: HTTP_METHODS;
|
|
16
|
-
path?: string;
|
|
17
|
-
id: string;
|
|
18
|
-
headers: Record<string, string | string[]>;
|
|
19
|
-
query?: Record<string, string | string[]>;
|
|
20
|
-
params?: Record<string, string>;
|
|
21
|
-
body: any;
|
|
22
|
-
rawBody: Buffer<ArrayBufferLike>;
|
|
23
|
-
isBase64Encoded?: boolean;
|
|
24
|
-
cookies: Record<string, string>;
|
|
25
|
-
multipart?: Record<string, MultipartFile | MultipartFile[]>;
|
|
26
|
-
_startTime: number;
|
|
27
|
-
ip: string;
|
|
28
|
-
end: () => any;
|
|
29
|
-
};
|
|
30
|
-
export type AppRequest = Request & (IncomingMessage | LambdaRequestMeta);
|
|
31
|
-
export type HttpRequest = Request & IncomingMessage;
|
|
32
|
-
export type Router = (req: AppRequest, res?: ServerResponse) => Promise<{
|
|
1
|
+
import { IRequest, IResponse } from './index.js';
|
|
2
|
+
import { ServerResponse } from 'http';
|
|
3
|
+
import { AppError } from './error';
|
|
4
|
+
export type Router = (req: IRequest, res?: ServerResponse) => Promise<{
|
|
33
5
|
status: number;
|
|
34
6
|
data: any;
|
|
35
7
|
message?: string;
|
|
36
8
|
}>;
|
|
37
|
-
export type EndpointResponse<T = any> = {
|
|
38
|
-
status: number;
|
|
39
|
-
data?: T;
|
|
40
|
-
error?: any;
|
|
41
|
-
};
|
|
42
9
|
export interface IController {
|
|
43
10
|
handleRequest: Router;
|
|
44
11
|
}
|
|
45
|
-
export type MiddlewareCB = (request:
|
|
46
|
-
export type InterceptorCB = (data: any, req?:
|
|
47
|
-
export type ErrorCB = (error:
|
|
12
|
+
export type MiddlewareCB = (request: IRequest, response: IResponse, next: (args?: any) => any) => void | Promise<IRequest> | IRequest | Promise<void> | void;
|
|
13
|
+
export type InterceptorCB = (data: any, req?: IRequest, res?: IResponse) => Promise<unknown> | unknown;
|
|
14
|
+
export type ErrorCB = (error: AppError, req?: IRequest, res?: IResponse) => any;
|
|
48
15
|
export type ParamDecoratorType = 'body' | 'params' | 'query' | 'request' | 'headers' | 'cookies' | 'response' | 'multipart' | 'event' | 'context' | 'sse' | 'ws';
|
|
49
16
|
export interface ParamMetadata {
|
|
50
17
|
index: number;
|
|
@@ -66,15 +33,11 @@ export declare enum HTTP_METHODS {
|
|
|
66
33
|
OPTIONS = "OPTIONS",
|
|
67
34
|
HEAD = "HEAD"
|
|
68
35
|
}
|
|
69
|
-
export
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
priority?: 'Low' | 'Medium' | 'High';
|
|
78
|
-
partitioned?: boolean;
|
|
79
|
-
}
|
|
80
|
-
export {};
|
|
36
|
+
export type Meta = {
|
|
37
|
+
requestUrl: URL;
|
|
38
|
+
method: string;
|
|
39
|
+
requestId: string;
|
|
40
|
+
sourceIp: string;
|
|
41
|
+
userAgent: string;
|
|
42
|
+
startTime: number;
|
|
43
|
+
};
|
package/dist/types/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";;;AAsDA,IAAY,YASX;AATD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,2BAAW,CAAA;IACX,6BAAa,CAAA;IACb,+BAAe,CAAA;IACf,iCAAiB,CAAA;IACjB,2BAAW,CAAA;IACX,mCAAmB,CAAA;IACnB,6BAAa,CAAA;AACf,CAAC,EATW,YAAY,4BAAZ,YAAY,QASvB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ServerResponse } from 'http';
|
|
2
|
-
import {
|
|
2
|
+
import { ErrorCB, HTTP_METHODS, InterceptorCB, MiddlewareCB } from './common';
|
|
3
3
|
import { CORSConfig } from './cors';
|
|
4
|
+
import { IRequest } from './request';
|
|
4
5
|
import { SanitizerConfig } from './sanitize';
|
|
5
6
|
export type ControllerClass = {
|
|
6
7
|
new (...args: any[]): any;
|
|
@@ -12,7 +13,7 @@ export type ControllerMethods = Array<{
|
|
|
12
13
|
middlewares?: MiddlewareCB[];
|
|
13
14
|
}>;
|
|
14
15
|
export type ControllerType = {
|
|
15
|
-
handleRequest?(request:
|
|
16
|
+
handleRequest?(request: IRequest, response: ServerResponse): Promise<any>;
|
|
16
17
|
ws?: WsControllerHandlers;
|
|
17
18
|
sse?: SeeControllerHandlers;
|
|
18
19
|
new (...args: any[]): any;
|
package/dist/types/error.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ServerResponse } from 'http';
|
|
2
|
+
import { LambdaResponse } from './lambda';
|
|
3
|
+
import { IRequest } from './request';
|
|
1
4
|
export declare enum ErrorCode {
|
|
2
5
|
BAD_REQUEST = "BAD_REQUEST",
|
|
3
6
|
UNAUTHORIZED = "UNAUTHORIZED",
|
|
@@ -67,3 +70,4 @@ export interface ErrorHandlerConfig {
|
|
|
67
70
|
logStack?: boolean;
|
|
68
71
|
customHandlers?: Record<ErrorCode, (error: AppError) => any>;
|
|
69
72
|
}
|
|
73
|
+
export type ErorrHandler = (error: Error, req: IRequest, response: LambdaResponse | ServerResponse) => any;
|
package/dist/types/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/types/error.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/types/error.ts"],"names":[],"mappings":";;;AAIA,IAAY,SAaX;AAbD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,0CAA6B,CAAA;IAC7B,oCAAuB,CAAA;IACvB,oCAAuB,CAAA;IACvB,oDAAuC,CAAA;IACvC,wDAA2C,CAAA;IAC3C,8CAAiC,CAAA;IACjC,wDAA2C,CAAA;IAC3C,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,4CAA+B,CAAA;IAC/B,oDAAuC,CAAA;AACzC,CAAC,EAbW,SAAS,yBAAT,SAAS,QAapB"}
|
package/dist/types/http.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IRequest, IResponse } from './index.js';
|
|
2
2
|
import { PubSub } from 'type-graphql';
|
|
3
|
-
import {
|
|
3
|
+
import { InterceptorCB, MiddlewareCB } from './common';
|
|
4
4
|
import { ControllerClass, ControllerType } from './controller';
|
|
5
5
|
import { CORSConfig } from './cors';
|
|
6
6
|
import { AppError } from './error';
|
|
@@ -32,7 +32,7 @@ export interface ServerConfig {
|
|
|
32
32
|
* Error handling callback
|
|
33
33
|
* @type {ErrorCB}
|
|
34
34
|
*/
|
|
35
|
-
errorHandler?: (error: AppError, req:
|
|
35
|
+
errorHandler?: (error: AppError, req: IRequest, response: IResponse) => any;
|
|
36
36
|
/**
|
|
37
37
|
* Array of controller types
|
|
38
38
|
* @type {ControllerType[]}
|
|
@@ -55,10 +55,10 @@ export interface ServerConfig {
|
|
|
55
55
|
statics?: StaticConfig[];
|
|
56
56
|
/**
|
|
57
57
|
* WebSocket enablement and lazy loading
|
|
58
|
-
* @type {{
|
|
58
|
+
* @type {{ path: string; lazy?: boolean }}
|
|
59
59
|
*/
|
|
60
60
|
websocket?: {
|
|
61
|
-
|
|
61
|
+
path: string;
|
|
62
62
|
lazy?: boolean;
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
@@ -68,23 +68,18 @@ export interface ServerConfig {
|
|
|
68
68
|
sse?: {
|
|
69
69
|
enabled: boolean;
|
|
70
70
|
};
|
|
71
|
-
/**
|
|
72
|
-
* Path for WebSocket connections
|
|
73
|
-
* @type {string}
|
|
74
|
-
*/
|
|
75
|
-
websocketPath?: string;
|
|
76
71
|
/**
|
|
77
72
|
* GraphQL configuration including playground, pubSub, and resolvers
|
|
78
73
|
* @type {{ playground?: boolean; pubSub?: PubSub; resolvers?: Function[] }}
|
|
79
74
|
*/
|
|
80
75
|
graphql?: {
|
|
76
|
+
path: string;
|
|
81
77
|
playground?: boolean;
|
|
82
78
|
pubSub?: PubSub;
|
|
83
79
|
resolvers?: Function[];
|
|
84
80
|
};
|
|
85
81
|
}
|
|
86
82
|
import { Server } from 'http';
|
|
87
|
-
import { LambdaResponse } from './lambda';
|
|
88
83
|
export interface IHttpServer {
|
|
89
84
|
readonly app: Server;
|
|
90
85
|
plugins: HttpPlugin[];
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -22,6 +22,8 @@ __exportStar(require("./http"), exports);
|
|
|
22
22
|
__exportStar(require("./lambda"), exports);
|
|
23
23
|
__exportStar(require("./multipart"), exports);
|
|
24
24
|
__exportStar(require("./plugins"), exports);
|
|
25
|
+
__exportStar(require("./request"), exports);
|
|
26
|
+
__exportStar(require("./response"), exports);
|
|
25
27
|
__exportStar(require("./sanitize"), exports);
|
|
26
28
|
__exportStar(require("./sse"), exports);
|
|
27
29
|
__exportStar(require("./static"), exports);
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B;AAC7B,yCAAuB;AACvB,0CAAwB;AACxB,yCAAuB;AACvB,2CAAyB;AACzB,8CAA4B;AAC5B,4CAA0B;AAC1B,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B;AAC7B,yCAAuB;AACvB,0CAAwB;AACxB,yCAAuB;AACvB,2CAAyB;AACzB,8CAA4B;AAC5B,4CAA0B;AAC1B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B"}
|
package/dist/types/lambda.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, Context, Handler } from 'aws-lambda';
|
|
2
|
-
import {
|
|
2
|
+
import { HTTP_METHODS } from './common';
|
|
3
3
|
import { ControllerClass } from './controller';
|
|
4
4
|
import { MultipartFile } from './multipart';
|
|
5
5
|
import { LambdaPlugin } from './plugins';
|
|
6
|
+
import { CookieOptions } from './response';
|
|
6
7
|
export interface LambdaFunctionUrlEvent {
|
|
7
8
|
version: string;
|
|
8
9
|
routeKey: string;
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { IRequest } from './index.js';
|
|
1
2
|
import { Context } from 'aws-lambda';
|
|
2
3
|
import { IncomingMessage, Server, ServerResponse } from 'http';
|
|
3
|
-
import {
|
|
4
|
+
import { MiddlewareCB } from './common';
|
|
4
5
|
import { IHttpServer } from './http';
|
|
5
6
|
import { ILambdaAdapter, LambdaEvent, LambdaRequest, LambdaResponse } from './lambda';
|
|
6
7
|
export interface HttpPluginHooks {
|
|
7
8
|
beforeRequest?: (req: IncomingMessage) => void | Promise<void>;
|
|
8
|
-
beforeRoute?: (req:
|
|
9
|
-
afterResponse?: (req:
|
|
9
|
+
beforeRoute?: (req: IRequest, response: ServerResponse) => void | Promise<void>;
|
|
10
|
+
afterResponse?: (req: IRequest, res: ServerResponse) => void | Promise<void>;
|
|
10
11
|
}
|
|
11
12
|
export interface HttpPlugin {
|
|
12
13
|
name: string;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { APIGatewayProxyEvent, Context } from 'aws-lambda';
|
|
2
|
+
import { IncomingHttpHeaders } from 'http';
|
|
3
|
+
import { LambdaEvent } from './lambda';
|
|
4
|
+
export type RequestSource = 'http' | 'lambda' | 'unknown';
|
|
5
|
+
export interface RequestOptions {
|
|
6
|
+
method: string;
|
|
7
|
+
requestUrl: URL;
|
|
8
|
+
url: string;
|
|
9
|
+
path: string;
|
|
10
|
+
headers: Record<string, string | string[]>;
|
|
11
|
+
query: Record<string, string | string[]>;
|
|
12
|
+
body: any;
|
|
13
|
+
params: Record<string, string>;
|
|
14
|
+
cookies: Record<string, string>;
|
|
15
|
+
sourceIp?: string;
|
|
16
|
+
userAgent?: string;
|
|
17
|
+
requestId: string;
|
|
18
|
+
stage?: string;
|
|
19
|
+
timestamp: Date;
|
|
20
|
+
raw?: any;
|
|
21
|
+
context?: any;
|
|
22
|
+
rawBody?: any;
|
|
23
|
+
event?: LambdaEvent;
|
|
24
|
+
isBase64Encoded?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface IRequest {
|
|
27
|
+
method: string;
|
|
28
|
+
path: string;
|
|
29
|
+
url: string;
|
|
30
|
+
requestUrl: URL;
|
|
31
|
+
headers: Record<string, string | string[]>;
|
|
32
|
+
query: Record<string, string | string[]>;
|
|
33
|
+
body: any;
|
|
34
|
+
params: Record<string, string>;
|
|
35
|
+
cookies: Record<string, string>;
|
|
36
|
+
sourceIp: string;
|
|
37
|
+
userAgent: string;
|
|
38
|
+
requestId: string;
|
|
39
|
+
stage: string;
|
|
40
|
+
timestamp: Date;
|
|
41
|
+
source: RequestSource;
|
|
42
|
+
raw: any;
|
|
43
|
+
context: any;
|
|
44
|
+
rawBody: any;
|
|
45
|
+
isBase64Encoded: any;
|
|
46
|
+
startTime: number;
|
|
47
|
+
getHeader(name: string): string | string[] | undefined;
|
|
48
|
+
getCookie(name: string): string | undefined;
|
|
49
|
+
getQuery(name: string): string | string[] | undefined;
|
|
50
|
+
getParam(name: string): string | undefined;
|
|
51
|
+
isHttp(): boolean;
|
|
52
|
+
isLambda(): boolean;
|
|
53
|
+
getLambdaEvent(): APIGatewayProxyEvent | undefined;
|
|
54
|
+
getLambdaContext(): Context | undefined;
|
|
55
|
+
getHttpRequest(): IncomingHttpHeaders | undefined;
|
|
56
|
+
setState(key: string, value: any): void;
|
|
57
|
+
getState<T = any>(key: string): T | undefined;
|
|
58
|
+
getAllState(): Map<string, any>;
|
|
59
|
+
isSecure(): boolean;
|
|
60
|
+
getClientIp(): string;
|
|
61
|
+
getHost(): string;
|
|
62
|
+
getFullUrl(): string;
|
|
63
|
+
clone(overrides?: Partial<RequestOptions>): IRequest;
|
|
64
|
+
toJSON(): Record<string, any>;
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/types/request.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type ResponseSource = 'http' | 'lambda' | 'unknown';
|
|
2
|
+
export interface CookieOptions {
|
|
3
|
+
maxAge?: number;
|
|
4
|
+
expires?: Date;
|
|
5
|
+
path?: string;
|
|
6
|
+
domain?: string;
|
|
7
|
+
secure?: boolean;
|
|
8
|
+
httpOnly?: boolean;
|
|
9
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
10
|
+
priority?: 'low' | 'medium' | 'high';
|
|
11
|
+
partitioned?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ResponseOptions {
|
|
14
|
+
statusCode?: number;
|
|
15
|
+
headers?: Record<string, string | string[]>;
|
|
16
|
+
body?: any;
|
|
17
|
+
cookies?: string[];
|
|
18
|
+
isBase64Encoded?: boolean;
|
|
19
|
+
encoding?: BufferEncoding;
|
|
20
|
+
}
|
|
21
|
+
export interface IResponse {
|
|
22
|
+
headers: Record<string, string | string[]>;
|
|
23
|
+
data: any;
|
|
24
|
+
cookies: string[];
|
|
25
|
+
isBase64Encoded: boolean;
|
|
26
|
+
source: ResponseSource;
|
|
27
|
+
raw: any;
|
|
28
|
+
headersSent: boolean;
|
|
29
|
+
ok: boolean;
|
|
30
|
+
meta: {
|
|
31
|
+
requestUrl: URL;
|
|
32
|
+
method: string;
|
|
33
|
+
};
|
|
34
|
+
status: number;
|
|
35
|
+
getStatus(): number;
|
|
36
|
+
setHeader(name: string, value: string | string[]): this;
|
|
37
|
+
getHeader(name: string): string | string[] | undefined;
|
|
38
|
+
hasHeader(name: string): boolean;
|
|
39
|
+
removeHeader(name: string): this;
|
|
40
|
+
setHeaders(headers: Record<string, string | string[]>): this;
|
|
41
|
+
setCookie(name: string, value: string, options?: CookieOptions): this;
|
|
42
|
+
clearCookie(name: string, options?: CookieOptions): this;
|
|
43
|
+
getCookies(): string[];
|
|
44
|
+
redirect(url: string, statusCode?: number): this;
|
|
45
|
+
end(data: unknown): this;
|
|
46
|
+
error(data: unknown): this;
|
|
47
|
+
reset(): this;
|
|
48
|
+
toJSON(): Record<string, any>;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/types/response.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const executeControllerMethod: (controller: ControllerInstance, propertyName: string, request: AppRequest, response: ServerResponse) => Promise<any>;
|
|
1
|
+
import { ControllerInstance, ControllerMethods, CORSConfig, InterceptorCB, IRequest, IResponse, MiddlewareCB, SanitizerConfig } from '../types/index.js';
|
|
2
|
+
export declare const executeControllerMethod: (controller: ControllerInstance, propertyName: string, request: IRequest, response: IResponse) => Promise<any>;
|
|
4
3
|
export declare const getControllerMethods: (controller: ControllerInstance) => ControllerMethods;
|
|
5
4
|
export declare const getAllMethods: (obj: any) => string[];
|
|
6
5
|
export declare const findRouteInController: (instance: any, path: string, route: string, method: string) => {
|
|
@@ -16,10 +15,10 @@ export declare const getResponse: (data: {
|
|
|
16
15
|
controllerInstance: ControllerInstance;
|
|
17
16
|
name: string;
|
|
18
17
|
interceptors: InterceptorCB[];
|
|
19
|
-
request:
|
|
20
|
-
response:
|
|
18
|
+
request: IRequest;
|
|
19
|
+
response: IResponse;
|
|
21
20
|
}) => Promise<any>;
|
|
22
|
-
export declare const applyMiddlewaresVsSanitizers: (request:
|
|
21
|
+
export declare const applyMiddlewaresVsSanitizers: (request: IRequest, response: IResponse, functions: {
|
|
23
22
|
sanitizers: SanitizerConfig[][];
|
|
24
23
|
middlewares: MiddlewareCB[][];
|
|
25
24
|
}) => Promise<void>;
|