@tsed/common 6.95.9 → 6.95.10

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.
Files changed (90) hide show
  1. package/package.json +15 -15
  2. package/lib/cjs/PlatformModule.d.ts +0 -6
  3. package/lib/cjs/builder/PlatformBuilder.d.ts +0 -104
  4. package/lib/cjs/builder/PlatformControllerBuilder.d.ts +0 -17
  5. package/lib/cjs/config/index.d.ts +0 -3
  6. package/lib/cjs/config/interfaces/ConverterSettings.d.ts +0 -6
  7. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
  8. package/lib/cjs/config/interfaces/PlatformLoggerSettings.d.ts +0 -44
  9. package/lib/cjs/config/interfaces/PlatformMulterSettings.d.ts +0 -138
  10. package/lib/cjs/config/interfaces/PlatformStaticsSettings.d.ts +0 -17
  11. package/lib/cjs/config/interfaces/index.d.ts +0 -97
  12. package/lib/cjs/config/services/PlatformConfiguration.d.ts +0 -81
  13. package/lib/cjs/constants/routerOptions.d.ts +0 -1
  14. package/lib/cjs/decorators/httpServer.d.ts +0 -28
  15. package/lib/cjs/decorators/httpsServer.d.ts +0 -28
  16. package/lib/cjs/decorators/index.d.ts +0 -16
  17. package/lib/cjs/decorators/method/acceptMime.d.ts +0 -19
  18. package/lib/cjs/decorators/method/endpointFn.d.ts +0 -9
  19. package/lib/cjs/decorators/method/location.d.ts +0 -1
  20. package/lib/cjs/decorators/method/redirect.d.ts +0 -1
  21. package/lib/cjs/decorators/method/route.d.ts +0 -1
  22. package/lib/cjs/decorators/method/view.d.ts +0 -25
  23. package/lib/cjs/decorators/multer/index.d.ts +0 -3
  24. package/lib/cjs/decorators/multer/multerFileSize.d.ts +0 -27
  25. package/lib/cjs/decorators/multer/multerOptions.d.ts +0 -41
  26. package/lib/cjs/decorators/multer/multipartFile.d.ts +0 -47
  27. package/lib/cjs/decorators/params/endpointInfo.d.ts +0 -13
  28. package/lib/cjs/decorators/params/error.d.ts +0 -7
  29. package/lib/cjs/decorators/params/next.d.ts +0 -22
  30. package/lib/cjs/decorators/params/request.d.ts +0 -46
  31. package/lib/cjs/decorators/params/response.d.ts +0 -40
  32. package/lib/cjs/decorators/params/responseData.d.ts +0 -9
  33. package/lib/cjs/domain/AnyToPromiseWithCtx.d.ts +0 -18
  34. package/lib/cjs/domain/ControllerProvider.d.ts +0 -24
  35. package/lib/cjs/domain/EndpointMetadata.d.ts +0 -50
  36. package/lib/cjs/domain/HandlerMetadata.d.ts +0 -32
  37. package/lib/cjs/domain/PlatformContext.d.ts +0 -65
  38. package/lib/cjs/domain/PlatformRouteDetails.d.ts +0 -23
  39. package/lib/cjs/domain/PropertyMetadata.d.ts +0 -17
  40. package/lib/cjs/domain/index.d.ts +0 -7
  41. package/lib/cjs/index.d.ts +0 -22
  42. package/lib/cjs/interfaces/AfterInit.d.ts +0 -3
  43. package/lib/cjs/interfaces/AfterListen.d.ts +0 -3
  44. package/lib/cjs/interfaces/AfterRoutesInit.d.ts +0 -3
  45. package/lib/cjs/interfaces/BeforeInit.d.ts +0 -3
  46. package/lib/cjs/interfaces/BeforeListen.d.ts +0 -3
  47. package/lib/cjs/interfaces/BeforeRoutesInit.d.ts +0 -3
  48. package/lib/cjs/interfaces/HandlerType.d.ts +0 -12
  49. package/lib/cjs/interfaces/IncomingEvent.d.ts +0 -6
  50. package/lib/cjs/interfaces/OnReady.d.ts +0 -3
  51. package/lib/cjs/interfaces/OnRequest.d.ts +0 -4
  52. package/lib/cjs/interfaces/OnResponse.d.ts +0 -4
  53. package/lib/cjs/interfaces/OnRoutesInit.d.ts +0 -3
  54. package/lib/cjs/interfaces/PathType.d.ts +0 -1
  55. package/lib/cjs/interfaces/PlatformAdapter.d.ts +0 -19
  56. package/lib/cjs/interfaces/PlatformRouteOptions.d.ts +0 -16
  57. package/lib/cjs/interfaces/ResponseErrorObject.d.ts +0 -8
  58. package/lib/cjs/interfaces/Route.d.ts +0 -10
  59. package/lib/cjs/interfaces/index.d.ts +0 -17
  60. package/lib/cjs/middlewares/AcceptMimesMiddleware.d.ts +0 -10
  61. package/lib/cjs/middlewares/GlobalAcceptMimesMiddleware.d.ts +0 -9
  62. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.d.ts +0 -10
  63. package/lib/cjs/middlewares/PlatformMulterMiddleware.d.ts +0 -19
  64. package/lib/cjs/middlewares/__mock__/FakeCtrl.d.ts +0 -2
  65. package/lib/cjs/middlewares/bindEndpointMiddleware.d.ts +0 -5
  66. package/lib/cjs/middlewares/index.d.ts +0 -5
  67. package/lib/cjs/services/FakeRawDriver.d.ts +0 -15
  68. package/lib/cjs/services/Platform.d.ts +0 -37
  69. package/lib/cjs/services/PlatformApplication.d.ts +0 -21
  70. package/lib/cjs/services/PlatformHandler.d.ts +0 -80
  71. package/lib/cjs/services/PlatformMiddlewaresChain.d.ts +0 -6
  72. package/lib/cjs/services/PlatformRequest.d.ts +0 -112
  73. package/lib/cjs/services/PlatformResponse.d.ts +0 -161
  74. package/lib/cjs/services/PlatformRouter.d.ts +0 -48
  75. package/lib/cjs/services/PlatformTest.d.ts +0 -58
  76. package/lib/cjs/services/index.d.ts +0 -8
  77. package/lib/cjs/utils/createContext.d.ts +0 -9
  78. package/lib/cjs/utils/createHandlerMetadata.d.ts +0 -8
  79. package/lib/cjs/utils/createHttpServer.d.ts +0 -4
  80. package/lib/cjs/utils/createHttpsServer.d.ts +0 -4
  81. package/lib/cjs/utils/createInjector.d.ts +0 -7
  82. package/lib/cjs/utils/getConfiguration.d.ts +0 -2
  83. package/lib/cjs/utils/getStaticsOptions.d.ts +0 -5
  84. package/lib/cjs/utils/index.d.ts +0 -8
  85. package/lib/cjs/utils/listenServer.d.ts +0 -7
  86. package/lib/cjs/utils/loadInjector.d.ts +0 -6
  87. package/lib/cjs/utils/mapReturnedResponse.d.ts +0 -4
  88. package/lib/cjs/utils/printRoutes.d.ts +0 -2
  89. package/lib/cjs/utils/setResponseHeaders.d.ts +0 -5
  90. package/lib/cjs/utils/useCtxHandler.d.ts +0 -13
@@ -1,4 +0,0 @@
1
- import { PlatformResponse } from "../services/PlatformResponse";
2
- export interface OnResponse {
3
- $onResponse(ctx: PlatformResponse): void;
4
- }
@@ -1,3 +0,0 @@
1
- export interface OnRoutesInit {
2
- $onRoutesInit(): void | Promise<any>;
3
- }
@@ -1 +0,0 @@
1
- export declare type PathType = string | RegExp | (string | RegExp)[];
@@ -1,19 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { IProvider } from "@tsed/di";
3
- export interface PlatformAdapter<App = TsED.Application, Router = TsED.Router> {
4
- /**
5
- * Load providers in top priority
6
- */
7
- readonly providers: IProvider[];
8
- /**
9
- * Called after the injector instantiation
10
- */
11
- onInit?: () => any;
12
- beforeLoadRoutes?: () => Promise<any>;
13
- afterLoadRoutes?: () => Promise<any>;
14
- useRouter?: () => any;
15
- useContext?: () => any;
16
- }
17
- export interface PlatformBuilderSettings<App = TsED.Application, Router = TsED.Router> extends Partial<TsED.Configuration> {
18
- adapter?: Type<PlatformAdapter<App, Router>>;
19
- }
@@ -1,16 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { PathType } from "./PathType";
3
- /**
4
- * @ignore
5
- */
6
- export interface PlatformRouteOptions {
7
- token?: Type<any>;
8
- path?: PathType | undefined;
9
- method?: string;
10
- isFinal?: boolean;
11
- handlers: any[];
12
- }
13
- /**
14
- * @ignore
15
- */
16
- export declare type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, "handlers">>;
@@ -1,8 +0,0 @@
1
- /**
2
- * Interface can be implemented to customize the error sent to the client.
3
- */
4
- export interface ResponseErrorObject extends Error {
5
- errors?: Error[] | Error | any;
6
- origin?: Error;
7
- headers?: {};
8
- }
@@ -1,10 +0,0 @@
1
- import { TokenProvider } from "@tsed/di";
2
- import { ControllerProvider } from "../domain/ControllerProvider";
3
- export interface Route extends Record<string, any> {
4
- route: string;
5
- token: TokenProvider;
6
- }
7
- export interface RouteController {
8
- route: string;
9
- provider: ControllerProvider;
10
- }
@@ -1,17 +0,0 @@
1
- export * from "./ResponseErrorObject";
2
- export * from "./HandlerType";
3
- export * from "./PlatformRouteOptions";
4
- export * from "./BeforeInit";
5
- export * from "./AfterInit";
6
- export * from "./AfterRoutesInit";
7
- export * from "./BeforeListen";
8
- export * from "./AfterListen";
9
- export * from "./BeforeRoutesInit";
10
- export * from "./AfterRoutesInit";
11
- export * from "./OnRoutesInit";
12
- export * from "./OnReady";
13
- export * from "./OnRequest";
14
- export * from "./OnResponse";
15
- export * from "./Route";
16
- export * from "./IncomingEvent";
17
- export * from "./PlatformAdapter";
@@ -1,10 +0,0 @@
1
- import { Context } from "@tsed/platform-params";
2
- import { MiddlewareMethods } from "@tsed/platform-middlewares";
3
- /**
4
- * @middleware
5
- * @deprecated Since 2020-11-30. Use PlatformAcceptMimesMiddleware.
6
- * @ignore
7
- */
8
- export declare class AcceptMimesMiddleware implements MiddlewareMethods {
9
- use(ctx: Context): void;
10
- }
@@ -1,9 +0,0 @@
1
- import { MiddlewareMethods } from "@tsed/platform-middlewares";
2
- import { Context } from "@tsed/platform-params";
3
- /**
4
- * @deprecated Since 2020-11-30. Use PlatformAcceptMimesMiddleware.
5
- * @ignore
6
- */
7
- export declare class GlobalAcceptMimesMiddleware implements MiddlewareMethods {
8
- use(ctx: Context): void;
9
- }
@@ -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,19 +0,0 @@
1
- import { MiddlewareMethods } from "@tsed/platform-middlewares";
2
- import { Context } from "@tsed/platform-params";
3
- import { PlatformMulterField, PlatformMulterSettings } from "../config";
4
- import { PlatformApplication } from "../services/PlatformApplication";
5
- export interface MulterInputOptions {
6
- fields: PlatformMulterField[];
7
- }
8
- /**
9
- * @middleware
10
- */
11
- export declare class PlatformMulterMiddleware implements MiddlewareMethods {
12
- settings: PlatformMulterSettings;
13
- app: PlatformApplication;
14
- use(ctx: Context): Promise<any>;
15
- protected getFields(conf: MulterInputOptions): {
16
- name: string;
17
- maxCount: number | undefined;
18
- }[];
19
- }
@@ -1,2 +0,0 @@
1
- export declare class FakeCtrl {
2
- }
@@ -1,5 +0,0 @@
1
- import type { EndpointMetadata, PlatformContext } from "../domain";
2
- /**
3
- * @ignore
4
- */
5
- export declare function bindEndpointMiddleware(endpoint: EndpointMetadata): (ctx: PlatformContext) => void;
@@ -1,5 +0,0 @@
1
- export * from "./bindEndpointMiddleware";
2
- export * from "./PlatformMulterMiddleware";
3
- export * from "./GlobalAcceptMimesMiddleware";
4
- export * from "./PlatformAcceptMimesMiddleware";
5
- export * from "./AcceptMimesMiddleware";
@@ -1,15 +0,0 @@
1
- /**
2
- * @ignore
3
- */
4
- export declare const createFakeRawDriver: () => {
5
- (): void;
6
- use: () => any;
7
- all: () => any;
8
- get: () => any;
9
- patch: () => any;
10
- post: () => any;
11
- put: () => any;
12
- head: () => any;
13
- delete: () => any;
14
- options: () => any;
15
- };
@@ -1,37 +0,0 @@
1
- import { InjectorService, TokenProvider } from "@tsed/di";
2
- import { PlatformRouteDetails } from "../domain";
3
- import { Route, RouteController } from "../interfaces/Route";
4
- import { PlatformApplication } from "./PlatformApplication";
5
- /**
6
- * `Platform` is used to provide all routes collected by annotation `@Controller`.
7
- *
8
- * @platform
9
- */
10
- export declare class Platform {
11
- readonly injector: InjectorService;
12
- readonly platformApplication: PlatformApplication;
13
- private _routes;
14
- private _controllers;
15
- constructor(injector: InjectorService, platformApplication: PlatformApplication);
16
- get app(): PlatformApplication<TsED.Application, TsED.Router>;
17
- get routes(): PlatformRouteDetails[];
18
- addRoutes(routes: Route[]): void;
19
- addRoute(basePath: string, token: TokenProvider): this | undefined;
20
- /**
21
- * Get all routes built by TsExpressDecorators and mounted on Express application.
22
- * @returns {PlatformRouteDetails[]}
23
- */
24
- getRoutes(): PlatformRouteDetails[];
25
- getMountedControllers(): RouteController[];
26
- protected $onInit(): void;
27
- /**
28
- * Create routers from the collected controllers.
29
- * @private
30
- */
31
- private createRouters;
32
- /**
33
- * Create controllers from DI
34
- * @private
35
- */
36
- private buildControllers;
37
- }
@@ -1,21 +0,0 @@
1
- import { PlatformHandler } from "./PlatformHandler";
2
- import { PlatformRouter } from "./PlatformRouter";
3
- declare global {
4
- namespace TsED {
5
- interface Application {
6
- }
7
- }
8
- }
9
- /**
10
- * `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.
11
- *
12
- * @platform
13
- */
14
- export declare class PlatformApplication<App = TsED.Application, Router = TsED.Router> extends PlatformRouter<Router> {
15
- raw: App;
16
- rawApp: App;
17
- rawRouter: Router;
18
- constructor(platformHandler: PlatformHandler);
19
- protected static createRawApp(): any;
20
- getApp(): App;
21
- }
@@ -1,80 +0,0 @@
1
- import { InjectorService, Provider } from "@tsed/di";
2
- import { ArgScope, HandlerWithScope, PlatformParams } from "@tsed/platform-params";
3
- import { PlatformResponseFilter } from "@tsed/platform-response-filter";
4
- import { EndpointMetadata } from "../domain/EndpointMetadata";
5
- import { HandlerMetadata } from "../domain/HandlerMetadata";
6
- import { PlatformContext } from "../domain/PlatformContext";
7
- import { PlatformRouteWithoutHandlers } from "../interfaces/PlatformRouteOptions";
8
- export interface OnRequestOptions {
9
- $ctx: PlatformContext;
10
- metadata: HandlerMetadata;
11
- handler: HandlerWithScope;
12
- next?: any;
13
- err?: any;
14
- [key: string]: any;
15
- }
16
- /**
17
- * Platform Handler abstraction layer. Wrap original class method to a pure platform handler (Express, Koa, etc...).
18
- * @platform
19
- */
20
- export declare class PlatformHandler {
21
- protected injector: InjectorService;
22
- protected params: PlatformParams;
23
- protected responseFilter: PlatformResponseFilter;
24
- constructor(injector: InjectorService, params: PlatformParams);
25
- /**
26
- * Create a native middleware based on the given metadata and return an instance of AnyToPromiseWithCtx
27
- * @param input
28
- * @param options
29
- */
30
- createHandler(input: EndpointMetadata | HandlerMetadata | any, options?: PlatformRouteWithoutHandlers): any;
31
- /**
32
- * Create injectable handler from the given provider
33
- * @param provider
34
- * @param propertyKey
35
- */
36
- createCustomHandler(provider: Provider, propertyKey: string): ($ctx: PlatformContext, next?: any) => Promise<any>;
37
- /**
38
- * Send the response to the consumer.
39
- * @param data
40
- * @param ctx
41
- * @protected
42
- */
43
- flush(data: any, ctx: PlatformContext): Promise<void>;
44
- compileHandler(metadata: HandlerMetadata): (scope: Record<string, any>) => Promise<any>;
45
- protected onCtxRequest(requestOptions: OnRequestOptions): Promise<any>;
46
- /**
47
- * Call handler when a request his handle
48
- * @param requestOptions
49
- */
50
- protected onRequest(requestOptions: OnRequestOptions): Promise<any>;
51
- protected onError(er: Error, requestOptions: OnRequestOptions): Promise<any>;
52
- /**
53
- * Manage success scenario
54
- * @param data
55
- * @param requestOptions
56
- * @protected
57
- */
58
- protected onSuccess(data: any, requestOptions: OnRequestOptions): Promise<any>;
59
- /**
60
- * Call the returned middleware by the handler.
61
- * @param middleware
62
- * @param ctx
63
- * @param next
64
- * @protected
65
- */
66
- protected callReturnedMiddleware(middleware: any, ctx: PlatformContext, next: any): any;
67
- /**
68
- * create Raw handler
69
- * @param metadata
70
- */
71
- protected createRawHandler(metadata: HandlerMetadata): any;
72
- /**
73
- * Set response headers
74
- * @param ctx
75
- * @protected
76
- */
77
- protected setHeaders(ctx: PlatformContext): void;
78
- protected next(requestOptions: OnRequestOptions): any;
79
- protected getDefaultArgs(metadata: HandlerMetadata): (scope: ArgScope<PlatformContext>) => Promise<any[]>;
80
- }
@@ -1,6 +0,0 @@
1
- import { JsonOperationRoute } from "@tsed/schema";
2
- import { ControllerProvider } from "../domain/ControllerProvider";
3
- import { EndpointMetadata } from "../domain/EndpointMetadata";
4
- export declare class PlatformMiddlewaresChain {
5
- get(provider: ControllerProvider, operationRoute: JsonOperationRoute<EndpointMetadata>): any[];
6
- }
@@ -1,112 +0,0 @@
1
- /// <reference types="node" />
2
- import { IncomingHttpHeaders, IncomingMessage } from "http";
3
- import type { PlatformContext } from "../domain/PlatformContext";
4
- import { IncomingEvent } from "../interfaces/IncomingEvent";
5
- import type { PlatformResponse } from "./PlatformResponse";
6
- declare global {
7
- namespace TsED {
8
- interface Request {
9
- id: string;
10
- $ctx: PlatformContext;
11
- }
12
- }
13
- }
14
- /**
15
- * Platform Request abstraction layer.
16
- * @platform
17
- */
18
- export declare class PlatformRequest<T extends {
19
- [key: string]: any;
20
- } = any> {
21
- protected $ctx: PlatformContext;
22
- raw: T;
23
- /**
24
- * The current @@PlatformResponse@@.
25
- */
26
- response: PlatformResponse;
27
- constructor({ request }: IncomingEvent, $ctx: PlatformContext);
28
- get secure(): boolean;
29
- get host(): string;
30
- get protocol(): string;
31
- /**
32
- * Get the url of the request.
33
- *
34
- * Is equivalent of `express.response.originalUrl || express.response.url`.
35
- */
36
- get url(): string;
37
- get headers(): IncomingHttpHeaders;
38
- get method(): string;
39
- /**
40
- * Contains key-value pairs of data submitted in the request body. By default, it is `undefined`, and is populated when you use
41
- * `body-parsing` middleware such as `express.json()` or `express.urlencoded()`.
42
- */
43
- get body(): any;
44
- get rawBody(): any;
45
- /**
46
- * When using `cookie-parser` middleware, this property is an object that contains cookies sent by the request.
47
- * If the request contains no cookies, it defaults to `{}`.
48
- */
49
- get cookies(): {
50
- [key: string]: any;
51
- };
52
- /**
53
- * This property is an object containing properties mapped to the named route `parameters`.
54
- * For example, if you have the route `/user/:name`, then the `name` property is available as `req.params.name`.
55
- * This object defaults to `{}`.
56
- */
57
- get params(): {
58
- [key: string]: any;
59
- };
60
- /**
61
- * This property is an object containing a property for each query string parameter in the route.
62
- * When query parser is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
63
- */
64
- get query(): {
65
- [key: string]: any;
66
- };
67
- /**
68
- * This property is an object containing a property for each session attributes set by any code.
69
- * It require to install a middleware like express-session to work.
70
- */
71
- get session(): {
72
- [key: string]: any;
73
- };
74
- get files(): any;
75
- /**
76
- * Return the original request framework instance
77
- */
78
- get request(): T;
79
- /**
80
- * Return the original request node.js instance
81
- */
82
- get req(): IncomingMessage;
83
- /**
84
- * Returns the HTTP request header specified by field. The match is case-insensitive.
85
- *
86
- * ```typescript
87
- * request.get('Content-Type') // => "text/plain"
88
- * ```
89
- *
90
- * @param name
91
- */
92
- get(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
- destroy(): void;
104
- /**
105
- * Return the Framework response object (express, koa, etc...)
106
- */
107
- getRequest<Req = T>(): Req;
108
- /**
109
- * Return the Node.js response object
110
- */
111
- getReq(): IncomingMessage;
112
- }
@@ -1,161 +0,0 @@
1
- /// <reference types="node" />
2
- import { ServerResponse } from "http";
3
- import { IncomingEvent } from "../interfaces/IncomingEvent";
4
- import type { PlatformRequest } from "./PlatformRequest";
5
- import type { PlatformContext } from "../domain/PlatformContext";
6
- declare global {
7
- namespace TsED {
8
- interface Response {
9
- }
10
- }
11
- }
12
- export declare type HeaderValue = Array<boolean | number | string> | boolean | number | string;
13
- /**
14
- * Platform Response abstraction layer.
15
- * @platform
16
- */
17
- export declare class PlatformResponse<T extends Record<string, any> = any> {
18
- protected $ctx: PlatformContext;
19
- /**
20
- * The current @@PlatformRequest@@.
21
- */
22
- request: PlatformRequest;
23
- data: any;
24
- raw: T;
25
- constructor({ response }: IncomingEvent, $ctx: PlatformContext);
26
- /**
27
- * Get the current statusCode
28
- */
29
- get statusCode(): any;
30
- /**
31
- * 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.
32
- *
33
- * This property is useful for exposing request-level information such as the request path name, authenticated user, user settings, and so on.
34
- */
35
- get locals(): any;
36
- /**
37
- * Return the original response framework instance
38
- */
39
- get response(): T;
40
- /**
41
- * Return the original response node.js instance
42
- */
43
- get res(): ServerResponse;
44
- static onFinished(res: any, cb: Function): void;
45
- /**
46
- * Returns the HTTP response header specified by field. The match is case-insensitive.
47
- *
48
- * ```typescript
49
- * response.get('Content-Type') // => "text/plain"
50
- * ```
51
- *
52
- * @param name
53
- */
54
- get(name: string): any;
55
- getHeaders(): Record<string, HeaderValue>;
56
- /**
57
- * Return the Framework response object (express, koa, etc...)
58
- */
59
- getResponse<Res = T>(): Res;
60
- /**
61
- * Return the Node.js response object
62
- */
63
- getRes(): ServerResponse;
64
- hasStatus(): boolean;
65
- /**
66
- * Sets the HTTP status for the response.
67
- *
68
- * @param status
69
- */
70
- status(status: number): this;
71
- /**
72
- * Set header `field` to `val`, or pass
73
- * an object of header fields.
74
- *
75
- * Examples:
76
- * ```typescript
77
- * response.setHeaders({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
78
- * ```
79
- *
80
- * Aliased as `res.header()`.
81
- */
82
- setHeaders(headers: Record<string, HeaderValue>): this;
83
- setHeader(key: string, item: any): this;
84
- /**
85
- * Set `Content-Type` response header with `type` through `mime.lookup()`
86
- * when it does not contain "/", or set the Content-Type to `type` otherwise.
87
- *
88
- * Examples:
89
- *
90
- * res.type('.html');
91
- * res.type('html');
92
- * res.type('json');
93
- * res.type('application/json');
94
- * res.type('png');
95
- */
96
- contentType(contentType: string): this;
97
- contentLength(length: number): this;
98
- getContentLength(): number | undefined;
99
- getContentType(): any;
100
- /**
101
- * Sets the HTTP response Content-Disposition header field to “attachment”.
102
- * 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.
103
- *
104
- * ```typescript
105
- * res.attachment()
106
- * // Content-Disposition: attachment
107
- *
108
- * res.attachment('path/to/logo.png')
109
- * // Content-Disposition: attachment; filename="logo.png"
110
- * // Content-Type: image/png
111
- * ```
112
- *
113
- * @param filename
114
- */
115
- attachment(filename: string): this;
116
- /**
117
- * 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).
118
- * If not specified, status defaults to `302 Found`.
119
- *
120
- * @param status
121
- * @param url
122
- */
123
- redirect(status: number, url: string): this;
124
- /**
125
- * Sets the response Location HTTP header to the specified path parameter.
126
- *
127
- * @param location
128
- */
129
- location(location: string): this;
130
- /**
131
- * Stream the given data.
132
- *
133
- * @param data
134
- */
135
- stream(data: ReadableStream | any): this;
136
- /**
137
- * Renders a view and sends the rendered HTML string to the client.
138
- *
139
- * @param path
140
- * @param options
141
- */
142
- render(path: string, options?: any): Promise<any>;
143
- /**
144
- * Send any data to your consumer.
145
- *
146
- * This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.
147
- * It choose the better way to send the data.
148
- *
149
- * @param data
150
- */
151
- body(data: any): this;
152
- getBody(): any;
153
- /**
154
- * Add a listener to handler the end of the request/response.
155
- * @param cb
156
- */
157
- onEnd(cb: Function): this;
158
- isDone(): boolean;
159
- destroy(): void;
160
- isHeadersSent(): boolean;
161
- }
@@ -1,48 +0,0 @@
1
- import { InjectorService, PathType } from "@tsed/di";
2
- import { PlatformMulter, PlatformMulterSettings, PlatformStaticsOptions } from "../config";
3
- import { PlatformRouteOptions, PlatformRouteWithoutHandlers } from "../interfaces";
4
- import { PlatformHandler } from "./PlatformHandler";
5
- /**
6
- * @ignore
7
- */
8
- export declare const PLATFORM_ROUTER_OPTIONS: unique symbol;
9
- declare global {
10
- namespace TsED {
11
- interface Router {
12
- }
13
- }
14
- }
15
- /**
16
- * Platform Router abstraction layer.
17
- * @platform
18
- */
19
- export declare class PlatformRouter<Router = TsED.Router> {
20
- protected platformHandler: PlatformHandler;
21
- rawRouter: Router;
22
- raw: any;
23
- isBuilt: boolean;
24
- injector: InjectorService;
25
- constructor(platformHandler: PlatformHandler);
26
- /**
27
- * Create a new instance of PlatformRouter
28
- * @param injector
29
- * @param routerOptions
30
- */
31
- static create(injector: InjectorService, routerOptions?: any): PlatformRouter<TsED.Router>;
32
- protected static createRawRouter(): any;
33
- callback(): any;
34
- getRouter(): Router;
35
- use(...handlers: any[]): this;
36
- addRoute(options: Partial<PlatformRouteOptions>): this;
37
- all(path: PathType, ...handlers: any[]): this;
38
- get(path: PathType, ...handlers: any[]): this;
39
- post(path: PathType, ...handlers: any[]): this;
40
- put(path: PathType, ...handlers: any[]): this;
41
- delete(path: PathType, ...handlers: any[]): this;
42
- patch(path: PathType, ...handlers: any[]): this;
43
- head(path: PathType, ...handlers: any[]): this;
44
- options(path: PathType, ...handlers: any[]): this;
45
- statics(path: string, options: PlatformStaticsOptions): this;
46
- multer(options: PlatformMulterSettings): PlatformMulter;
47
- protected mapHandlers(handlers: any[], options?: PlatformRouteWithoutHandlers): any[];
48
- }