@tsed/platform-http 8.0.0 → 8.0.2
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 +1 -1
- package/lib/esm/common/index.js +0 -1
- package/lib/esm/common/index.js.map +1 -1
- package/lib/types/common/fn/adapter.d.ts +1 -1
- package/lib/types/common/index.d.ts +0 -1
- package/package.json +19 -17
- package/src/common/builder/PlatformBuilder.spec.ts +331 -0
- package/src/common/builder/PlatformBuilder.ts +426 -0
- package/src/common/builder/__fixtures__/PlatformCustom.ts +39 -0
- package/src/common/config/interfaces/PlatformJsonMapperSettings.ts +11 -0
- package/src/common/config/interfaces/PlatformMulterSettings.ts +21 -0
- package/src/common/config/interfaces/PlatformRouterSettings.ts +11 -0
- package/src/common/config/interfaces/PlatformStaticsSettings.ts +23 -0
- package/src/common/config/services/PlatformConfiguration.spec.ts +181 -0
- package/src/common/config/services/PlatformConfiguration.ts +157 -0
- package/src/common/constants/routerOptions.ts +1 -0
- package/src/common/decorators/PlatformProvider.ts +14 -0
- package/src/common/decorators/multer/multerFileSize.spec.ts +22 -0
- package/src/common/decorators/multer/multerFileSize.ts +32 -0
- package/src/common/decorators/multer/multerOptions.spec.ts +21 -0
- package/src/common/decorators/multer/multerOptions.ts +53 -0
- package/src/common/decorators/multer/multipartFile.spec.ts +259 -0
- package/src/common/decorators/multer/multipartFile.ts +88 -0
- package/src/common/decorators/params/error.spec.ts +15 -0
- package/src/common/decorators/params/error.ts +16 -0
- package/src/common/decorators/params/next.spec.ts +15 -0
- package/src/common/decorators/params/next.ts +31 -0
- package/src/common/decorators/params/request.spec.ts +49 -0
- package/src/common/decorators/params/request.ts +85 -0
- package/src/common/decorators/params/response.spec.ts +36 -0
- package/src/common/decorators/params/response.ts +73 -0
- package/src/common/domain/AnyToPromiseWithCtx.spec.ts +20 -0
- package/src/common/domain/AnyToPromiseWithCtx.ts +30 -0
- package/src/common/domain/EndpointMetadata.ts +1 -0
- package/src/common/domain/PlatformContext.spec.ts +124 -0
- package/src/common/domain/PlatformContext.ts +135 -0
- package/src/common/domain/PlatformRouteDetails.ts +7 -0
- package/src/common/exports.ts +4 -0
- package/src/common/fn/adapter.ts +23 -0
- package/src/common/fn/application.ts +11 -0
- package/src/common/index.ts +62 -0
- package/src/common/interfaces/AfterInit.ts +3 -0
- package/src/common/interfaces/AfterListen.ts +3 -0
- package/src/common/interfaces/AfterRoutesInit.ts +3 -0
- package/src/common/interfaces/BeforeInit.ts +3 -0
- package/src/common/interfaces/BeforeListen.ts +3 -0
- package/src/common/interfaces/BeforeRoutesInit.ts +3 -0
- package/src/common/interfaces/HandlerType.ts +12 -0
- package/src/common/interfaces/IncomingEvent.ts +6 -0
- package/src/common/interfaces/OnReady.ts +3 -0
- package/src/common/interfaces/OnRequest.ts +5 -0
- package/src/common/interfaces/OnResponse.ts +5 -0
- package/src/common/interfaces/OnRoutesInit.ts +3 -0
- package/src/common/interfaces/PlatformRouteOptions.ts +17 -0
- package/src/common/interfaces/ResponseErrorObject.ts +8 -0
- package/src/common/interfaces/Route.ts +12 -0
- package/src/common/middlewares/PlatformAcceptMimesMiddleware.spec.ts +215 -0
- package/src/common/middlewares/PlatformAcceptMimesMiddleware.ts +24 -0
- package/src/common/middlewares/PlatformMulterMiddleware.spec.ts +97 -0
- package/src/common/middlewares/PlatformMulterMiddleware.ts +59 -0
- package/src/common/services/Platform.spec.ts +145 -0
- package/src/common/services/Platform.ts +79 -0
- package/src/common/services/PlatformAdapter.ts +89 -0
- package/src/common/services/PlatformApplication.spec.ts +101 -0
- package/src/common/services/PlatformApplication.ts +54 -0
- package/src/common/services/PlatformHandler.spec.ts +152 -0
- package/src/common/services/PlatformHandler.ts +140 -0
- package/src/common/services/PlatformMiddlewaresChain.spec.ts +96 -0
- package/src/common/services/PlatformMiddlewaresChain.ts +55 -0
- package/src/common/services/PlatformRequest.spec.ts +185 -0
- package/src/common/services/PlatformRequest.ts +181 -0
- package/src/common/services/PlatformResponse.spec.ts +344 -0
- package/src/common/services/PlatformResponse.ts +388 -0
- package/src/common/utils/closeServer.spec.ts +11 -0
- package/src/common/utils/closeServer.ts +7 -0
- package/src/common/utils/createContext.spec.ts +111 -0
- package/src/common/utils/createContext.ts +52 -0
- package/src/common/utils/createHttpServer.spec.ts +74 -0
- package/src/common/utils/createHttpServer.ts +15 -0
- package/src/common/utils/createHttpsServer.spec.ts +73 -0
- package/src/common/utils/createHttpsServer.ts +16 -0
- package/src/common/utils/createInjector.spec.ts +42 -0
- package/src/common/utils/createInjector.ts +55 -0
- package/src/common/utils/createServer.ts +51 -0
- package/src/common/utils/ensureContext.spec.ts +41 -0
- package/src/common/utils/ensureContext.ts +17 -0
- package/src/common/utils/getConfiguration.spec.ts +163 -0
- package/src/common/utils/getConfiguration.ts +34 -0
- package/src/common/utils/getStaticsOptions.spec.ts +27 -0
- package/src/common/utils/getStaticsOptions.ts +24 -0
- package/src/common/utils/listenServer.ts +17 -0
- package/src/common/utils/mapReturnedResponse.spec.ts +35 -0
- package/src/common/utils/mapReturnedResponse.ts +10 -0
- package/src/common/utils/printRoutes.spec.ts +19 -0
- package/src/common/utils/printRoutes.ts +40 -0
- package/src/common/utils/resolveControllers.spec.ts +40 -0
- package/src/common/utils/resolveControllers.ts +54 -0
- package/src/common/utils/setResponseHeaders.spec.ts +84 -0
- package/src/common/utils/setResponseHeaders.ts +31 -0
- package/src/index.ts +2 -0
- package/src/testing/FakeAdapter.ts +69 -0
- package/src/testing/FakeResponse.ts +72 -0
- package/src/testing/PlatformTest.spec.ts +53 -0
- package/src/testing/PlatformTest.ts +157 -0
- package/src/testing/index.ts +5 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {AnyPromiseResult, AnyToPromise} from "@tsed/core";
|
|
2
|
+
|
|
3
|
+
import {PlatformContext} from "./PlatformContext.js";
|
|
4
|
+
|
|
5
|
+
export class AnyToPromiseWithCtx extends AnyToPromise {
|
|
6
|
+
public $ctx: PlatformContext;
|
|
7
|
+
|
|
8
|
+
constructor($ctx: PlatformContext) {
|
|
9
|
+
super();
|
|
10
|
+
this.$ctx = $ctx;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
isDone(): boolean {
|
|
14
|
+
const {$ctx} = this;
|
|
15
|
+
|
|
16
|
+
return $ctx?.isDone() || super.isDone();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
call(cb: Function): Promise<AnyPromiseResult<any>> {
|
|
20
|
+
return super.call(() => cb(this));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
destroy() {
|
|
24
|
+
(this.$ctx as any) = null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
isCanceledResponse(process: any) {
|
|
28
|
+
return process === this.$ctx.getResponse();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {EndpointMetadata} from "@tsed/schema";
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {nameOf} from "@tsed/core";
|
|
2
|
+
|
|
3
|
+
import {PlatformTest} from "../../testing/PlatformTest.js";
|
|
4
|
+
import {PlatformApplication} from "../services/PlatformApplication.js";
|
|
5
|
+
import {PlatformContext} from "./PlatformContext.js";
|
|
6
|
+
|
|
7
|
+
describe("PlatformContext", () => {
|
|
8
|
+
beforeEach(() => PlatformTest.create());
|
|
9
|
+
afterEach(() => PlatformTest.reset());
|
|
10
|
+
it("should create a new Context and skip log", () => {
|
|
11
|
+
const logger = {
|
|
12
|
+
info: vi.fn()
|
|
13
|
+
};
|
|
14
|
+
const context = new PlatformContext({
|
|
15
|
+
event: {
|
|
16
|
+
response: PlatformTest.createResponse(),
|
|
17
|
+
request: PlatformTest.createRequest({
|
|
18
|
+
url: "/admin"
|
|
19
|
+
})
|
|
20
|
+
},
|
|
21
|
+
id: "id",
|
|
22
|
+
logger,
|
|
23
|
+
maxStackSize: 0,
|
|
24
|
+
ignoreUrlPatterns: ["/admin", /\/admin2/],
|
|
25
|
+
injector: PlatformTest.injector
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
context.endpoint = {} as any;
|
|
29
|
+
context.logger.info("test");
|
|
30
|
+
|
|
31
|
+
context.handlerMetadata = {} as any;
|
|
32
|
+
context.endpoint = {} as any;
|
|
33
|
+
|
|
34
|
+
expect(context.id).toEqual("id");
|
|
35
|
+
expect(context.dateStart).toBeInstanceOf(Date);
|
|
36
|
+
expect(context.container).toBeInstanceOf(Map);
|
|
37
|
+
expect(context.env).toEqual("test");
|
|
38
|
+
expect(context.getRequest()).toEqual(context.request.raw);
|
|
39
|
+
expect(context.getResponse()).toEqual(context.response.raw);
|
|
40
|
+
expect(context.getReq()).toEqual(context.request.raw);
|
|
41
|
+
expect(context.getRes()).toEqual(context.response.raw);
|
|
42
|
+
expect(context.app).toBeInstanceOf(PlatformApplication);
|
|
43
|
+
expect(context.handlerMetadata).toEqual({});
|
|
44
|
+
expect(context.endpoint).toEqual({});
|
|
45
|
+
expect(nameOf(context.getApp())).toEqual("FakeRawDriver");
|
|
46
|
+
});
|
|
47
|
+
it("should create a new Context and log event", () => {
|
|
48
|
+
const logger = {
|
|
49
|
+
info: vi.fn()
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const context = new PlatformContext({
|
|
53
|
+
id: "id",
|
|
54
|
+
event: {
|
|
55
|
+
response: PlatformTest.createResponse(),
|
|
56
|
+
request: PlatformTest.createRequest({
|
|
57
|
+
url: "/"
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
logger,
|
|
61
|
+
injector: PlatformTest.injector,
|
|
62
|
+
maxStackSize: 0,
|
|
63
|
+
ignoreUrlPatterns: ["/admin", /\/admin2/]
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
context.logger.info("test");
|
|
67
|
+
|
|
68
|
+
expect(context.id).toEqual("id");
|
|
69
|
+
expect(context.dateStart).toBeInstanceOf(Date);
|
|
70
|
+
expect(context.container).toBeInstanceOf(Map);
|
|
71
|
+
expect(context.env).toEqual("test");
|
|
72
|
+
expect(context.app).toBeInstanceOf(PlatformApplication);
|
|
73
|
+
expect(nameOf(context.getApp())).toEqual("FakeRawDriver");
|
|
74
|
+
});
|
|
75
|
+
it("should return done when the response is empty", async () => {
|
|
76
|
+
const context = new PlatformContext({
|
|
77
|
+
id: "id",
|
|
78
|
+
event: {
|
|
79
|
+
response: PlatformTest.createResponse(),
|
|
80
|
+
request: PlatformTest.createRequest({
|
|
81
|
+
url: "/"
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
logger: {
|
|
85
|
+
info: vi.fn()
|
|
86
|
+
},
|
|
87
|
+
injector: PlatformTest.injector,
|
|
88
|
+
maxStackSize: 0,
|
|
89
|
+
ignoreUrlPatterns: ["/admin"]
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(context.isDone()).toEqual(false);
|
|
93
|
+
|
|
94
|
+
await context.finish();
|
|
95
|
+
|
|
96
|
+
expect(context.isDone()).toEqual(true);
|
|
97
|
+
});
|
|
98
|
+
it("should return done when the response is empty (start context before)", async () => {
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
const context = new PlatformContext({
|
|
101
|
+
id: "id",
|
|
102
|
+
event: {
|
|
103
|
+
response: PlatformTest.createResponse(),
|
|
104
|
+
request: PlatformTest.createRequest({
|
|
105
|
+
url: "/"
|
|
106
|
+
})
|
|
107
|
+
},
|
|
108
|
+
logger: {
|
|
109
|
+
info: vi.fn()
|
|
110
|
+
},
|
|
111
|
+
injector: PlatformTest.injector,
|
|
112
|
+
maxStackSize: 0,
|
|
113
|
+
ignoreUrlPatterns: ["/admin"]
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
await context.start();
|
|
117
|
+
|
|
118
|
+
expect(context.isDone()).toEqual(false);
|
|
119
|
+
|
|
120
|
+
await context.finish();
|
|
121
|
+
|
|
122
|
+
expect(context.isDone()).toEqual(true);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {DIContext, DIContextOptions, injector} from "@tsed/di";
|
|
2
|
+
import {$asyncEmit} from "@tsed/hooks";
|
|
3
|
+
import {PlatformHandlerMetadata} from "@tsed/platform-router";
|
|
4
|
+
import {EndpointMetadata} from "@tsed/schema";
|
|
5
|
+
import {IncomingMessage, ServerResponse} from "http";
|
|
6
|
+
|
|
7
|
+
import {IncomingEvent} from "../interfaces/IncomingEvent.js";
|
|
8
|
+
import {PlatformApplication} from "../services/PlatformApplication.js";
|
|
9
|
+
import {PlatformRequest} from "../services/PlatformRequest.js";
|
|
10
|
+
import {PlatformResponse} from "../services/PlatformResponse.js";
|
|
11
|
+
|
|
12
|
+
declare global {
|
|
13
|
+
namespace TsED {
|
|
14
|
+
export interface Context extends PlatformContext {}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PlatformContextOptions extends DIContextOptions {
|
|
19
|
+
event: IncomingEvent;
|
|
20
|
+
ignoreUrlPatterns?: any[];
|
|
21
|
+
endpoint?: EndpointMetadata;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class PlatformContext<
|
|
25
|
+
PReq extends PlatformRequest = PlatformRequest,
|
|
26
|
+
PRes extends PlatformResponse = PlatformResponse
|
|
27
|
+
> extends DIContext {
|
|
28
|
+
readonly PLATFORM: string = "WWW";
|
|
29
|
+
public event: IncomingEvent;
|
|
30
|
+
/**
|
|
31
|
+
* The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
|
|
32
|
+
*/
|
|
33
|
+
public data: any;
|
|
34
|
+
/**
|
|
35
|
+
* The error caught by the current handler
|
|
36
|
+
*/
|
|
37
|
+
public error?: unknown;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
public next?: any;
|
|
42
|
+
/**
|
|
43
|
+
* The current @@PlatformResponse@@.
|
|
44
|
+
*/
|
|
45
|
+
readonly response: PRes;
|
|
46
|
+
/**
|
|
47
|
+
* The current @@PlatformRequest@@.
|
|
48
|
+
*/
|
|
49
|
+
readonly request: PReq;
|
|
50
|
+
/**
|
|
51
|
+
* The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
|
|
52
|
+
*/
|
|
53
|
+
endpoint: EndpointMetadata;
|
|
54
|
+
/**
|
|
55
|
+
* The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.
|
|
56
|
+
*/
|
|
57
|
+
handlerMetadata: PlatformHandlerMetadata;
|
|
58
|
+
|
|
59
|
+
#isFinished: boolean = false;
|
|
60
|
+
|
|
61
|
+
constructor(options: PlatformContextOptions) {
|
|
62
|
+
super(options);
|
|
63
|
+
|
|
64
|
+
options.endpoint && (this.endpoint = options.endpoint);
|
|
65
|
+
|
|
66
|
+
this.event = options.event;
|
|
67
|
+
this.response = new (options.ResponseKlass || PlatformResponse)(this);
|
|
68
|
+
this.request = new (options.RequestKlass || PlatformRequest)(this);
|
|
69
|
+
|
|
70
|
+
this.request.request.$ctx = this;
|
|
71
|
+
this.request.request.id = this.id;
|
|
72
|
+
|
|
73
|
+
this.response.setHeader("x-request-id", this.id);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get url() {
|
|
77
|
+
return this.request.url;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get app() {
|
|
81
|
+
return injector().get<PlatformApplication>(PlatformApplication)!;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
start() {
|
|
85
|
+
return $asyncEmit("$onRequest", [this]);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async finish() {
|
|
89
|
+
await Promise.all([$asyncEmit("$onResponse", [this]), this.destroy()]);
|
|
90
|
+
this.#isFinished = true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
isFinished() {
|
|
94
|
+
return this.#isFinished;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
isDone() {
|
|
98
|
+
return this.request?.isAborted() || this.response?.isDone() || this.isFinished();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Return the framework request instance (Express, Koa, etc...)
|
|
103
|
+
*/
|
|
104
|
+
getRequest<Req = any>(): Req {
|
|
105
|
+
return this.request.getRequest<Req>();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Return the framework response instance (Express, Koa, etc...)
|
|
110
|
+
*/
|
|
111
|
+
getResponse<Res = any>(): Res {
|
|
112
|
+
return this.response.getResponse<Res>();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get Node.js request
|
|
117
|
+
*/
|
|
118
|
+
getReq(): IncomingMessage {
|
|
119
|
+
return this.request.getReq();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get Node.js response
|
|
124
|
+
*/
|
|
125
|
+
getRes(): ServerResponse {
|
|
126
|
+
return this.response.getRes();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Return the original application instance.
|
|
131
|
+
*/
|
|
132
|
+
getApp<T = any>(): T {
|
|
133
|
+
return this.app.getApp() as any;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {Type} from "@tsed/core";
|
|
2
|
+
import {refValue} from "@tsed/di";
|
|
3
|
+
|
|
4
|
+
import type {PlatformAdapter} from "../services/PlatformAdapter.js";
|
|
5
|
+
|
|
6
|
+
const ADAPTER = "platform.adapter";
|
|
7
|
+
|
|
8
|
+
let globalAdapter: Type<PlatformAdapter<any>>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Set the platform adapter
|
|
12
|
+
*/
|
|
13
|
+
export function adapter(adapter?: Type<PlatformAdapter<any>>): Type<PlatformAdapter<any>> {
|
|
14
|
+
const ref = refValue<Type<PlatformAdapter<any>>>(ADAPTER);
|
|
15
|
+
|
|
16
|
+
if (adapter) {
|
|
17
|
+
globalAdapter ||= adapter;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ref.value ||= globalAdapter;
|
|
21
|
+
|
|
22
|
+
return ref.value as Type<PlatformAdapter<any>>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {injector} from "@tsed/di";
|
|
2
|
+
|
|
3
|
+
import type {PlatformApplication} from "../services/PlatformApplication.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Return the injectable Application instance.
|
|
7
|
+
* @note Application is only available after PlatformExpress/PlatformKoa instance creation.
|
|
8
|
+
*/
|
|
9
|
+
export function application<App = TsED.Application>() {
|
|
10
|
+
return injector().get<PlatformApplication<App>>("PlatformApplication")!;
|
|
11
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by @tsed/barrels.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./builder/PlatformBuilder.js";
|
|
5
|
+
export * from "./config/interfaces/PlatformJsonMapperSettings.js";
|
|
6
|
+
export * from "./config/interfaces/PlatformMulterSettings.js";
|
|
7
|
+
export * from "./config/interfaces/PlatformRouterSettings.js";
|
|
8
|
+
export * from "./config/interfaces/PlatformStaticsSettings.js";
|
|
9
|
+
export * from "./config/services/PlatformConfiguration.js";
|
|
10
|
+
export * from "./constants/routerOptions.js";
|
|
11
|
+
export * from "./decorators/multer/multerFileSize.js";
|
|
12
|
+
export * from "./decorators/multer/multerOptions.js";
|
|
13
|
+
export * from "./decorators/multer/multipartFile.js";
|
|
14
|
+
export * from "./decorators/params/error.js";
|
|
15
|
+
export * from "./decorators/params/next.js";
|
|
16
|
+
export * from "./decorators/params/request.js";
|
|
17
|
+
export * from "./decorators/params/response.js";
|
|
18
|
+
export * from "./decorators/PlatformProvider.js";
|
|
19
|
+
export * from "./domain/AnyToPromiseWithCtx.js";
|
|
20
|
+
export * from "./domain/EndpointMetadata.js";
|
|
21
|
+
export * from "./domain/PlatformContext.js";
|
|
22
|
+
export * from "./domain/PlatformRouteDetails.js";
|
|
23
|
+
export * from "./exports.js";
|
|
24
|
+
export * from "./fn/adapter.js";
|
|
25
|
+
export * from "./fn/application.js";
|
|
26
|
+
export * from "./interfaces/AfterInit.js";
|
|
27
|
+
export * from "./interfaces/AfterListen.js";
|
|
28
|
+
export * from "./interfaces/AfterRoutesInit.js";
|
|
29
|
+
export * from "./interfaces/BeforeInit.js";
|
|
30
|
+
export * from "./interfaces/BeforeListen.js";
|
|
31
|
+
export * from "./interfaces/BeforeRoutesInit.js";
|
|
32
|
+
export * from "./interfaces/HandlerType.js";
|
|
33
|
+
export * from "./interfaces/IncomingEvent.js";
|
|
34
|
+
export * from "./interfaces/OnReady.js";
|
|
35
|
+
export * from "./interfaces/OnRequest.js";
|
|
36
|
+
export * from "./interfaces/OnResponse.js";
|
|
37
|
+
export * from "./interfaces/OnRoutesInit.js";
|
|
38
|
+
export * from "./interfaces/PlatformRouteOptions.js";
|
|
39
|
+
export * from "./interfaces/ResponseErrorObject.js";
|
|
40
|
+
export * from "./interfaces/Route.js";
|
|
41
|
+
export * from "./middlewares/PlatformAcceptMimesMiddleware.js";
|
|
42
|
+
export * from "./middlewares/PlatformMulterMiddleware.js";
|
|
43
|
+
export * from "./services/Platform.js";
|
|
44
|
+
export * from "./services/PlatformAdapter.js";
|
|
45
|
+
export * from "./services/PlatformApplication.js";
|
|
46
|
+
export * from "./services/PlatformHandler.js";
|
|
47
|
+
export * from "./services/PlatformMiddlewaresChain.js";
|
|
48
|
+
export * from "./services/PlatformRequest.js";
|
|
49
|
+
export * from "./services/PlatformResponse.js";
|
|
50
|
+
export * from "./utils/closeServer.js";
|
|
51
|
+
export * from "./utils/createContext.js";
|
|
52
|
+
export * from "./utils/createHttpServer.js";
|
|
53
|
+
export * from "./utils/createHttpsServer.js";
|
|
54
|
+
export * from "./utils/createInjector.js";
|
|
55
|
+
export * from "./utils/createServer.js";
|
|
56
|
+
export * from "./utils/ensureContext.js";
|
|
57
|
+
export * from "./utils/getStaticsOptions.js";
|
|
58
|
+
export * from "./utils/listenServer.js";
|
|
59
|
+
export * from "./utils/mapReturnedResponse.js";
|
|
60
|
+
export * from "./utils/printRoutes.js";
|
|
61
|
+
export * from "./utils/resolveControllers.js";
|
|
62
|
+
export * from "./utils/setResponseHeaders.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {Type} from "@tsed/core";
|
|
2
|
+
import {PathType} from "@tsed/di";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
export interface PlatformRouteOptions {
|
|
8
|
+
token?: Type<any>;
|
|
9
|
+
path?: PathType | undefined;
|
|
10
|
+
method?: string;
|
|
11
|
+
handlers: any[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
export type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, "handlers">>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {Provider, TokenProvider} from "@tsed/di";
|
|
2
|
+
|
|
3
|
+
export interface Route extends Record<string, any> {
|
|
4
|
+
route: string;
|
|
5
|
+
token: TokenProvider;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface RouteController {
|
|
9
|
+
route: string;
|
|
10
|
+
routes: Set<string>;
|
|
11
|
+
provider: Provider;
|
|
12
|
+
}
|