quantum-flow 1.20.1 → 1.20.3
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 +5 -4
- package/dist/app/aws/index.d.ts +1 -1
- package/dist/app/aws/utils/response.d.ts +12 -7
- package/dist/app/aws/utils/response.js +46 -15
- package/dist/app/aws/utils/response.js.map +1 -1
- package/dist/core/decorators.d.ts +3 -3
- package/dist/core/decorators.js +5 -5
- package/dist/core/decorators.js.map +1 -1
- package/dist/types/common.d.ts +11 -0
- package/dist/types/lambda.d.ts +13 -14
- package/dist/types/plugins.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,11 +134,12 @@ server.listen().catch(console.error);
|
|
|
134
134
|
- Use `@Headers` to access request headers.
|
|
135
135
|
- Use `@Query` to handle query parameters.
|
|
136
136
|
- Use `@Params` to access route parameters.
|
|
137
|
-
- Use `@
|
|
137
|
+
- Use `@Files` to access files sent within multipart/form-data requests.
|
|
138
|
+
Text sent as multipart/form-data is exposed with `@Body` decorators
|
|
138
139
|
- Use `@Request` to access the original request object.
|
|
139
140
|
- Use `@Response` to access the original object.
|
|
140
141
|
- Use `@InjectWS` to access the websocket service.
|
|
141
|
-
- Use `@InjectSSE
|
|
142
|
+
- Use `@InjectSSE` to access the server-side-event service.
|
|
142
143
|
|
|
143
144
|
# AWS Lambda Support
|
|
144
145
|
|
|
@@ -146,7 +147,7 @@ Use `LambdaAdapter` to convert API Gateway events to requests and responses. Cre
|
|
|
146
147
|
|
|
147
148
|
```typescript
|
|
148
149
|
Example Lambda handler creation
|
|
149
|
-
import { LambdaAdapter, LambdaRequest } from 'quantum-flow/aws';
|
|
150
|
+
import { LambdaAdapter, LambdaRequest, LambdaResponse } from 'quantum-flow/aws';
|
|
150
151
|
import { Request, Query, Headers, Params, Response } from 'quantum-flow/core'
|
|
151
152
|
|
|
152
153
|
@Controller({ prefix: 'user' })
|
|
@@ -156,7 +157,7 @@ class UserController {
|
|
|
156
157
|
@Headers() headers: Record<string, string | string[]>,
|
|
157
158
|
@Params(ParamDTO, 'param') params: string,
|
|
158
159
|
@Request() req: LambdaRequest,
|
|
159
|
-
@Response() res:
|
|
160
|
+
@Response() res: LambdaResponse
|
|
160
161
|
) { }
|
|
161
162
|
}
|
|
162
163
|
const lambdaAdapter = new LambdaAdapter(UserController);
|
package/dist/app/aws/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { LambdaEvent, LambdaRequest } from '../../types/index.js';
|
|
1
|
+
export { LambdaEvent, LambdaRequest, LambdaResponse } from '../../types/index.js';
|
|
2
2
|
export * from './lambda';
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare class LResponse implements ILResponse {
|
|
4
|
-
private originalResponse?;
|
|
1
|
+
import { CookieOptions, LambdaResponse } from '../../../types/index.js';
|
|
2
|
+
export declare class LResponse implements LambdaResponse {
|
|
5
3
|
private _statusCode;
|
|
6
4
|
private _headers;
|
|
7
5
|
body: any;
|
|
8
|
-
|
|
6
|
+
isBase64Encoded?: boolean;
|
|
7
|
+
_cookies: string[];
|
|
8
|
+
setCookie(name: string, value: string, options?: CookieOptions): void;
|
|
9
|
+
clearCookie(name: string, options?: {
|
|
10
|
+
path?: string;
|
|
11
|
+
domain?: string;
|
|
12
|
+
}): void;
|
|
13
|
+
getCookies(): string[];
|
|
14
|
+
clearAllCookies(): void;
|
|
15
|
+
private _updateCookieHeader;
|
|
9
16
|
setHeader(name: string, value: string): void;
|
|
10
17
|
set statusCode(code: number);
|
|
11
18
|
get statusCode(): number;
|
|
12
19
|
get headers(): Record<string, string>;
|
|
13
|
-
send(): void;
|
|
14
|
-
get original(): ServerResponse | undefined;
|
|
15
20
|
}
|
|
@@ -2,24 +2,61 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LResponse = void 0;
|
|
4
4
|
class LResponse {
|
|
5
|
-
originalResponse;
|
|
6
5
|
_statusCode = 200;
|
|
7
6
|
_headers = {};
|
|
8
7
|
body = null;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
isBase64Encoded;
|
|
9
|
+
_cookies;
|
|
10
|
+
setCookie(name, value, options) {
|
|
11
|
+
let cookie = `${name}=${encodeURIComponent(value)}`;
|
|
12
|
+
if (options) {
|
|
13
|
+
if (options.maxAge)
|
|
14
|
+
cookie += `; Max-Age=${options.maxAge}`;
|
|
15
|
+
if (options.expires)
|
|
16
|
+
cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
17
|
+
if (options.domain)
|
|
18
|
+
cookie += `; Domain=${options.domain}`;
|
|
19
|
+
if (options.path)
|
|
20
|
+
cookie += `; Path=${options.path}`;
|
|
21
|
+
if (options.secure)
|
|
22
|
+
cookie += `; Secure`;
|
|
23
|
+
if (options.httpOnly)
|
|
24
|
+
cookie += `; HttpOnly`;
|
|
25
|
+
if (options.sameSite)
|
|
26
|
+
cookie += `; SameSite=${options.sameSite}`;
|
|
27
|
+
if (options.priority)
|
|
28
|
+
cookie += `; Priority=${options.priority}`;
|
|
29
|
+
if (options.partitioned)
|
|
30
|
+
cookie += `; Partitioned`;
|
|
31
|
+
}
|
|
32
|
+
this._cookies.push(cookie);
|
|
33
|
+
this._updateCookieHeader();
|
|
34
|
+
}
|
|
35
|
+
clearCookie(name, options) {
|
|
36
|
+
const cookie = `${name}=; Max-Age=0; Expires=${new Date(0).toUTCString()}${options?.path ? `; Path=${options.path}` : ''}${options?.domain ? `; Domain=${options.domain}` : ''}`;
|
|
37
|
+
this._cookies.push(cookie);
|
|
38
|
+
this._updateCookieHeader();
|
|
39
|
+
}
|
|
40
|
+
getCookies() {
|
|
41
|
+
return [...this._cookies];
|
|
42
|
+
}
|
|
43
|
+
clearAllCookies() {
|
|
44
|
+
this._cookies = [];
|
|
45
|
+
delete this._headers['Set-Cookie'];
|
|
46
|
+
}
|
|
47
|
+
_updateCookieHeader() {
|
|
48
|
+
if (this._cookies.length > 0) {
|
|
49
|
+
this._headers['Set-Cookie'] = this._cookies.join(', ');
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
delete this._headers['Set-Cookie'];
|
|
53
|
+
}
|
|
11
54
|
}
|
|
12
55
|
setHeader(name, value) {
|
|
13
56
|
this._headers[name] = value;
|
|
14
|
-
if (this.originalResponse) {
|
|
15
|
-
this.originalResponse.setHeader(name, value);
|
|
16
|
-
}
|
|
17
57
|
}
|
|
18
58
|
set statusCode(code) {
|
|
19
59
|
this._statusCode = code;
|
|
20
|
-
if (this.originalResponse) {
|
|
21
|
-
this.originalResponse.statusCode = code;
|
|
22
|
-
}
|
|
23
60
|
}
|
|
24
61
|
get statusCode() {
|
|
25
62
|
return this._statusCode;
|
|
@@ -27,12 +64,6 @@ class LResponse {
|
|
|
27
64
|
get headers() {
|
|
28
65
|
return { ...this._headers };
|
|
29
66
|
}
|
|
30
|
-
send() {
|
|
31
|
-
throw `Lambda response doesn't have "send" method`;
|
|
32
|
-
}
|
|
33
|
-
get original() {
|
|
34
|
-
return this.originalResponse;
|
|
35
|
-
}
|
|
36
67
|
}
|
|
37
68
|
exports.LResponse = LResponse;
|
|
38
69
|
//# sourceMappingURL=response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/app/aws/utils/response.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/app/aws/utils/response.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;IACZ,WAAW,GAAW,GAAG,CAAC;IAC1B,QAAQ,GAA2B,EAAE,CAAC;IAC9C,IAAI,GAAQ,IAAI,CAAC;IACjB,eAAe,CAAW;IAC1B,QAAQ,CAAW;IAEnB,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,OAAuB;QAC5D,IAAI,MAAM,GAAG,GAAG,IAAI,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,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AI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAED,UAAU;QACR,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,eAAe;QACb,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;IAEO,mBAAmB;QACzB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,KAAa;QACnC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,IAAI,UAAU,CAAC,IAAY;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;CACF;AAnED,8BAmEC"}
|
|
@@ -78,11 +78,11 @@ export declare const Cookies: (name?: string) => (target: any, propertyKey: stri
|
|
|
78
78
|
*
|
|
79
79
|
* Usage:
|
|
80
80
|
* ```ts
|
|
81
|
-
* @
|
|
82
|
-
* @
|
|
81
|
+
* @Files() multipartData: any
|
|
82
|
+
* @Files('file') file: File
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
export declare const
|
|
85
|
+
export declare const Files: (name?: string) => (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
86
86
|
/**
|
|
87
87
|
* Parameter decorator to inject the response object.
|
|
88
88
|
*
|
package/dist/core/decorators.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Response = exports.
|
|
3
|
+
exports.Response = exports.Files = exports.Cookies = exports.Headers = exports.Request = exports.Query = exports.Params = exports.Body = void 0;
|
|
4
4
|
const _utils_1 = require("../utils/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Parameter decorator to extract and validate the request body.
|
|
@@ -88,12 +88,12 @@ exports.Cookies = Cookies;
|
|
|
88
88
|
*
|
|
89
89
|
* Usage:
|
|
90
90
|
* ```ts
|
|
91
|
-
* @
|
|
92
|
-
* @
|
|
91
|
+
* @Files() multipartData: any
|
|
92
|
+
* @Files('file') file: File
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
|
-
const
|
|
96
|
-
exports.
|
|
95
|
+
const Files = (name) => (0, _utils_1.createParamDecorator)('multipart', undefined, name);
|
|
96
|
+
exports.Files = Files;
|
|
97
97
|
/**
|
|
98
98
|
* Parameter decorator to inject the response object.
|
|
99
99
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/core/decorators.ts"],"names":[],"mappings":";;;AAAA,mCAA8C;AAE9C;;;;;;;;;;GAUG;AACI,MAAM,IAAI,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,IAAA,6BAAoB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAAxD,QAAA,IAAI,QAAoD;AAErE;;;;;;;;;;;;GAYG;AACI,MAAM,MAAM,GAAG,CAAC,GAAS,EAAE,IAAa,EAAE,EAAE,CACjD,IAAA,6BAAoB,EAClB,QAAQ,EACR,OAAO,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC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AAQ,GAAG,GAAG,EAAE,CAAC,IAAA,6BAAoB,EAAC,UAAU,CAAC,CAAC;AAAlD,QAAA,QAAQ,YAA0C"}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -64,4 +64,15 @@ export declare enum HTTP_METHODS {
|
|
|
64
64
|
OPTIONS = "OPTIONS",
|
|
65
65
|
HEAD = "HEAD"
|
|
66
66
|
}
|
|
67
|
+
export interface CookieOptions {
|
|
68
|
+
maxAge?: number;
|
|
69
|
+
expires?: Date;
|
|
70
|
+
domain?: string;
|
|
71
|
+
path?: string;
|
|
72
|
+
secure?: boolean;
|
|
73
|
+
httpOnly?: boolean;
|
|
74
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
75
|
+
priority?: 'Low' | 'Medium' | 'High';
|
|
76
|
+
partitioned?: boolean;
|
|
77
|
+
}
|
|
67
78
|
export {};
|
package/dist/types/lambda.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, Context, Handler } from 'aws-lambda';
|
|
2
|
-
import { HTTP_METHODS } from './common';
|
|
2
|
+
import { CookieOptions, HTTP_METHODS } from './common';
|
|
3
3
|
import { ControllerClass } from './controller';
|
|
4
4
|
import { MultipartFile } from './multipart';
|
|
5
5
|
import { LambdaPlugin } from './plugins';
|
|
@@ -51,14 +51,6 @@ export interface LambdaRequestMeta {
|
|
|
51
51
|
sourceIp?: string;
|
|
52
52
|
userAgent?: string;
|
|
53
53
|
}
|
|
54
|
-
export interface LambdaResponse {
|
|
55
|
-
statusCode: number;
|
|
56
|
-
headers?: Record<string, string>;
|
|
57
|
-
body: string;
|
|
58
|
-
isBase64Encoded?: boolean;
|
|
59
|
-
multiValueHeaders?: Record<string, string[]>;
|
|
60
|
-
cookies?: string[];
|
|
61
|
-
}
|
|
62
54
|
export interface LambdaApp {
|
|
63
55
|
beforeStart?: () => void;
|
|
64
56
|
}
|
|
@@ -86,13 +78,20 @@ export interface LambdaRequest {
|
|
|
86
78
|
sourceIp: string;
|
|
87
79
|
end(): void;
|
|
88
80
|
}
|
|
89
|
-
export interface
|
|
81
|
+
export interface LambdaResponse {
|
|
90
82
|
body: any;
|
|
91
|
-
setHeader(name: string, value: string): void;
|
|
92
83
|
statusCode: number;
|
|
93
|
-
headers
|
|
94
|
-
|
|
95
|
-
|
|
84
|
+
headers?: Record<string, string>;
|
|
85
|
+
cookies?: string[];
|
|
86
|
+
isBase64Encoded?: boolean;
|
|
87
|
+
setHeader(name: string, value: string): void;
|
|
88
|
+
setCookie(name: string, value: string, options?: CookieOptions): void;
|
|
89
|
+
clearCookie(name: string, options?: {
|
|
90
|
+
path?: string;
|
|
91
|
+
domain?: string;
|
|
92
|
+
}): void;
|
|
93
|
+
getCookies(): string[];
|
|
94
|
+
clearAllCookies(): void;
|
|
96
95
|
}
|
|
97
96
|
export interface ILambdaAdapter {
|
|
98
97
|
handler: Handler;
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Context } from 'aws-lambda';
|
|
|
2
2
|
import { IncomingMessage, Server, ServerResponse } from 'http';
|
|
3
3
|
import { AppRequest, MiddlewareCB } from './common';
|
|
4
4
|
import { IHttpServer } from './http';
|
|
5
|
-
import { ILambdaAdapter,
|
|
5
|
+
import { ILambdaAdapter, LambdaEvent, LambdaRequest, LambdaResponse } from './lambda';
|
|
6
6
|
export interface HttpPluginHooks {
|
|
7
7
|
beforeRequest?: (req: IncomingMessage) => void | Promise<void>;
|
|
8
8
|
beforeRoute?: (req: AppRequest, response: ServerResponse) => void | Promise<void>;
|
|
@@ -21,7 +21,7 @@ export type PluginKeys = keyof Omit<HttpPlugin, 'name' | 'hooks'>;
|
|
|
21
21
|
export interface LambdaPluginHooks {
|
|
22
22
|
beforeRequest?: (event: LambdaEvent, context: Context) => void | Promise<void>;
|
|
23
23
|
beforeRoute?: (req: LambdaRequest) => void | Promise<void>;
|
|
24
|
-
afterResponse?: (req: LambdaRequest, res:
|
|
24
|
+
afterResponse?: (req: LambdaRequest, res: LambdaResponse) => void | Promise<void>;
|
|
25
25
|
}
|
|
26
26
|
export interface LambdaPlugin {
|
|
27
27
|
name: string;
|