@tsed/common 6.118.0-rc.1 → 6.119.1
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/jest.config.js +3 -3
- package/lib/cjs/domain/PlatformContext.js +41 -29
- package/lib/cjs/domain/PlatformContext.js.map +1 -1
- package/lib/cjs/domain/PlatformRouteDetails.js +2 -0
- package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
- package/lib/cjs/services/PlatformRequest.js +13 -18
- package/lib/cjs/services/PlatformRequest.js.map +1 -1
- package/lib/cjs/services/PlatformResponse.js +10 -13
- package/lib/cjs/services/PlatformResponse.js.map +1 -1
- package/lib/cjs/services/PlatformTest.js +16 -3
- package/lib/cjs/services/PlatformTest.js.map +1 -1
- package/lib/cjs/utils/createContext.js +25 -9
- package/lib/cjs/utils/createContext.js.map +1 -1
- package/lib/esm/domain/PlatformContext.js +41 -29
- package/lib/esm/domain/PlatformContext.js.map +1 -1
- package/lib/esm/domain/PlatformRouteDetails.js +2 -0
- package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
- package/lib/esm/services/PlatformRequest.js +13 -18
- package/lib/esm/services/PlatformRequest.js.map +1 -1
- package/lib/esm/services/PlatformResponse.js +10 -13
- package/lib/esm/services/PlatformResponse.js.map +1 -1
- package/lib/esm/services/PlatformTest.js +16 -3
- package/lib/esm/services/PlatformTest.js.map +1 -1
- package/lib/esm/utils/createContext.js +23 -8
- package/lib/esm/utils/createContext.js.map +1 -1
- package/lib/types/domain/PlatformContext.d.ts +19 -13
- package/lib/types/services/PlatformRequest.d.ts +11 -8
- package/lib/types/services/PlatformResponse.d.ts +8 -9
- package/lib/types/services/PlatformTest.d.ts +2 -2
- package/lib/types/utils/createContext.d.ts +4 -1
- package/package.json +16 -19
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ContextMethods, DIContext, DIContextOptions } from "@tsed/di";
|
|
3
3
|
import { EndpointMetadata } from "@tsed/schema";
|
|
4
4
|
import { IncomingMessage, ServerResponse } from "http";
|
|
5
|
+
import { IncomingEvent } from "../interfaces/IncomingEvent";
|
|
5
6
|
import { PlatformApplication } from "../services/PlatformApplication";
|
|
6
7
|
import { PlatformRequest } from "../services/PlatformRequest";
|
|
7
8
|
import { PlatformResponse } from "../services/PlatformResponse";
|
|
@@ -12,36 +13,40 @@ declare global {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
export interface PlatformContextOptions extends DIContextOptions {
|
|
15
|
-
event:
|
|
16
|
-
response?: ServerResponse;
|
|
17
|
-
request?: IncomingMessage;
|
|
18
|
-
};
|
|
16
|
+
event: IncomingEvent;
|
|
19
17
|
ignoreUrlPatterns?: any[];
|
|
20
18
|
endpoint?: EndpointMetadata;
|
|
21
19
|
}
|
|
22
|
-
export declare class PlatformContext extends DIContext implements ContextMethods {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
endpoint: EndpointMetadata;
|
|
20
|
+
export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse> extends DIContext implements ContextMethods {
|
|
21
|
+
#private;
|
|
22
|
+
event: IncomingEvent;
|
|
27
23
|
/**
|
|
28
24
|
* The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
|
|
29
25
|
*/
|
|
30
26
|
data: any;
|
|
27
|
+
/**
|
|
28
|
+
* The error caught by the current handler
|
|
29
|
+
*/
|
|
30
|
+
error?: unknown;
|
|
31
31
|
/**
|
|
32
32
|
* The current @@PlatformResponse@@.
|
|
33
33
|
*/
|
|
34
|
-
readonly response:
|
|
34
|
+
readonly response: PRes;
|
|
35
35
|
/**
|
|
36
36
|
* The current @@PlatformRequest@@.
|
|
37
37
|
*/
|
|
38
|
-
readonly request:
|
|
38
|
+
readonly request: PReq;
|
|
39
39
|
private ignoreUrlPatterns;
|
|
40
|
-
constructor(
|
|
40
|
+
constructor(options: PlatformContextOptions);
|
|
41
|
+
/**
|
|
42
|
+
* The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
|
|
43
|
+
*/
|
|
44
|
+
get endpoint(): EndpointMetadata;
|
|
45
|
+
set endpoint(endpoint: EndpointMetadata);
|
|
41
46
|
get url(): string;
|
|
42
47
|
get app(): PlatformApplication<TsED.Application, TsED.Router>;
|
|
43
48
|
destroy(): Promise<void>;
|
|
44
|
-
isDone():
|
|
49
|
+
isDone(): any;
|
|
45
50
|
/**
|
|
46
51
|
* Return the framework request instance (Express, Koa, etc...)
|
|
47
52
|
*/
|
|
@@ -62,4 +67,5 @@ export declare class PlatformContext extends DIContext implements ContextMethods
|
|
|
62
67
|
* Return the original application instance.
|
|
63
68
|
*/
|
|
64
69
|
getApp<T = any>(): T;
|
|
70
|
+
upgrade(event: IncomingEvent): void;
|
|
65
71
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingHttpHeaders, IncomingMessage } from "http";
|
|
3
3
|
import type { PlatformContext } from "../domain/PlatformContext";
|
|
4
|
-
import { IncomingEvent } from "../interfaces/IncomingEvent";
|
|
5
4
|
import type { PlatformResponse } from "./PlatformResponse";
|
|
6
5
|
declare global {
|
|
7
6
|
namespace TsED {
|
|
8
7
|
interface Request {
|
|
9
8
|
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
10
12
|
$ctx: PlatformContext;
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -15,16 +17,16 @@ declare global {
|
|
|
15
17
|
* Platform Request abstraction layer.
|
|
16
18
|
* @platform
|
|
17
19
|
*/
|
|
18
|
-
export declare class PlatformRequest<
|
|
20
|
+
export declare class PlatformRequest<Req extends {
|
|
19
21
|
[key: string]: any;
|
|
20
22
|
} = any> {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
readonly $ctx: PlatformContext;
|
|
24
|
+
constructor($ctx: PlatformContext);
|
|
23
25
|
/**
|
|
24
26
|
* The current @@PlatformResponse@@.
|
|
25
27
|
*/
|
|
26
|
-
response: PlatformResponse;
|
|
27
|
-
|
|
28
|
+
get response(): PlatformResponse;
|
|
29
|
+
get raw(): Req;
|
|
28
30
|
get secure(): boolean;
|
|
29
31
|
get host(): string;
|
|
30
32
|
get protocol(): string;
|
|
@@ -72,10 +74,11 @@ export declare class PlatformRequest<T extends {
|
|
|
72
74
|
[key: string]: any;
|
|
73
75
|
};
|
|
74
76
|
get files(): any;
|
|
77
|
+
get route(): any;
|
|
75
78
|
/**
|
|
76
79
|
* Return the original request framework instance
|
|
77
80
|
*/
|
|
78
|
-
get request():
|
|
81
|
+
get request(): Req;
|
|
79
82
|
/**
|
|
80
83
|
* Return the original request node.js instance
|
|
81
84
|
*/
|
|
@@ -104,7 +107,7 @@ export declare class PlatformRequest<T extends {
|
|
|
104
107
|
/**
|
|
105
108
|
* Return the Framework response object (express, koa, etc...)
|
|
106
109
|
*/
|
|
107
|
-
getRequest<
|
|
110
|
+
getRequest<R = Req>(): R;
|
|
108
111
|
/**
|
|
109
112
|
* Return the Node.js response object
|
|
110
113
|
*/
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { OutgoingHttpHeaders, ServerResponse } from "http";
|
|
3
|
-
import { IncomingEvent } from "../interfaces/IncomingEvent";
|
|
4
3
|
import type { PlatformRequest } from "./PlatformRequest";
|
|
5
4
|
import type { PlatformContext } from "../domain/PlatformContext";
|
|
6
5
|
declare global {
|
|
@@ -14,15 +13,15 @@ export declare type HeaderValue = Array<boolean | number | string> | boolean | n
|
|
|
14
13
|
* Platform Response abstraction layer.
|
|
15
14
|
* @platform
|
|
16
15
|
*/
|
|
17
|
-
export declare class PlatformResponse<
|
|
18
|
-
|
|
16
|
+
export declare class PlatformResponse<Res extends Record<string, any> = any> {
|
|
17
|
+
readonly $ctx: PlatformContext;
|
|
18
|
+
data: any;
|
|
19
|
+
constructor($ctx: PlatformContext);
|
|
19
20
|
/**
|
|
20
21
|
* The current @@PlatformRequest@@.
|
|
21
22
|
*/
|
|
22
|
-
request: PlatformRequest;
|
|
23
|
-
|
|
24
|
-
raw: T;
|
|
25
|
-
constructor({ response }: IncomingEvent, $ctx: PlatformContext);
|
|
23
|
+
get request(): PlatformRequest;
|
|
24
|
+
get raw(): Res;
|
|
26
25
|
/**
|
|
27
26
|
* Get the current statusCode
|
|
28
27
|
*/
|
|
@@ -36,7 +35,7 @@ export declare class PlatformResponse<T extends Record<string, any> = any> {
|
|
|
36
35
|
/**
|
|
37
36
|
* Return the original response framework instance
|
|
38
37
|
*/
|
|
39
|
-
get response():
|
|
38
|
+
get response(): Res;
|
|
40
39
|
/**
|
|
41
40
|
* Return the original response node.js instance
|
|
42
41
|
*/
|
|
@@ -56,7 +55,7 @@ export declare class PlatformResponse<T extends Record<string, any> = any> {
|
|
|
56
55
|
/**
|
|
57
56
|
* Return the Framework response object (express, koa, etc...)
|
|
58
57
|
*/
|
|
59
|
-
getResponse<
|
|
58
|
+
getResponse<R = Res>(): R;
|
|
60
59
|
/**
|
|
61
60
|
* Return the Node.js response object
|
|
62
61
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DITest, DITestOptions, InjectorService } from "@tsed/di";
|
|
2
1
|
import { Type } from "@tsed/core";
|
|
2
|
+
import { DITest, DITestOptions, InjectorService } from "@tsed/di";
|
|
3
3
|
import { PlatformContext, PlatformContextOptions } from "../domain/PlatformContext";
|
|
4
4
|
import { PlatformAdapter, PlatformBuilderSettings } from "./PlatformAdapter";
|
|
5
5
|
/**
|
|
@@ -54,5 +54,5 @@ export declare class PlatformTest extends DITest {
|
|
|
54
54
|
static callback(): any;
|
|
55
55
|
static createRequest(options?: any): any;
|
|
56
56
|
static createResponse(options?: any): any;
|
|
57
|
-
static createRequestContext(options?: Partial<PlatformContextOptions & any>): PlatformContext
|
|
57
|
+
static createRequestContext(options?: Partial<PlatformContextOptions & any>): PlatformContext<import("./PlatformRequest").PlatformRequest<any>, import("./PlatformResponse").PlatformResponse<any>>;
|
|
58
58
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { InjectorService } from "@tsed/di";
|
|
2
2
|
import { PlatformContext } from "../domain/PlatformContext";
|
|
3
|
+
import { PlatformRequest } from "../services/PlatformRequest";
|
|
4
|
+
import { PlatformResponse } from "../services/PlatformResponse";
|
|
3
5
|
import { IncomingEvent } from "../interfaces/IncomingEvent";
|
|
6
|
+
export declare function ignoreLog(ignoreUrlPatterns: any[] | undefined): ((ignore: boolean, data: any, url: string) => any) | undefined;
|
|
4
7
|
/**
|
|
5
8
|
* Create the TsED context to wrap request, response, injector, etc...
|
|
6
9
|
* @param injector
|
|
7
10
|
* @ignore
|
|
8
11
|
*/
|
|
9
|
-
export declare function createContext(injector: InjectorService): (event: IncomingEvent) => Promise<PlatformContext
|
|
12
|
+
export declare function createContext(injector: InjectorService): (event: IncomingEvent) => Promise<PlatformContext<PlatformRequest<any>, PlatformResponse<any>>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.119.1",
|
|
4
4
|
"description": "A TypeScript Framework on top of Express",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -62,22 +62,22 @@
|
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@tsed/components-scan": "6.
|
|
66
|
-
"@tsed/core": "6.
|
|
67
|
-
"@tsed/di": "6.
|
|
68
|
-
"@tsed/exceptions": "6.
|
|
69
|
-
"@tsed/json-mapper": "6.
|
|
65
|
+
"@tsed/components-scan": "6.119.1",
|
|
66
|
+
"@tsed/core": "6.119.1",
|
|
67
|
+
"@tsed/di": "6.119.1",
|
|
68
|
+
"@tsed/exceptions": "6.119.1",
|
|
69
|
+
"@tsed/json-mapper": "6.119.1",
|
|
70
70
|
"@tsed/logger": ">=6.2.0",
|
|
71
71
|
"@tsed/logger-file": ">=6.2.0",
|
|
72
|
-
"@tsed/perf": "6.
|
|
73
|
-
"@tsed/platform-cache": "6.
|
|
74
|
-
"@tsed/platform-exceptions": "6.
|
|
75
|
-
"@tsed/platform-log-middleware": "6.
|
|
76
|
-
"@tsed/platform-middlewares": "6.
|
|
77
|
-
"@tsed/platform-params": "6.
|
|
78
|
-
"@tsed/platform-response-filter": "6.
|
|
79
|
-
"@tsed/platform-views": "6.
|
|
80
|
-
"@tsed/schema": "6.
|
|
72
|
+
"@tsed/perf": "6.119.1",
|
|
73
|
+
"@tsed/platform-cache": "6.119.1",
|
|
74
|
+
"@tsed/platform-exceptions": "6.119.1",
|
|
75
|
+
"@tsed/platform-log-middleware": "6.119.1",
|
|
76
|
+
"@tsed/platform-middlewares": "6.119.1",
|
|
77
|
+
"@tsed/platform-params": "6.119.1",
|
|
78
|
+
"@tsed/platform-response-filter": "6.119.1",
|
|
79
|
+
"@tsed/platform-views": "6.119.1",
|
|
80
|
+
"@tsed/schema": "6.119.1",
|
|
81
81
|
"@types/json-schema": "7.0.11",
|
|
82
82
|
"@types/on-finished": "2.3.1",
|
|
83
83
|
"on-finished": "2.4.1",
|
|
@@ -96,8 +96,5 @@
|
|
|
96
96
|
"optional": false
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"devDependencies": {}
|
|
100
|
-
"publishConfig": {
|
|
101
|
-
"tag": "rc"
|
|
102
|
-
}
|
|
99
|
+
"devDependencies": {}
|
|
103
100
|
}
|