@tsed/common 6.70.1 → 7.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ /// <reference types="node" />
2
+ import { IncomingMessage, ServerResponse } from "http";
3
+ export interface IncomingEvent<Req = IncomingMessage, Res = ServerResponse> extends Record<string, unknown> {
4
+ response: Res;
5
+ request: Req;
6
+ }
@@ -15,3 +15,4 @@ export * from "./OnRequest";
15
15
  export * from "./OnResponse";
16
16
  export * from "./Route";
17
17
  export * from "./PlatformRouterMethods";
18
+ export * from "./IncomingEvent";
@@ -1,6 +1,4 @@
1
1
  export * from "./bindEndpointMiddleware";
2
2
  export * from "./PlatformLogMiddleware";
3
3
  export * from "./PlatformMulterMiddleware";
4
- export * from "./GlobalAcceptMimesMiddleware";
5
4
  export * from "./PlatformAcceptMimesMiddleware";
6
- export * from "./AcceptMimesMiddleware";
@@ -1,6 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import { IncomingHttpHeaders, IncomingMessage } from "http";
3
3
  import type { PlatformContext } from "../domain/PlatformContext";
4
+ import { IncomingEvent } from "../interfaces/IncomingEvent";
5
+ import type { PlatformResponse } from "./PlatformResponse";
4
6
  declare global {
5
7
  namespace TsED {
6
8
  interface Request {
@@ -17,7 +19,11 @@ export declare class PlatformRequest<T extends {
17
19
  [key: string]: any;
18
20
  } = any> {
19
21
  raw: T;
20
- constructor(raw: T);
22
+ /**
23
+ * The current @@PlatformResponse@@.
24
+ */
25
+ response: PlatformResponse;
26
+ constructor({ request }: IncomingEvent);
21
27
  get secure(): boolean;
22
28
  get host(): string;
23
29
  get protocol(): string;
@@ -1,23 +1,28 @@
1
1
  /// <reference types="node" />
2
2
  import { PlatformViews } from "@tsed/platform-views";
3
3
  import { ServerResponse } from "http";
4
+ import { IncomingEvent } from "../interfaces/IncomingEvent";
5
+ import type { PlatformRequest } from "./PlatformRequest";
4
6
  declare global {
5
7
  namespace TsED {
6
8
  interface Response {
7
9
  }
8
10
  }
9
11
  }
12
+ export declare type HeaderValue = Array<boolean | number | string> | boolean | number | string;
10
13
  /**
11
14
  * Platform Response abstraction layer.
12
15
  * @platform
13
16
  */
14
- export declare class PlatformResponse<T extends {
15
- [key: string]: any;
16
- } = any> {
17
- raw: T;
17
+ export declare class PlatformResponse<T extends Record<string, any> = any> {
18
18
  platformViews: PlatformViews;
19
+ /**
20
+ * The current @@PlatformRequest@@.
21
+ */
22
+ request: PlatformRequest;
19
23
  data: any;
20
- constructor(raw: T);
24
+ raw: T;
25
+ constructor({ response }: IncomingEvent);
21
26
  /**
22
27
  * Get the current statusCode
23
28
  */
@@ -47,7 +52,7 @@ export declare class PlatformResponse<T extends {
47
52
  * @param name
48
53
  */
49
54
  get(name: string): any;
50
- getHeaders(): Record<string, number | string | string[]>;
55
+ getHeaders(): Record<string, HeaderValue>;
51
56
  /**
52
57
  * Return the Framework response object (express, koa, etc...)
53
58
  */
@@ -74,9 +79,7 @@ export declare class PlatformResponse<T extends {
74
79
  *
75
80
  * Aliased as `res.header()`.
76
81
  */
77
- setHeaders(headers: {
78
- [key: string]: any;
79
- }): this;
82
+ setHeaders(headers: Record<string, HeaderValue>): this;
80
83
  setHeader(key: string, item: any): this;
81
84
  /**
82
85
  * Set `Content-Type` response header with `type` through `mime.lookup()`
@@ -51,5 +51,7 @@ export declare class PlatformTest extends DITest {
51
51
  * ```
52
52
  */
53
53
  static callback(): any;
54
- static createRequestContext(options?: Partial<PlatformContextOptions>): PlatformContext;
54
+ static createRequest(options?: any): any;
55
+ static createResponse(options?: any): any;
56
+ static createRequestContext(options?: Partial<PlatformContextOptions & any>): PlatformContext;
55
57
  }
@@ -1,12 +1,9 @@
1
1
  import { InjectorService } from "@tsed/di";
2
2
  import { PlatformContext } from "../domain/PlatformContext";
3
- import { PlatformRequest } from "../services/PlatformRequest";
4
- import { PlatformResponse } from "../services/PlatformResponse";
3
+ import { IncomingEvent } from "../interfaces/IncomingEvent";
5
4
  /**
6
5
  * Create the TsED context to wrap request, response, injector, etc...
7
6
  * @param injector
8
- * @param request
9
- * @param response
10
7
  * @ignore
11
8
  */
12
- export declare function createContext(injector: InjectorService, request: PlatformRequest, response: PlatformResponse): Promise<PlatformContext>;
9
+ export declare function createContext(injector: InjectorService): (event: IncomingEvent) => Promise<PlatformContext>;
@@ -2,7 +2,6 @@ export * from "./createInjector";
2
2
  export * from "./createPlatformApplication";
3
3
  export * from "./createHttpServer";
4
4
  export * from "./createHttpsServer";
5
- export * from "./loadInjector";
6
5
  export * from "./printRoutes";
7
6
  export * from "./listenServer";
8
7
  export * from "./createContext";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/common",
3
- "version": "6.70.1",
3
+ "version": "7.0.0-alpha.1",
4
4
  "description": "A TypeScript Framework on top of Express",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -39,7 +39,7 @@
39
39
  "bugs": {
40
40
  "url": "https://github.com/tsedio/tsed/issues"
41
41
  },
42
- "homepage": "https://github.com/tsedio/tsed/tree/production/packages/platform/common",
42
+ "homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/platform/common",
43
43
  "repository": "https://github.com/tsedio/tsed",
44
44
  "funding": [
45
45
  {
@@ -55,20 +55,20 @@
55
55
  "build": "microbundle --target node --no-compress --format modern,cjs --tsconfig ./tsconfig.compile.json"
56
56
  },
57
57
  "dependencies": {
58
- "@tsed/components-scan": "6.70.1",
59
- "@tsed/core": "6.70.1",
60
- "@tsed/di": "6.70.1",
61
- "@tsed/exceptions": "6.70.1",
62
- "@tsed/json-mapper": "6.70.1",
58
+ "@tsed/components-scan": "7.0.0-alpha.1",
59
+ "@tsed/core": "7.0.0-alpha.1",
60
+ "@tsed/di": "7.0.0-alpha.1",
61
+ "@tsed/exceptions": "7.0.0-alpha.1",
62
+ "@tsed/json-mapper": "7.0.0-alpha.1",
63
63
  "@tsed/logger": "^5.16.0",
64
- "@tsed/perf": "6.70.1",
65
- "@tsed/platform-cache": "6.70.1",
66
- "@tsed/platform-exceptions": "6.70.1",
67
- "@tsed/platform-middlewares": "6.70.1",
68
- "@tsed/platform-params": "6.70.1",
69
- "@tsed/platform-response-filter": "6.70.1",
70
- "@tsed/platform-views": "6.70.1",
71
- "@tsed/schema": "6.70.1",
64
+ "@tsed/perf": "7.0.0-alpha.1",
65
+ "@tsed/platform-cache": "7.0.0-alpha.1",
66
+ "@tsed/platform-exceptions": "7.0.0-alpha.1",
67
+ "@tsed/platform-middlewares": "7.0.0-alpha.1",
68
+ "@tsed/platform-params": "7.0.0-alpha.1",
69
+ "@tsed/platform-response-filter": "7.0.0-alpha.1",
70
+ "@tsed/platform-views": "7.0.0-alpha.1",
71
+ "@tsed/schema": "7.0.0-alpha.1",
72
72
  "@types/json-schema": "7.0.7",
73
73
  "json-schema": "^0.2.3",
74
74
  "on-finished": "2.3.0",
@@ -1,10 +0,0 @@
1
- import { EndpointMetadata } from "../../domain/EndpointMetadata";
2
- export declare type EndpointInfo = EndpointMetadata;
3
- /**
4
- * Get the current endpoint metadata.
5
- * @decorator
6
- * @operation
7
- * @input
8
- * @deprecated Use `@Context() $ctx: Context` then `$ctx.endpoint` instead.
9
- */
10
- export declare function EndpointInfo(): Function;
@@ -1,9 +0,0 @@
1
- /**
2
- * Return the current response data. Prefer the @@Context@@ decorator to get or set data.
3
- *
4
- * @decorator
5
- * @operation
6
- * @input
7
- * @deprecated Use `@Context() $ctx: Context` then $ctx.data.
8
- */
9
- export declare function ResponseData(): ParameterDecorator;
@@ -1,11 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { JsonEntityStore } from "@tsed/schema";
3
- export declare class PropertyMetadata extends JsonEntityStore {
4
- static get(target: Type<any>, propertyKey: string | symbol): PropertyMetadata;
5
- /**
6
- * @deprecated Since 2020-11-11. Use getProperties from @tsed/schema
7
- */
8
- static getProperties(target: Type<any>, options?: Partial<{
9
- withIgnoredProps: boolean;
10
- }>): Map<string | number | symbol, JsonEntityStore>;
11
- }
@@ -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,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>>;