@tsed/common 6.95.9 → 6.96.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.
Files changed (111) hide show
  1. package/lib/cjs/builder/PlatformBuilder.js +1 -1
  2. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  3. package/lib/cjs/domain/AnyToPromiseWithCtx.js +1 -9
  4. package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
  5. package/lib/cjs/domain/PlatformContext.js +8 -1
  6. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  7. package/lib/cjs/services/PlatformHandler.js +3 -5
  8. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  9. package/lib/cjs/services/PlatformTest.js +1 -2
  10. package/lib/cjs/services/PlatformTest.js.map +1 -1
  11. package/lib/esm/builder/PlatformBuilder.js +1 -1
  12. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  13. package/lib/esm/domain/AnyToPromiseWithCtx.js +2 -10
  14. package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
  15. package/lib/esm/domain/PlatformContext.js +8 -1
  16. package/lib/esm/domain/PlatformContext.js.map +1 -1
  17. package/lib/esm/services/PlatformHandler.js +3 -5
  18. package/lib/esm/services/PlatformHandler.js.map +1 -1
  19. package/lib/esm/services/PlatformTest.js +2 -3
  20. package/lib/esm/services/PlatformTest.js.map +1 -1
  21. package/lib/types/services/PlatformTest.d.ts +2 -2
  22. package/package.json +15 -15
  23. package/lib/cjs/PlatformModule.d.ts +0 -6
  24. package/lib/cjs/builder/PlatformBuilder.d.ts +0 -104
  25. package/lib/cjs/builder/PlatformControllerBuilder.d.ts +0 -17
  26. package/lib/cjs/config/index.d.ts +0 -3
  27. package/lib/cjs/config/interfaces/ConverterSettings.d.ts +0 -6
  28. package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
  29. package/lib/cjs/config/interfaces/PlatformLoggerSettings.d.ts +0 -44
  30. package/lib/cjs/config/interfaces/PlatformMulterSettings.d.ts +0 -138
  31. package/lib/cjs/config/interfaces/PlatformStaticsSettings.d.ts +0 -17
  32. package/lib/cjs/config/interfaces/index.d.ts +0 -97
  33. package/lib/cjs/config/services/PlatformConfiguration.d.ts +0 -81
  34. package/lib/cjs/constants/routerOptions.d.ts +0 -1
  35. package/lib/cjs/decorators/httpServer.d.ts +0 -28
  36. package/lib/cjs/decorators/httpsServer.d.ts +0 -28
  37. package/lib/cjs/decorators/index.d.ts +0 -16
  38. package/lib/cjs/decorators/method/acceptMime.d.ts +0 -19
  39. package/lib/cjs/decorators/method/endpointFn.d.ts +0 -9
  40. package/lib/cjs/decorators/method/location.d.ts +0 -1
  41. package/lib/cjs/decorators/method/redirect.d.ts +0 -1
  42. package/lib/cjs/decorators/method/route.d.ts +0 -1
  43. package/lib/cjs/decorators/method/view.d.ts +0 -25
  44. package/lib/cjs/decorators/multer/index.d.ts +0 -3
  45. package/lib/cjs/decorators/multer/multerFileSize.d.ts +0 -27
  46. package/lib/cjs/decorators/multer/multerOptions.d.ts +0 -41
  47. package/lib/cjs/decorators/multer/multipartFile.d.ts +0 -47
  48. package/lib/cjs/decorators/params/endpointInfo.d.ts +0 -13
  49. package/lib/cjs/decorators/params/error.d.ts +0 -7
  50. package/lib/cjs/decorators/params/next.d.ts +0 -22
  51. package/lib/cjs/decorators/params/request.d.ts +0 -46
  52. package/lib/cjs/decorators/params/response.d.ts +0 -40
  53. package/lib/cjs/decorators/params/responseData.d.ts +0 -9
  54. package/lib/cjs/domain/AnyToPromiseWithCtx.d.ts +0 -18
  55. package/lib/cjs/domain/ControllerProvider.d.ts +0 -24
  56. package/lib/cjs/domain/EndpointMetadata.d.ts +0 -50
  57. package/lib/cjs/domain/HandlerMetadata.d.ts +0 -32
  58. package/lib/cjs/domain/PlatformContext.d.ts +0 -65
  59. package/lib/cjs/domain/PlatformRouteDetails.d.ts +0 -23
  60. package/lib/cjs/domain/PropertyMetadata.d.ts +0 -17
  61. package/lib/cjs/domain/index.d.ts +0 -7
  62. package/lib/cjs/index.d.ts +0 -22
  63. package/lib/cjs/interfaces/AfterInit.d.ts +0 -3
  64. package/lib/cjs/interfaces/AfterListen.d.ts +0 -3
  65. package/lib/cjs/interfaces/AfterRoutesInit.d.ts +0 -3
  66. package/lib/cjs/interfaces/BeforeInit.d.ts +0 -3
  67. package/lib/cjs/interfaces/BeforeListen.d.ts +0 -3
  68. package/lib/cjs/interfaces/BeforeRoutesInit.d.ts +0 -3
  69. package/lib/cjs/interfaces/HandlerType.d.ts +0 -12
  70. package/lib/cjs/interfaces/IncomingEvent.d.ts +0 -6
  71. package/lib/cjs/interfaces/OnReady.d.ts +0 -3
  72. package/lib/cjs/interfaces/OnRequest.d.ts +0 -4
  73. package/lib/cjs/interfaces/OnResponse.d.ts +0 -4
  74. package/lib/cjs/interfaces/OnRoutesInit.d.ts +0 -3
  75. package/lib/cjs/interfaces/PathType.d.ts +0 -1
  76. package/lib/cjs/interfaces/PlatformAdapter.d.ts +0 -19
  77. package/lib/cjs/interfaces/PlatformRouteOptions.d.ts +0 -16
  78. package/lib/cjs/interfaces/ResponseErrorObject.d.ts +0 -8
  79. package/lib/cjs/interfaces/Route.d.ts +0 -10
  80. package/lib/cjs/interfaces/index.d.ts +0 -17
  81. package/lib/cjs/middlewares/AcceptMimesMiddleware.d.ts +0 -10
  82. package/lib/cjs/middlewares/GlobalAcceptMimesMiddleware.d.ts +0 -9
  83. package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.d.ts +0 -10
  84. package/lib/cjs/middlewares/PlatformMulterMiddleware.d.ts +0 -19
  85. package/lib/cjs/middlewares/__mock__/FakeCtrl.d.ts +0 -2
  86. package/lib/cjs/middlewares/bindEndpointMiddleware.d.ts +0 -5
  87. package/lib/cjs/middlewares/index.d.ts +0 -5
  88. package/lib/cjs/services/FakeRawDriver.d.ts +0 -15
  89. package/lib/cjs/services/Platform.d.ts +0 -37
  90. package/lib/cjs/services/PlatformApplication.d.ts +0 -21
  91. package/lib/cjs/services/PlatformHandler.d.ts +0 -80
  92. package/lib/cjs/services/PlatformMiddlewaresChain.d.ts +0 -6
  93. package/lib/cjs/services/PlatformRequest.d.ts +0 -112
  94. package/lib/cjs/services/PlatformResponse.d.ts +0 -161
  95. package/lib/cjs/services/PlatformRouter.d.ts +0 -48
  96. package/lib/cjs/services/PlatformTest.d.ts +0 -58
  97. package/lib/cjs/services/index.d.ts +0 -8
  98. package/lib/cjs/utils/createContext.d.ts +0 -9
  99. package/lib/cjs/utils/createHandlerMetadata.d.ts +0 -8
  100. package/lib/cjs/utils/createHttpServer.d.ts +0 -4
  101. package/lib/cjs/utils/createHttpsServer.d.ts +0 -4
  102. package/lib/cjs/utils/createInjector.d.ts +0 -7
  103. package/lib/cjs/utils/getConfiguration.d.ts +0 -2
  104. package/lib/cjs/utils/getStaticsOptions.d.ts +0 -5
  105. package/lib/cjs/utils/index.d.ts +0 -8
  106. package/lib/cjs/utils/listenServer.d.ts +0 -7
  107. package/lib/cjs/utils/loadInjector.d.ts +0 -6
  108. package/lib/cjs/utils/mapReturnedResponse.d.ts +0 -4
  109. package/lib/cjs/utils/printRoutes.d.ts +0 -2
  110. package/lib/cjs/utils/setResponseHeaders.d.ts +0 -5
  111. package/lib/cjs/utils/useCtxHandler.d.ts +0 -13
@@ -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
- }
@@ -1,58 +0,0 @@
1
- import { DITest, InjectorService } from "@tsed/di";
2
- import { PlatformContext, PlatformContextOptions } from "../domain/PlatformContext";
3
- import { PlatformAdapter, PlatformBuilderSettings } from "../interfaces/PlatformAdapter";
4
- import { Type } from "@tsed/core";
5
- /**
6
- * @platform
7
- */
8
- export declare class PlatformTest extends DITest {
9
- static adapter: Type<PlatformAdapter>;
10
- static create(settings?: Partial<TsED.Configuration>): Promise<void>;
11
- /**
12
- * Create a new injector with the right default services
13
- */
14
- static createInjector(settings?: any): InjectorService;
15
- /**
16
- * Load the server silently without listening port and configure it on test profile.
17
- * @decorator
18
- * @param mod
19
- * @param listen
20
- * @param settings
21
- * @returns {Promise<void>}
22
- */
23
- static bootstrap(mod: any, { listen, ...settings }?: Partial<PlatformBuilderSettings & {
24
- listen: boolean;
25
- }>): () => Promise<void>;
26
- /**
27
- * It injects services into the test function where you can alter, spy on, and manipulate them.
28
- *
29
- * The inject function has two parameters
30
- *
31
- * * an array of Service dependency injection tokens,
32
- * * a test function whose parameters correspond exactly to each item in the injection token array.
33
- *
34
- * @param targets
35
- * @param func
36
- */
37
- static inject<T>(targets: any[], func: (...args: any[]) => Promise<T> | T): () => Promise<T>;
38
- /**
39
- * Return the raw application (express or koa).
40
- * Use this callback with SuperTest.
41
- *
42
- * ```typescript
43
- * let request: SuperTest.SuperTest<SuperTest.Test>;
44
- * beforeEach(PlatformTest.bootstrap(Server, {
45
- * mount: {
46
- * "/rest": [ProductsController]
47
- * }
48
- * }));
49
- * beforeEach(() => {
50
- * request = SuperTest(PlatformTest.callback());
51
- * });
52
- * ```
53
- */
54
- static callback(): any;
55
- static createRequest(options?: any): any;
56
- static createResponse(options?: any): any;
57
- static createRequestContext(options?: Partial<PlatformContextOptions & any>): PlatformContext;
58
- }
@@ -1,8 +0,0 @@
1
- export * from "./Platform";
2
- export * from "./PlatformApplication";
3
- export * from "./PlatformHandler";
4
- export * from "./PlatformRequest";
5
- export * from "./PlatformResponse";
6
- export * from "./PlatformRouter";
7
- export * from "./PlatformTest";
8
- export * from "./PlatformMiddlewaresChain";
@@ -1,9 +0,0 @@
1
- import { InjectorService } from "@tsed/di";
2
- import { PlatformContext } from "../domain/PlatformContext";
3
- import { IncomingEvent } from "../interfaces/IncomingEvent";
4
- /**
5
- * Create the TsED context to wrap request, response, injector, etc...
6
- * @param injector
7
- * @ignore
8
- */
9
- export declare function createContext(injector: InjectorService): (event: IncomingEvent) => Promise<PlatformContext>;
@@ -1,8 +0,0 @@
1
- import { InjectorService } from "@tsed/di";
2
- import { EndpointMetadata } from "../domain/EndpointMetadata";
3
- import { HandlerMetadata } from "../domain/HandlerMetadata";
4
- import { PlatformRouteWithoutHandlers } from "../interfaces/PlatformRouteOptions";
5
- /**
6
- * @ignore
7
- */
8
- export declare function createHandlerMetadata(injector: InjectorService, obj: any | EndpointMetadata, routeOptions?: PlatformRouteWithoutHandlers): HandlerMetadata;
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import { InjectorService } from "@tsed/di";
3
- import Http from "http";
4
- export declare function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener): (() => Promise<void>) | undefined;
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import { InjectorService } from "@tsed/di";
3
- import Http from "http";
4
- export declare function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener): (() => Promise<void>) | undefined;
@@ -1,7 +0,0 @@
1
- import { InjectorService, IProvider } from "@tsed/di";
2
- interface CreateInjectorOptions {
3
- providers?: IProvider[];
4
- settings?: Partial<TsED.Configuration>;
5
- }
6
- export declare function createInjector({ providers, settings }: CreateInjectorOptions): InjectorService;
7
- export {};
@@ -1,2 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- export declare function getConfiguration(configuration?: any, module?: Type<any> | null): any;
@@ -1,5 +0,0 @@
1
- import { PlatformStaticsOptions, PlatformStaticsSettings } from "../config/interfaces/PlatformStaticsSettings";
2
- export declare function getStaticsOptions(statics?: PlatformStaticsSettings): {
3
- path: string;
4
- options: PlatformStaticsOptions;
5
- }[];
@@ -1,8 +0,0 @@
1
- export * from "./createInjector";
2
- export * from "./createHttpServer";
3
- export * from "./createHttpsServer";
4
- export * from "./loadInjector";
5
- export * from "./printRoutes";
6
- export * from "./listenServer";
7
- export * from "./createContext";
8
- export * from "./useCtxHandler";
@@ -1,7 +0,0 @@
1
- /// <reference types="node" />
2
- import type Http from "http";
3
- import type Https from "https";
4
- import type Http2 from "http2";
5
- import { InjectorService } from "@tsed/di";
6
- import { getHostInfoFromPort } from "@tsed/core";
7
- export declare function listenServer(injector: InjectorService, server: Http.Server | Https.Server | Http2.Http2Server, hostInfo: ReturnType<typeof getHostInfoFromPort>): Promise<ReturnType<typeof getHostInfoFromPort>>;
@@ -1,6 +0,0 @@
1
- import { Container, InjectorService, LocalsContainer } from "@tsed/di";
2
- /**
3
- * @ignore
4
- * @deprecated User injector.load(container, module) instead
5
- */
6
- export declare function loadInjector(injector: InjectorService, container?: Container): Promise<LocalsContainer<any>>;
@@ -1,4 +0,0 @@
1
- /**
2
- * @ignore
3
- */
4
- export declare function mapReturnedResponse({ use, collection, ...options }: any): any;
@@ -1,2 +0,0 @@
1
- import { PlatformRouteDetails } from "../domain/PlatformRouteDetails";
2
- export declare function printRoutes(routes: PlatformRouteDetails[]): string;
@@ -1,5 +0,0 @@
1
- import { PlatformContext } from "../domain/PlatformContext";
2
- /**
3
- * @ignore
4
- */
5
- export declare function setResponseHeaders(ctx: PlatformContext): void;
@@ -1,13 +0,0 @@
1
- import { PlatformContext } from "../domain/PlatformContext";
2
- import { HandlerType } from "../interfaces/HandlerType";
3
- export declare type PlatformCtxHandler = ($ctx: PlatformContext) => any | Promise<any>;
4
- /**
5
- * Create Ts.ED context handler
6
- * @param fn
7
- * @ignore
8
- */
9
- export declare function useCtxHandler(fn: PlatformCtxHandler & {
10
- type?: HandlerType;
11
- }): PlatformCtxHandler & {
12
- type?: HandlerType | undefined;
13
- };