@tsed/common 8.0.0-alpha.4 → 8.0.0-alpha.6
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/lib/esm/services/PlatformTest.js.map +1 -1
- package/lib/types/builder/PlatformBuilder.d.ts +1 -1
- package/lib/types/config/services/PlatformConfiguration.d.ts +1 -1
- package/lib/types/domain/PlatformContext.d.ts +1 -1
- package/lib/types/interfaces/IncomingEvent.d.ts +1 -1
- package/lib/types/services/FakeResponse.d.ts +1 -1
- package/lib/types/services/PlatformAdapter.d.ts +1 -1
- package/lib/types/services/PlatformApplication.d.ts +1 -1
- package/lib/types/services/PlatformRequest.d.ts +1 -1
- package/lib/types/services/PlatformResponse.d.ts +2 -2
- package/lib/types/services/PlatformTest.d.ts +1 -1
- package/lib/types/utils/closeServer.d.ts +3 -3
- package/lib/types/utils/createHttpServer.d.ts +1 -1
- package/lib/types/utils/createHttpsServer.d.ts +1 -1
- package/lib/types/utils/createServer.d.ts +3 -3
- package/lib/types/utils/listenServer.d.ts +3 -3
- package/package.json +19 -20
- package/lib/cjs/builder/PlatformBuilder.js +0 -341
- package/lib/cjs/builder/PlatformBuilder.js.map +0 -1
- package/lib/cjs/config/interfaces/PlatformJsonMapperSettings.js +0 -3
- package/lib/cjs/config/interfaces/PlatformJsonMapperSettings.js.map +0 -1
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js +0 -3
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +0 -1
- package/lib/cjs/config/interfaces/PlatformRouterSettings.js +0 -3
- package/lib/cjs/config/interfaces/PlatformRouterSettings.js.map +0 -1
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +0 -3
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +0 -1
- package/lib/cjs/config/services/PlatformConfiguration.js +0 -122
- package/lib/cjs/config/services/PlatformConfiguration.js.map +0 -1
- package/lib/cjs/constants/routerOptions.js +0 -5
- package/lib/cjs/constants/routerOptions.js.map +0 -1
- package/lib/cjs/decorators/PlatformProvider.js +0 -11
- package/lib/cjs/decorators/PlatformProvider.js.map +0 -1
- package/lib/cjs/decorators/multer/multerFileSize.js +0 -35
- package/lib/cjs/decorators/multer/multerFileSize.js.map +0 -1
- package/lib/cjs/decorators/multer/multerOptions.js +0 -52
- package/lib/cjs/decorators/multer/multerOptions.js.map +0 -1
- package/lib/cjs/decorators/multer/multipartFile.js +0 -78
- package/lib/cjs/decorators/multer/multipartFile.js.map +0 -1
- package/lib/cjs/decorators/params/error.js +0 -20
- package/lib/cjs/decorators/params/error.js.map +0 -1
- package/lib/cjs/decorators/params/next.js +0 -21
- package/lib/cjs/decorators/params/next.js.map +0 -1
- package/lib/cjs/decorators/params/request.js +0 -39
- package/lib/cjs/decorators/params/request.js.map +0 -1
- package/lib/cjs/decorators/params/response.js +0 -33
- package/lib/cjs/decorators/params/response.js.map +0 -1
- package/lib/cjs/domain/AnyToPromiseWithCtx.js +0 -25
- package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +0 -1
- package/lib/cjs/domain/EndpointMetadata.js +0 -6
- package/lib/cjs/domain/EndpointMetadata.js.map +0 -1
- package/lib/cjs/domain/PlatformContext.js +0 -73
- package/lib/cjs/domain/PlatformContext.js.map +0 -1
- package/lib/cjs/domain/PlatformRouteDetails.js +0 -3
- package/lib/cjs/domain/PlatformRouteDetails.js.map +0 -1
- package/lib/cjs/exports.js +0 -30
- package/lib/cjs/exports.js.map +0 -1
- package/lib/cjs/index.js +0 -67
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interfaces/AfterInit.js +0 -3
- package/lib/cjs/interfaces/AfterInit.js.map +0 -1
- package/lib/cjs/interfaces/AfterListen.js +0 -3
- package/lib/cjs/interfaces/AfterListen.js.map +0 -1
- package/lib/cjs/interfaces/AfterRoutesInit.js +0 -3
- package/lib/cjs/interfaces/AfterRoutesInit.js.map +0 -1
- package/lib/cjs/interfaces/BeforeInit.js +0 -3
- package/lib/cjs/interfaces/BeforeInit.js.map +0 -1
- package/lib/cjs/interfaces/BeforeListen.js +0 -3
- package/lib/cjs/interfaces/BeforeListen.js.map +0 -1
- package/lib/cjs/interfaces/BeforeRoutesInit.js +0 -3
- package/lib/cjs/interfaces/BeforeRoutesInit.js.map +0 -1
- package/lib/cjs/interfaces/HandlerType.js +0 -17
- package/lib/cjs/interfaces/HandlerType.js.map +0 -1
- package/lib/cjs/interfaces/IncomingEvent.js +0 -3
- package/lib/cjs/interfaces/IncomingEvent.js.map +0 -1
- package/lib/cjs/interfaces/OnReady.js +0 -3
- package/lib/cjs/interfaces/OnReady.js.map +0 -1
- package/lib/cjs/interfaces/OnRequest.js +0 -3
- package/lib/cjs/interfaces/OnRequest.js.map +0 -1
- package/lib/cjs/interfaces/OnResponse.js +0 -3
- package/lib/cjs/interfaces/OnResponse.js.map +0 -1
- package/lib/cjs/interfaces/OnRoutesInit.js +0 -3
- package/lib/cjs/interfaces/OnRoutesInit.js.map +0 -1
- package/lib/cjs/interfaces/PlatformRouteOptions.js +0 -3
- package/lib/cjs/interfaces/PlatformRouteOptions.js.map +0 -1
- package/lib/cjs/interfaces/ResponseErrorObject.js +0 -3
- package/lib/cjs/interfaces/ResponseErrorObject.js.map +0 -1
- package/lib/cjs/interfaces/Route.js +0 -3
- package/lib/cjs/interfaces/Route.js.map +0 -1
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +0 -39
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +0 -1
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js +0 -70
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/services/FakeAdapter.js +0 -6
- package/lib/cjs/services/FakeAdapter.js.map +0 -1
- package/lib/cjs/services/FakeResponse.js +0 -59
- package/lib/cjs/services/FakeResponse.js.map +0 -1
- package/lib/cjs/services/Platform.js +0 -76
- package/lib/cjs/services/Platform.js.map +0 -1
- package/lib/cjs/services/PlatformAdapter.js +0 -82
- package/lib/cjs/services/PlatformAdapter.js.map +0 -1
- package/lib/cjs/services/PlatformApplication.js +0 -44
- package/lib/cjs/services/PlatformApplication.js.map +0 -1
- package/lib/cjs/services/PlatformHandler.js +0 -133
- package/lib/cjs/services/PlatformHandler.js.map +0 -1
- package/lib/cjs/services/PlatformMiddlewaresChain.js +0 -60
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +0 -1
- package/lib/cjs/services/PlatformRequest.js +0 -144
- package/lib/cjs/services/PlatformRequest.js.map +0 -1
- package/lib/cjs/services/PlatformResponse.js +0 -309
- package/lib/cjs/services/PlatformResponse.js.map +0 -1
- package/lib/cjs/services/PlatformTest.js +0 -142
- package/lib/cjs/services/PlatformTest.js.map +0 -1
- package/lib/cjs/utils/closeServer.js +0 -8
- package/lib/cjs/utils/closeServer.js.map +0 -1
- package/lib/cjs/utils/createContext.js +0 -49
- package/lib/cjs/utils/createContext.js.map +0 -1
- package/lib/cjs/utils/createHttpServer.js +0 -18
- package/lib/cjs/utils/createHttpServer.js.map +0 -1
- package/lib/cjs/utils/createHttpsServer.js +0 -18
- package/lib/cjs/utils/createHttpsServer.js.map +0 -1
- package/lib/cjs/utils/createInjector.js +0 -45
- package/lib/cjs/utils/createInjector.js.map +0 -1
- package/lib/cjs/utils/createServer.js +0 -33
- package/lib/cjs/utils/createServer.js.map +0 -1
- package/lib/cjs/utils/ensureContext.js +0 -16
- package/lib/cjs/utils/ensureContext.js.map +0 -1
- package/lib/cjs/utils/getConfiguration.js +0 -36
- package/lib/cjs/utils/getConfiguration.js.map +0 -1
- package/lib/cjs/utils/getStaticsOptions.js +0 -21
- package/lib/cjs/utils/getStaticsOptions.js.map +0 -1
- package/lib/cjs/utils/listenServer.js +0 -14
- package/lib/cjs/utils/listenServer.js.map +0 -1
- package/lib/cjs/utils/mapReturnedResponse.js +0 -15
- package/lib/cjs/utils/mapReturnedResponse.js.map +0 -1
- package/lib/cjs/utils/printRoutes.js +0 -38
- package/lib/cjs/utils/printRoutes.js.map +0 -1
- package/lib/cjs/utils/registerPlatformAdapter.js +0 -11
- package/lib/cjs/utils/registerPlatformAdapter.js.map +0 -1
- package/lib/cjs/utils/setResponseHeaders.js +0 -29
- package/lib/cjs/utils/setResponseHeaders.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/builder/PlatformBuilder.d.ts +0 -100
- package/lib/types-esm/config/interfaces/PlatformJsonMapperSettings.d.ts +0 -10
- package/lib/types-esm/config/interfaces/PlatformMulterSettings.d.ts +0 -14
- package/lib/types-esm/config/interfaces/PlatformRouterSettings.d.ts +0 -10
- package/lib/types-esm/config/interfaces/PlatformStaticsSettings.d.ts +0 -17
- package/lib/types-esm/config/services/PlatformConfiguration.d.ts +0 -67
- package/lib/types-esm/constants/routerOptions.d.ts +0 -1
- package/lib/types-esm/decorators/PlatformProvider.d.ts +0 -3
- package/lib/types-esm/decorators/multer/multerFileSize.d.ts +0 -27
- package/lib/types-esm/decorators/multer/multerOptions.d.ts +0 -41
- package/lib/types-esm/decorators/multer/multipartFile.d.ts +0 -47
- package/lib/types-esm/decorators/params/error.d.ts +0 -7
- package/lib/types-esm/decorators/params/next.d.ts +0 -22
- package/lib/types-esm/decorators/params/request.d.ts +0 -46
- package/lib/types-esm/decorators/params/response.d.ts +0 -40
- package/lib/types-esm/domain/AnyToPromiseWithCtx.d.ts +0 -10
- package/lib/types-esm/domain/EndpointMetadata.d.ts +0 -1
- package/lib/types-esm/domain/PlatformContext.d.ts +0 -80
- package/lib/types-esm/domain/PlatformRouteDetails.d.ts +0 -7
- package/lib/types-esm/exports.d.ts +0 -11
- package/lib/types-esm/index.d.ts +0 -63
- package/lib/types-esm/interfaces/AfterInit.d.ts +0 -3
- package/lib/types-esm/interfaces/AfterListen.d.ts +0 -3
- package/lib/types-esm/interfaces/AfterRoutesInit.d.ts +0 -3
- package/lib/types-esm/interfaces/BeforeInit.d.ts +0 -3
- package/lib/types-esm/interfaces/BeforeListen.d.ts +0 -3
- package/lib/types-esm/interfaces/BeforeRoutesInit.d.ts +0 -3
- package/lib/types-esm/interfaces/HandlerType.d.ts +0 -12
- package/lib/types-esm/interfaces/IncomingEvent.d.ts +0 -6
- package/lib/types-esm/interfaces/OnReady.d.ts +0 -3
- package/lib/types-esm/interfaces/OnRequest.d.ts +0 -4
- package/lib/types-esm/interfaces/OnResponse.d.ts +0 -4
- package/lib/types-esm/interfaces/OnRoutesInit.d.ts +0 -3
- package/lib/types-esm/interfaces/PlatformRouteOptions.d.ts +0 -15
- package/lib/types-esm/interfaces/ResponseErrorObject.d.ts +0 -8
- package/lib/types-esm/interfaces/Route.d.ts +0 -10
- package/lib/types-esm/middlewares/PlatformAcceptMimesMiddleware.d.ts +0 -10
- package/lib/types-esm/middlewares/PlatformMulterMiddleware.d.ts +0 -24
- package/lib/types-esm/services/FakeAdapter.d.ts +0 -1
- package/lib/types-esm/services/FakeResponse.d.ts +0 -22
- package/lib/types-esm/services/Platform.d.ts +0 -25
- package/lib/types-esm/services/PlatformAdapter.d.ts +0 -89
- package/lib/types-esm/services/PlatformApplication.d.ts +0 -29
- package/lib/types-esm/services/PlatformHandler.d.ts +0 -39
- package/lib/types-esm/services/PlatformMiddlewaresChain.d.ts +0 -17
- package/lib/types-esm/services/PlatformRequest.d.ts +0 -111
- package/lib/types-esm/services/PlatformResponse.d.ts +0 -174
- package/lib/types-esm/services/PlatformTest.d.ts +0 -60
- package/lib/types-esm/utils/closeServer.d.ts +0 -7
- package/lib/types-esm/utils/createContext.d.ts +0 -10
- package/lib/types-esm/utils/createHttpServer.d.ts +0 -4
- package/lib/types-esm/utils/createHttpsServer.d.ts +0 -4
- package/lib/types-esm/utils/createInjector.d.ts +0 -9
- package/lib/types-esm/utils/createServer.d.ts +0 -17
- package/lib/types-esm/utils/ensureContext.d.ts +0 -2
- package/lib/types-esm/utils/getConfiguration.d.ts +0 -2
- package/lib/types-esm/utils/getStaticsOptions.d.ts +0 -5
- package/lib/types-esm/utils/listenServer.d.ts +0 -8
- package/lib/types-esm/utils/mapReturnedResponse.d.ts +0 -4
- package/lib/types-esm/utils/printRoutes.d.ts +0 -2
- package/lib/types-esm/utils/registerPlatformAdapter.d.ts +0 -3
- package/lib/types-esm/utils/setResponseHeaders.d.ts +0 -5
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @ignore
|
|
3
|
-
*/
|
|
4
|
-
export declare enum HandlerType {
|
|
5
|
-
CUSTOM = "custom",
|
|
6
|
-
ENDPOINT = "endpoint",
|
|
7
|
-
MIDDLEWARE = "middleware",
|
|
8
|
-
ERR_MIDDLEWARE = "err:middleware",
|
|
9
|
-
CTX_FN = "context",
|
|
10
|
-
RAW_FN = "raw:middleware",
|
|
11
|
-
RAW_ERR_FN = "raw:err:middleware"
|
|
12
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { PathType } from "@tsed/di";
|
|
3
|
-
/**
|
|
4
|
-
* @ignore
|
|
5
|
-
*/
|
|
6
|
-
export interface PlatformRouteOptions {
|
|
7
|
-
token?: Type<any>;
|
|
8
|
-
path?: PathType | undefined;
|
|
9
|
-
method?: string;
|
|
10
|
-
handlers: any[];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @ignore
|
|
14
|
-
*/
|
|
15
|
-
export type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, "handlers">>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { MiddlewareMethods } from "@tsed/platform-middlewares";
|
|
2
|
-
import { Context } from "@tsed/platform-params";
|
|
3
|
-
/**
|
|
4
|
-
* @middleware
|
|
5
|
-
* @platform
|
|
6
|
-
*/
|
|
7
|
-
export declare class PlatformAcceptMimesMiddleware implements MiddlewareMethods {
|
|
8
|
-
acceptMimes: string[];
|
|
9
|
-
use(ctx: Context): void;
|
|
10
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadRequest } from "@tsed/exceptions";
|
|
2
|
-
import { MiddlewareMethods } from "@tsed/platform-middlewares";
|
|
3
|
-
import type { MulterError } from "multer";
|
|
4
|
-
import { PlatformMulterField, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings.js";
|
|
5
|
-
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
6
|
-
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
7
|
-
export interface MulterInputOptions {
|
|
8
|
-
fields: PlatformMulterField[];
|
|
9
|
-
}
|
|
10
|
-
export declare class MulterException extends BadRequest {
|
|
11
|
-
constructor(er: MulterError);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @middleware
|
|
15
|
-
*/
|
|
16
|
-
export declare class PlatformMulterMiddleware implements MiddlewareMethods {
|
|
17
|
-
protected settings: PlatformMulterSettings;
|
|
18
|
-
protected app: PlatformApplication;
|
|
19
|
-
use(ctx: PlatformContext): Promise<any>;
|
|
20
|
-
protected getFields(conf: MulterInputOptions): {
|
|
21
|
-
name: string;
|
|
22
|
-
maxCount: number | undefined;
|
|
23
|
-
}[];
|
|
24
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { FakeAdapter } from "./PlatformAdapter.js";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from "node:events";
|
|
3
|
-
export declare class FakeResponse extends EventEmitter {
|
|
4
|
-
headers: Record<string, unknown>;
|
|
5
|
-
locals: Record<string, unknown>;
|
|
6
|
-
statusCode: number;
|
|
7
|
-
data: any;
|
|
8
|
-
constructor(opts?: {});
|
|
9
|
-
status(code: number): this;
|
|
10
|
-
contentType(content: string): void;
|
|
11
|
-
contentLength(content: number): void;
|
|
12
|
-
redirect(status: number, path: string): void;
|
|
13
|
-
location(path: string): void;
|
|
14
|
-
get(key: string): unknown;
|
|
15
|
-
getHeaders(): Record<string, unknown>;
|
|
16
|
-
set(key: string, value: any): this;
|
|
17
|
-
setHeader(key: string, value: any): this;
|
|
18
|
-
send(data: any): void;
|
|
19
|
-
json(data: any): void;
|
|
20
|
-
write(chunk: any): void;
|
|
21
|
-
end(data: any): void;
|
|
22
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { InjectorService, TokenProvider } from "@tsed/di";
|
|
2
|
-
import { PlatformLayer, PlatformRouters } from "@tsed/platform-router";
|
|
3
|
-
import { Route, RouteController } from "../interfaces/Route.js";
|
|
4
|
-
import { PlatformApplication } from "./PlatformApplication.js";
|
|
5
|
-
/**
|
|
6
|
-
* `Platform` is used to provide all routes collected by annotation `@Controller`.
|
|
7
|
-
*
|
|
8
|
-
* @platform
|
|
9
|
-
*/
|
|
10
|
-
export declare class Platform {
|
|
11
|
-
#private;
|
|
12
|
-
readonly injector: InjectorService;
|
|
13
|
-
readonly platformApplication: PlatformApplication;
|
|
14
|
-
readonly platformRouters: PlatformRouters;
|
|
15
|
-
constructor(injector: InjectorService, platformApplication: PlatformApplication, platformRouters: PlatformRouters);
|
|
16
|
-
get app(): PlatformApplication<TsED.Application>;
|
|
17
|
-
addRoutes(routes: Route[]): void;
|
|
18
|
-
addRoute(route: string, token: TokenProvider): this;
|
|
19
|
-
getLayers(): PlatformLayer[];
|
|
20
|
-
/**
|
|
21
|
-
* Get all controllers mounted on the application.
|
|
22
|
-
* @returns {RouteController[]}
|
|
23
|
-
*/
|
|
24
|
-
getMountedControllers(): RouteController[];
|
|
25
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Type } from "@tsed/core";
|
|
3
|
-
import { InjectorService, ProviderOpts } from "@tsed/di";
|
|
4
|
-
import { PlatformContextHandler, PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
|
|
5
|
-
import { IncomingMessage, ServerResponse } from "http";
|
|
6
|
-
import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings.js";
|
|
7
|
-
import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings.js";
|
|
8
|
-
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
9
|
-
import { CreateServerReturn } from "../utils/createServer.js";
|
|
10
|
-
import type { PlatformApplication } from "./PlatformApplication.js";
|
|
11
|
-
export declare abstract class PlatformAdapter<App = TsED.Application> {
|
|
12
|
-
protected injector: InjectorService;
|
|
13
|
-
static readonly NAME: string;
|
|
14
|
-
/**
|
|
15
|
-
* Load providers in top priority
|
|
16
|
-
*/
|
|
17
|
-
providers: ProviderOpts[];
|
|
18
|
-
constructor(injector: InjectorService);
|
|
19
|
-
get app(): PlatformApplication<App>;
|
|
20
|
-
getServers(): CreateServerReturn[];
|
|
21
|
-
onInit(): Promise<void> | void;
|
|
22
|
-
beforeLoadRoutes(): Promise<void> | void;
|
|
23
|
-
afterLoadRoutes(): Promise<void> | void;
|
|
24
|
-
/**
|
|
25
|
-
* create initial context
|
|
26
|
-
*/
|
|
27
|
-
abstract useContext(): any;
|
|
28
|
-
/**
|
|
29
|
-
* Map router layer to the targeted framework
|
|
30
|
-
*/
|
|
31
|
-
abstract mapLayers(layer: PlatformLayer[]): void;
|
|
32
|
-
/**
|
|
33
|
-
* Map handler to the targeted framework
|
|
34
|
-
*/
|
|
35
|
-
abstract mapHandler(handler: Function, layer: PlatformHandlerMetadata): Function;
|
|
36
|
-
/**
|
|
37
|
-
* Return the app instance
|
|
38
|
-
*/
|
|
39
|
-
abstract createApp(): {
|
|
40
|
-
app: App;
|
|
41
|
-
callback(): (req: IncomingMessage, res: ServerResponse) => void;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Return the statics middlewares
|
|
45
|
-
* @param endpoint
|
|
46
|
-
* @param options
|
|
47
|
-
*/
|
|
48
|
-
abstract statics(endpoint: string, options: PlatformStaticsOptions): any;
|
|
49
|
-
/**
|
|
50
|
-
* Return the multipart middleware
|
|
51
|
-
* @param options
|
|
52
|
-
*/
|
|
53
|
-
abstract multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
54
|
-
/**
|
|
55
|
-
* Return the body parser for the given
|
|
56
|
-
* @param type
|
|
57
|
-
* @param opts
|
|
58
|
-
*/
|
|
59
|
-
abstract bodyParser(type: string, opts?: Record<string, any>): any;
|
|
60
|
-
}
|
|
61
|
-
export interface PlatformBuilderSettings<App = TsED.Application> extends Partial<TsED.Configuration> {
|
|
62
|
-
adapter?: Type<PlatformAdapter<App>>;
|
|
63
|
-
}
|
|
64
|
-
export declare class FakeAdapter extends PlatformAdapter<any> {
|
|
65
|
-
providers: ProviderOpts[];
|
|
66
|
-
static readonly NAME: string;
|
|
67
|
-
static createFakeRawDriver(): {
|
|
68
|
-
(): void;
|
|
69
|
-
use: () => any;
|
|
70
|
-
all: () => any;
|
|
71
|
-
get: () => any;
|
|
72
|
-
patch: () => any;
|
|
73
|
-
post: () => any;
|
|
74
|
-
put: () => any;
|
|
75
|
-
head: () => any;
|
|
76
|
-
delete: () => any;
|
|
77
|
-
options: () => any;
|
|
78
|
-
};
|
|
79
|
-
createApp(): {
|
|
80
|
-
app: any;
|
|
81
|
-
callback(): any;
|
|
82
|
-
};
|
|
83
|
-
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
84
|
-
statics(endpoint: string, options: PlatformStaticsOptions): any;
|
|
85
|
-
bodyParser(type: string): any;
|
|
86
|
-
mapLayers(layers: PlatformLayer[]): void;
|
|
87
|
-
mapHandler(handler: PlatformContextHandler<PlatformContext>): PlatformContextHandler<PlatformContext<import("./PlatformRequest.js").PlatformRequest<any>, import("./PlatformResponse.js").PlatformResponse<any>>>;
|
|
88
|
-
useContext(): void;
|
|
89
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="multer" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { InjectorService } from "@tsed/di";
|
|
4
|
-
import { PlatformRouter } from "@tsed/platform-router";
|
|
5
|
-
import { IncomingMessage, ServerResponse } from "http";
|
|
6
|
-
import { PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings.js";
|
|
7
|
-
import { PlatformAdapter } from "./PlatformAdapter.js";
|
|
8
|
-
declare global {
|
|
9
|
-
namespace TsED {
|
|
10
|
-
interface Application {
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.
|
|
16
|
-
*
|
|
17
|
-
* @platform
|
|
18
|
-
*/
|
|
19
|
-
export declare class PlatformApplication<App = TsED.Application> extends PlatformRouter {
|
|
20
|
-
adapter: PlatformAdapter<App>;
|
|
21
|
-
injector: InjectorService;
|
|
22
|
-
rawApp: App;
|
|
23
|
-
rawCallback: () => any;
|
|
24
|
-
constructor(adapter: PlatformAdapter<App>, injector: InjectorService);
|
|
25
|
-
getApp(): App;
|
|
26
|
-
multer(options: PlatformMulterSettings): import("multer").Multer;
|
|
27
|
-
callback(): (req: IncomingMessage, res: ServerResponse) => any;
|
|
28
|
-
callback(req: IncomingMessage, res: ServerResponse): any;
|
|
29
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { AnyPromiseResult } from "@tsed/core";
|
|
2
|
-
import { Provider } from "@tsed/di";
|
|
3
|
-
import { PlatformExceptions } from "@tsed/platform-exceptions";
|
|
4
|
-
import { PlatformParams, PlatformParamsCallback } from "@tsed/platform-params";
|
|
5
|
-
import { PlatformResponseFilter } from "@tsed/platform-response-filter";
|
|
6
|
-
import { PlatformHandlerMetadata, PlatformRouters } from "@tsed/platform-router";
|
|
7
|
-
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
8
|
-
import { PlatformApplication } from "./PlatformApplication.js";
|
|
9
|
-
import { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain.js";
|
|
10
|
-
/**
|
|
11
|
-
* Platform Handler abstraction layer. Wrap original class method to a pure platform handler (Express, Koa, etc...).
|
|
12
|
-
* @platform
|
|
13
|
-
*/
|
|
14
|
-
export declare class PlatformHandler {
|
|
15
|
-
protected platformRouters: PlatformRouters;
|
|
16
|
-
protected responseFilter: PlatformResponseFilter;
|
|
17
|
-
protected platformParams: PlatformParams;
|
|
18
|
-
protected platformExceptions: PlatformExceptions;
|
|
19
|
-
protected platformApplication: PlatformApplication;
|
|
20
|
-
protected platformMiddlewaresChain: PlatformMiddlewaresChain;
|
|
21
|
-
constructor(platformRouters: PlatformRouters);
|
|
22
|
-
createHandler(handlerMetadata: PlatformHandlerMetadata): any;
|
|
23
|
-
/**
|
|
24
|
-
* @param provider
|
|
25
|
-
* @param propertyKey
|
|
26
|
-
*/
|
|
27
|
-
createCustomHandler(provider: Provider, propertyKey: string): any;
|
|
28
|
-
/**
|
|
29
|
-
* Call handler when a request his handle
|
|
30
|
-
*/
|
|
31
|
-
onRequest(handler: PlatformParamsCallback, $ctx: PlatformContext): Promise<any>;
|
|
32
|
-
onResponse({ status, data, headers }: AnyPromiseResult, $ctx: PlatformContext): void;
|
|
33
|
-
/**
|
|
34
|
-
* Send the response to the consumer.
|
|
35
|
-
* @protected
|
|
36
|
-
* @param $ctx
|
|
37
|
-
*/
|
|
38
|
-
flush($ctx: PlatformContext): Promise<void>;
|
|
39
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { InjectorService } from "@tsed/di";
|
|
2
|
-
import { AlterEndpointHandlersArg } from "@tsed/platform-router";
|
|
3
|
-
import { JsonOperationRoute } from "@tsed/schema";
|
|
4
|
-
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
5
|
-
export declare class PlatformMiddlewaresChain {
|
|
6
|
-
protected acceptMimes: string[];
|
|
7
|
-
protected adapter: PlatformAdapter;
|
|
8
|
-
protected injector: InjectorService;
|
|
9
|
-
get(handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute): AlterEndpointHandlersArg;
|
|
10
|
-
protected hasAcceptMimes(operationRoute: JsonOperationRoute): number;
|
|
11
|
-
protected getParamTypes(middlewares: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute): {
|
|
12
|
-
ACCEPT_MIMES: number;
|
|
13
|
-
FILE: boolean;
|
|
14
|
-
RAW_BODY: boolean;
|
|
15
|
-
BODY: boolean;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IncomingHttpHeaders, IncomingMessage } from "http";
|
|
3
|
-
import type { PlatformContext } from "../domain/PlatformContext.js";
|
|
4
|
-
import type { PlatformResponse } from "./PlatformResponse.js";
|
|
5
|
-
declare global {
|
|
6
|
-
namespace TsED {
|
|
7
|
-
interface Request {
|
|
8
|
-
id: string;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Platform Request abstraction layer.
|
|
14
|
-
* @platform
|
|
15
|
-
*/
|
|
16
|
-
export declare class PlatformRequest<Req extends {
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
} = any> {
|
|
19
|
-
readonly $ctx: PlatformContext;
|
|
20
|
-
constructor($ctx: PlatformContext);
|
|
21
|
-
/**
|
|
22
|
-
* The current @@PlatformResponse@@.
|
|
23
|
-
*/
|
|
24
|
-
get response(): PlatformResponse;
|
|
25
|
-
get raw(): Req;
|
|
26
|
-
get secure(): boolean;
|
|
27
|
-
get host(): string;
|
|
28
|
-
get protocol(): string;
|
|
29
|
-
/**
|
|
30
|
-
* Get the url of the request.
|
|
31
|
-
*
|
|
32
|
-
* Is equivalent of `express.response.originalUrl || express.response.url`.
|
|
33
|
-
*/
|
|
34
|
-
get url(): string;
|
|
35
|
-
get headers(): IncomingHttpHeaders;
|
|
36
|
-
get method(): string;
|
|
37
|
-
/**
|
|
38
|
-
* Contains key-value pairs of data submitted in the request body. By default, it is `undefined`, and is populated when you use
|
|
39
|
-
* `body-parsing` middleware such as `express.json()` or `express.urlencoded()`.
|
|
40
|
-
*/
|
|
41
|
-
get body(): any;
|
|
42
|
-
get rawBody(): any;
|
|
43
|
-
/**
|
|
44
|
-
* When using `cookie-parser` middleware, this property is an object that contains cookies sent by the request.
|
|
45
|
-
* If the request contains no cookies, it defaults to `{}`.
|
|
46
|
-
*/
|
|
47
|
-
get cookies(): {
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* This property is an object containing properties mapped to the named route `parameters`.
|
|
52
|
-
* For example, if you have the route `/user/:name`, then the `name` property is available as `req.params.name`.
|
|
53
|
-
* This object defaults to `{}`.
|
|
54
|
-
*/
|
|
55
|
-
get params(): {
|
|
56
|
-
[key: string]: any;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* This property is an object containing a property for each query string parameter in the route.
|
|
60
|
-
* When query parser is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
|
|
61
|
-
*/
|
|
62
|
-
get query(): {
|
|
63
|
-
[key: string]: any;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* This property is an object containing a property for each session attributes set by any code.
|
|
67
|
-
* It requires to install a middleware like express-session to work.
|
|
68
|
-
*/
|
|
69
|
-
get session(): {
|
|
70
|
-
[key: string]: any;
|
|
71
|
-
};
|
|
72
|
-
get files(): any;
|
|
73
|
-
get route(): import("@tsed/platform-router").SinglePathType;
|
|
74
|
-
/**
|
|
75
|
-
* Return the original request framework instance
|
|
76
|
-
*/
|
|
77
|
-
get request(): Req;
|
|
78
|
-
/**
|
|
79
|
-
* Return the original request node.js instance
|
|
80
|
-
*/
|
|
81
|
-
get req(): IncomingMessage;
|
|
82
|
-
/**
|
|
83
|
-
* Returns the HTTP request header specified by field. The match is case-insensitive.
|
|
84
|
-
*
|
|
85
|
-
* ```typescript
|
|
86
|
-
* request.get('Content-Type') // => "text/plain"
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* @param name
|
|
90
|
-
*/
|
|
91
|
-
get(name: string): any;
|
|
92
|
-
getHeader(name: string): any;
|
|
93
|
-
/**
|
|
94
|
-
* Checks if the specified content types are acceptable, based on the request’s Accept HTTP header field. The method returns the best match, or if none of the specified content types is acceptable, returns false (in which case, the application should respond with 406 "Not Acceptable").
|
|
95
|
-
*
|
|
96
|
-
* The type value may be a single MIME type string (such as “application/json”), an extension name such as “json”, a comma-delimited list, or an array. For a list or array, the method returns the best match (if any).
|
|
97
|
-
*
|
|
98
|
-
* @param mime
|
|
99
|
-
*/
|
|
100
|
-
accepts(mime: string): string | false;
|
|
101
|
-
accepts(mime: string[]): string[] | false;
|
|
102
|
-
isAborted(): any;
|
|
103
|
-
/**
|
|
104
|
-
* Return the Framework response object (express, koa, etc...)
|
|
105
|
-
*/
|
|
106
|
-
getRequest<R = Req>(): R;
|
|
107
|
-
/**
|
|
108
|
-
* Return the Node.js response object
|
|
109
|
-
*/
|
|
110
|
-
getReq(): IncomingMessage;
|
|
111
|
-
}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { OutgoingHttpHeaders, ServerResponse } from "http";
|
|
4
|
-
import type { PlatformContext } from "../domain/PlatformContext.js";
|
|
5
|
-
import type { PlatformRequest } from "./PlatformRequest.js";
|
|
6
|
-
declare global {
|
|
7
|
-
namespace TsED {
|
|
8
|
-
interface Response {
|
|
9
|
-
}
|
|
10
|
-
interface SetCookieOpts extends Record<string, unknown> {
|
|
11
|
-
maxAge?: number | undefined;
|
|
12
|
-
signed?: boolean | undefined;
|
|
13
|
-
expires?: Date | undefined;
|
|
14
|
-
httpOnly?: boolean | undefined;
|
|
15
|
-
path?: string | undefined;
|
|
16
|
-
domain?: string | undefined;
|
|
17
|
-
secure?: boolean | undefined;
|
|
18
|
-
encode?: ((val: string) => string) | undefined;
|
|
19
|
-
sameSite?: boolean | "lax" | "strict" | "none" | undefined;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Platform Response abstraction layer.
|
|
25
|
-
* @platform
|
|
26
|
-
*/
|
|
27
|
-
export declare class PlatformResponse<Res extends Record<string, any> = any> {
|
|
28
|
-
readonly $ctx: PlatformContext;
|
|
29
|
-
data: any;
|
|
30
|
-
constructor($ctx: PlatformContext);
|
|
31
|
-
/**
|
|
32
|
-
* The current @@PlatformRequest@@.
|
|
33
|
-
*/
|
|
34
|
-
get request(): PlatformRequest;
|
|
35
|
-
get raw(): Res;
|
|
36
|
-
/**
|
|
37
|
-
* Get the current statusCode
|
|
38
|
-
*/
|
|
39
|
-
get statusCode(): any;
|
|
40
|
-
/**
|
|
41
|
-
* An object that contains response local variables scoped to the request, and therefore available only to the view(s) rendered during that request / response cycle (if any). Otherwise, this property is identical to app.locals.
|
|
42
|
-
*
|
|
43
|
-
* This property is useful for exposing request-level information such as the request path name, authenticated user, user settings, and so on.
|
|
44
|
-
*/
|
|
45
|
-
get locals(): any;
|
|
46
|
-
/**
|
|
47
|
-
* Return the original response framework instance
|
|
48
|
-
*/
|
|
49
|
-
get response(): Res;
|
|
50
|
-
/**
|
|
51
|
-
* Return the original response node.js instance
|
|
52
|
-
*/
|
|
53
|
-
get res(): ServerResponse<import("http").IncomingMessage>;
|
|
54
|
-
/**
|
|
55
|
-
* Returns the HTTP response header specified by field. The match is case-insensitive.
|
|
56
|
-
*
|
|
57
|
-
* ```typescript
|
|
58
|
-
* response.get('Content-Type') // => "text/plain"
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* @param name
|
|
62
|
-
*/
|
|
63
|
-
get(name: string): any;
|
|
64
|
-
getHeaders(): OutgoingHttpHeaders;
|
|
65
|
-
/**
|
|
66
|
-
* Return the Framework response object (express, koa, etc...)
|
|
67
|
-
*/
|
|
68
|
-
getResponse<R = Res>(): R;
|
|
69
|
-
/**
|
|
70
|
-
* Return the Node.js response object
|
|
71
|
-
*/
|
|
72
|
-
getRes(): ServerResponse;
|
|
73
|
-
hasStatus(): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Sets the HTTP status for the response.
|
|
76
|
-
*
|
|
77
|
-
* @param status
|
|
78
|
-
*/
|
|
79
|
-
status(status: number): this;
|
|
80
|
-
/**
|
|
81
|
-
* Set header `field` to `val`, or pass
|
|
82
|
-
* an object of header fields.
|
|
83
|
-
*
|
|
84
|
-
* Examples:
|
|
85
|
-
* ```typescript
|
|
86
|
-
* response.setHeaders({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* Aliased as `res.header()`.
|
|
90
|
-
*/
|
|
91
|
-
setHeaders(headers: OutgoingHttpHeaders): this;
|
|
92
|
-
setHeader(key: string, item: any): this;
|
|
93
|
-
/**
|
|
94
|
-
* Set `Content-Type` response header with `type` through `mime.lookup()`
|
|
95
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
96
|
-
*
|
|
97
|
-
* Examples:
|
|
98
|
-
*
|
|
99
|
-
* res.type('.html');
|
|
100
|
-
* res.type('html');
|
|
101
|
-
* res.type('json');
|
|
102
|
-
* res.type('application/json');
|
|
103
|
-
* res.type('png');
|
|
104
|
-
*/
|
|
105
|
-
contentType(contentType: string): this;
|
|
106
|
-
contentLength(length: number): this;
|
|
107
|
-
getContentLength(): number | undefined;
|
|
108
|
-
getContentType(): any;
|
|
109
|
-
/**
|
|
110
|
-
* Sets the HTTP response Content-Disposition header field to “attachment”.
|
|
111
|
-
* If a filename is given, then it sets the Content-Type based on the extension name via res.type(), and sets the Content-Disposition “filename=” parameter.
|
|
112
|
-
*
|
|
113
|
-
* ```typescript
|
|
114
|
-
* res.attachment()
|
|
115
|
-
* // Content-Disposition: attachment
|
|
116
|
-
*
|
|
117
|
-
* res.attachment('path/to/logo.png')
|
|
118
|
-
* // Content-Disposition: attachment; filename="logo.png"
|
|
119
|
-
* // Content-Type: image/png
|
|
120
|
-
* ```
|
|
121
|
-
*
|
|
122
|
-
* @param filename
|
|
123
|
-
*/
|
|
124
|
-
attachment(filename: string): this;
|
|
125
|
-
/**
|
|
126
|
-
* Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an [HTTP status code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
|
|
127
|
-
* If not specified, status defaults to `302 Found`.
|
|
128
|
-
*
|
|
129
|
-
* @param status
|
|
130
|
-
* @param url
|
|
131
|
-
*/
|
|
132
|
-
redirect(status: number, url: string): this;
|
|
133
|
-
/**
|
|
134
|
-
* Sets the response Location HTTP header to the specified path parameter.
|
|
135
|
-
*
|
|
136
|
-
* @param location
|
|
137
|
-
*/
|
|
138
|
-
location(location: string): this;
|
|
139
|
-
/**
|
|
140
|
-
* Stream the given data.
|
|
141
|
-
*
|
|
142
|
-
* @param data
|
|
143
|
-
*/
|
|
144
|
-
stream(data: any): this;
|
|
145
|
-
/**
|
|
146
|
-
* Renders a view and sends the rendered HTML string to the client.
|
|
147
|
-
*
|
|
148
|
-
* @param path
|
|
149
|
-
* @param options
|
|
150
|
-
*/
|
|
151
|
-
render(path: string, options?: any): Promise<any>;
|
|
152
|
-
/**
|
|
153
|
-
* Send any data to your consumer.
|
|
154
|
-
*
|
|
155
|
-
* This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.
|
|
156
|
-
* It chooses the better way to send the data.
|
|
157
|
-
*
|
|
158
|
-
* @param data
|
|
159
|
-
*/
|
|
160
|
-
body(data: any): this;
|
|
161
|
-
getBody(): any;
|
|
162
|
-
/**
|
|
163
|
-
* Add a listener to handler the end of the request/response.
|
|
164
|
-
* @param cb
|
|
165
|
-
*/
|
|
166
|
-
onEnd(cb: () => Promise<void> | void): this;
|
|
167
|
-
isDone(): boolean;
|
|
168
|
-
isHeadersSent(): boolean;
|
|
169
|
-
cookie(name: string, value: string | null, opts?: TsED.SetCookieOpts): this;
|
|
170
|
-
protected formatHeader(key: string, item: any): any;
|
|
171
|
-
protected json(data: any): this;
|
|
172
|
-
protected buffer(data: any): void;
|
|
173
|
-
protected end(data?: string | Buffer): void;
|
|
174
|
-
}
|