@tsed/common 6.110.2 → 6.111.0
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/cjs/builder/PlatformBuilder.js +10 -6
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
- package/lib/cjs/builder/PlatformControllerBuilder.js +5 -8
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -1
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/services/FakeAdapter.js +55 -0
- package/lib/cjs/services/FakeAdapter.js.map +1 -0
- package/lib/cjs/services/Platform.js +1 -1
- package/lib/cjs/services/Platform.js.map +1 -1
- package/lib/cjs/services/PlatformAdapter.js +14 -0
- package/lib/cjs/services/PlatformAdapter.js.map +1 -0
- package/lib/cjs/services/PlatformApplication.js +9 -11
- package/lib/cjs/services/PlatformApplication.js.map +1 -1
- package/lib/cjs/services/PlatformMiddlewaresChain.js +42 -7
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/cjs/services/PlatformRouter.js +11 -33
- package/lib/cjs/services/PlatformRouter.js.map +1 -1
- package/lib/cjs/services/PlatformTest.js +0 -1
- package/lib/cjs/services/PlatformTest.js.map +1 -1
- package/lib/cjs/utils/createInjector.js +11 -3
- package/lib/cjs/utils/createInjector.js.map +1 -1
- package/lib/esm/builder/PlatformBuilder.js +10 -6
- package/lib/esm/builder/PlatformBuilder.js.map +1 -1
- package/lib/esm/builder/PlatformControllerBuilder.js +5 -8
- package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -1
- package/lib/esm/index.js +2 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/services/FakeAdapter.js +51 -0
- package/lib/esm/services/FakeAdapter.js.map +1 -0
- package/lib/esm/services/Platform.js +1 -1
- package/lib/esm/services/Platform.js.map +1 -1
- package/lib/esm/services/PlatformAdapter.js +10 -0
- package/lib/esm/services/PlatformAdapter.js.map +1 -0
- package/lib/esm/services/PlatformApplication.js +9 -11
- package/lib/esm/services/PlatformApplication.js.map +1 -1
- package/lib/esm/services/PlatformMiddlewaresChain.js +43 -8
- package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/esm/services/PlatformRouter.js +12 -34
- package/lib/esm/services/PlatformRouter.js.map +1 -1
- package/lib/esm/services/PlatformTest.js +0 -1
- package/lib/esm/services/PlatformTest.js.map +1 -1
- package/lib/esm/utils/createInjector.js +11 -3
- package/lib/esm/utils/createInjector.js.map +1 -1
- package/lib/types/builder/PlatformBuilder.d.ts +3 -2
- package/lib/types/builder/PlatformControllerBuilder.d.ts +2 -1
- package/lib/types/index.d.ts +2 -2
- package/lib/types/services/FakeAdapter.d.ts +30 -0
- package/lib/types/services/PlatformAdapter.d.ts +47 -0
- package/lib/types/services/PlatformApplication.d.ts +3 -3
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +4 -1
- package/lib/types/services/PlatformRouter.d.ts +7 -6
- package/lib/types/services/PlatformTest.d.ts +1 -1
- package/lib/types/utils/createInjector.d.ts +5 -3
- package/package.json +15 -15
- package/readme.md +4 -20
- package/lib/cjs/interfaces/PlatformAdapter.js +0 -3
- package/lib/cjs/interfaces/PlatformAdapter.js.map +0 -1
- package/lib/cjs/services/FakeRawDriver.js +0 -26
- package/lib/cjs/services/FakeRawDriver.js.map +0 -1
- package/lib/esm/interfaces/PlatformAdapter.js +0 -2
- package/lib/esm/interfaces/PlatformAdapter.js.map +0 -1
- package/lib/esm/services/FakeRawDriver.js +0 -22
- package/lib/esm/services/FakeRawDriver.js.map +0 -1
- package/lib/types/interfaces/PlatformAdapter.d.ts +0 -19
- package/lib/types/services/FakeRawDriver.d.ts +0 -15
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { JsonOperationRoute } from "@tsed/schema";
|
|
2
2
|
import { ControllerProvider } from "../domain/ControllerProvider";
|
|
3
|
+
import { PlatformAdapter } from "../services/PlatformAdapter";
|
|
3
4
|
export declare class PlatformMiddlewaresChain {
|
|
4
5
|
protected acceptMimes: string[];
|
|
5
|
-
|
|
6
|
+
protected adapter: PlatformAdapter;
|
|
7
|
+
get(provider: ControllerProvider, operationRoute: JsonOperationRoute, parentMiddlewares?: any[]): any[];
|
|
6
8
|
protected hasAcceptMimes(operationRoute: JsonOperationRoute): number;
|
|
9
|
+
protected getParamTypes(middlewares: any[], operationRoute: JsonOperationRoute): any;
|
|
7
10
|
}
|
|
@@ -3,6 +3,8 @@ import { PlatformHandler } from "./PlatformHandler";
|
|
|
3
3
|
import { PlatformRouteOptions, PlatformRouteWithoutHandlers } from "../interfaces/PlatformRouteOptions";
|
|
4
4
|
import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings";
|
|
5
5
|
import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings";
|
|
6
|
+
import { PlatformAdapter } from "./PlatformAdapter";
|
|
7
|
+
import { RouterOptions } from "express";
|
|
6
8
|
/**
|
|
7
9
|
* @ignore
|
|
8
10
|
*/
|
|
@@ -17,22 +19,21 @@ declare global {
|
|
|
17
19
|
* Platform Router abstraction layer.
|
|
18
20
|
* @platform
|
|
19
21
|
*/
|
|
20
|
-
export declare class PlatformRouter<Router = TsED.Router> {
|
|
21
|
-
#private;
|
|
22
|
+
export declare class PlatformRouter<App = TsED.Application, Router = TsED.Router> {
|
|
22
23
|
protected platformHandler: PlatformHandler;
|
|
24
|
+
readonly adapter: PlatformAdapter<App, Router>;
|
|
23
25
|
rawRouter: Router;
|
|
24
26
|
raw: any;
|
|
25
27
|
isBuilt: boolean;
|
|
26
28
|
injector: InjectorService;
|
|
27
|
-
|
|
29
|
+
callback: () => any;
|
|
30
|
+
constructor(platformHandler: PlatformHandler, adapter: PlatformAdapter<App, Router>, routerOptions?: Partial<RouterOptions>);
|
|
28
31
|
/**
|
|
29
32
|
* Create a new instance of PlatformRouter
|
|
30
33
|
* @param injector
|
|
31
34
|
* @param routerOptions
|
|
32
35
|
*/
|
|
33
|
-
static create(injector: InjectorService, routerOptions?: any): PlatformRouter<TsED.Router>;
|
|
34
|
-
protected static createRawRouter(): any;
|
|
35
|
-
callback(): any;
|
|
36
|
+
static create(injector: InjectorService, routerOptions?: any): PlatformRouter<TsED.Application, TsED.Router>;
|
|
36
37
|
getRouter(): Router;
|
|
37
38
|
use(...handlers: any[]): this;
|
|
38
39
|
addRoute(options: Partial<PlatformRouteOptions>): this;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DITest, DITestOptions, InjectorService } from "@tsed/di";
|
|
2
2
|
import { Type } from "@tsed/core";
|
|
3
3
|
import { PlatformContext, PlatformContextOptions } from "../domain/PlatformContext";
|
|
4
|
-
import { PlatformAdapter, PlatformBuilderSettings } from "
|
|
4
|
+
import { PlatformAdapter, PlatformBuilderSettings } from "./PlatformAdapter";
|
|
5
5
|
/**
|
|
6
6
|
* @platform
|
|
7
7
|
*/
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { InjectorService
|
|
1
|
+
import { InjectorService } from "@tsed/di";
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
3
|
+
import { PlatformAdapter } from "../services/PlatformAdapter";
|
|
2
4
|
interface CreateInjectorOptions {
|
|
3
|
-
|
|
5
|
+
adapter?: Type<PlatformAdapter<any, any>>;
|
|
4
6
|
settings?: Partial<TsED.Configuration>;
|
|
5
7
|
}
|
|
6
|
-
export declare function createInjector({
|
|
8
|
+
export declare function createInjector({ adapter, settings }: CreateInjectorOptions): InjectorService;
|
|
7
9
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.111.0",
|
|
4
4
|
"description": "A TypeScript Framework on top of Express",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -61,22 +61,22 @@
|
|
|
61
61
|
}
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@tsed/components-scan": "6.
|
|
65
|
-
"@tsed/core": "6.
|
|
66
|
-
"@tsed/di": "6.
|
|
67
|
-
"@tsed/exceptions": "6.
|
|
68
|
-
"@tsed/json-mapper": "6.
|
|
64
|
+
"@tsed/components-scan": "6.111.0",
|
|
65
|
+
"@tsed/core": "6.111.0",
|
|
66
|
+
"@tsed/di": "6.111.0",
|
|
67
|
+
"@tsed/exceptions": "6.111.0",
|
|
68
|
+
"@tsed/json-mapper": "6.111.0",
|
|
69
69
|
"@tsed/logger": ">=6.1.1",
|
|
70
70
|
"@tsed/logger-file": ">=6.1.0",
|
|
71
|
-
"@tsed/perf": "6.
|
|
72
|
-
"@tsed/platform-cache": "6.
|
|
73
|
-
"@tsed/platform-exceptions": "6.
|
|
74
|
-
"@tsed/platform-log-middleware": "6.
|
|
75
|
-
"@tsed/platform-middlewares": "6.
|
|
76
|
-
"@tsed/platform-params": "6.
|
|
77
|
-
"@tsed/platform-response-filter": "6.
|
|
78
|
-
"@tsed/platform-views": "6.
|
|
79
|
-
"@tsed/schema": "6.
|
|
71
|
+
"@tsed/perf": "6.111.0",
|
|
72
|
+
"@tsed/platform-cache": "6.111.0",
|
|
73
|
+
"@tsed/platform-exceptions": "6.111.0",
|
|
74
|
+
"@tsed/platform-log-middleware": "6.111.0",
|
|
75
|
+
"@tsed/platform-middlewares": "6.111.0",
|
|
76
|
+
"@tsed/platform-params": "6.111.0",
|
|
77
|
+
"@tsed/platform-response-filter": "6.111.0",
|
|
78
|
+
"@tsed/platform-views": "6.111.0",
|
|
79
|
+
"@tsed/schema": "6.111.0",
|
|
80
80
|
"@types/json-schema": "7.0.11",
|
|
81
81
|
"@types/on-finished": "2.3.1",
|
|
82
82
|
"on-finished": "2.4.1",
|
package/readme.md
CHANGED
|
@@ -77,30 +77,14 @@ import {PlatformApplication} from "@tsed/common";
|
|
|
77
77
|
import "@tsed/platform-express";
|
|
78
78
|
import Path from "path";
|
|
79
79
|
import cookieParser from "cookie-parser";
|
|
80
|
-
import bodyParser from "body-parser";
|
|
81
80
|
import compress from "compression";
|
|
82
81
|
import methodOverride from "method-override";
|
|
83
82
|
|
|
84
83
|
@Configuration({
|
|
85
|
-
port: 3000
|
|
84
|
+
port: 3000,
|
|
85
|
+
middlewares: [cookieParser(), compress({}), methodOverride()]
|
|
86
86
|
})
|
|
87
|
-
export class Server {
|
|
88
|
-
@Inject()
|
|
89
|
-
app: PlatformApplication;
|
|
90
|
-
|
|
91
|
-
public $beforeRoutesInit() {
|
|
92
|
-
this.app
|
|
93
|
-
.use(cookieParser())
|
|
94
|
-
.use(compress({}))
|
|
95
|
-
.use(methodOverride())
|
|
96
|
-
.use(bodyParser.json())
|
|
97
|
-
.use(
|
|
98
|
-
bodyParser.urlencoded({
|
|
99
|
-
extended: true
|
|
100
|
-
})
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
87
|
+
export class Server {}
|
|
104
88
|
```
|
|
105
89
|
|
|
106
90
|
To run your server, you have to use Platform API to bootstrap your application with the expected
|
|
@@ -156,7 +140,7 @@ import {User} from "../models/User";
|
|
|
156
140
|
@Controller("/users")
|
|
157
141
|
export class UsersCtrl {
|
|
158
142
|
@Inject()
|
|
159
|
-
usersService: UsersService;
|
|
143
|
+
protected usersService: UsersService;
|
|
160
144
|
|
|
161
145
|
@Get("/:id")
|
|
162
146
|
@Summary("Get a user from his Id")
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformAdapter.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformAdapter.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ProviderOpts} from \"@tsed/di\";\n\nexport interface PlatformAdapter<App = TsED.Application, Router = TsED.Router> {\n /**\n * Load providers in top priority\n */\n readonly providers: ProviderOpts[];\n /**\n * Called after the injector instantiation\n */\n onInit?: () => any;\n beforeLoadRoutes?: () => Promise<any>;\n afterLoadRoutes?: () => Promise<any>;\n useRouter?: () => any;\n useContext?: () => any;\n}\n\nexport interface PlatformBuilderSettings<App = TsED.Application, Router = TsED.Router> extends Partial<TsED.Configuration> {\n adapter?: Type<PlatformAdapter<App, Router>>;\n}\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFakeRawDriver = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @ignore
|
|
6
|
-
*/
|
|
7
|
-
const createFakeRawDriver = () => {
|
|
8
|
-
// istanbul ignore next
|
|
9
|
-
function FakeRawDriver() { }
|
|
10
|
-
// istanbul ignore next
|
|
11
|
-
function use() {
|
|
12
|
-
return this;
|
|
13
|
-
}
|
|
14
|
-
FakeRawDriver.use = use;
|
|
15
|
-
FakeRawDriver.all = use;
|
|
16
|
-
FakeRawDriver.get = use;
|
|
17
|
-
FakeRawDriver.patch = use;
|
|
18
|
-
FakeRawDriver.post = use;
|
|
19
|
-
FakeRawDriver.put = use;
|
|
20
|
-
FakeRawDriver.head = use;
|
|
21
|
-
FakeRawDriver.delete = use;
|
|
22
|
-
FakeRawDriver.options = use;
|
|
23
|
-
return FakeRawDriver;
|
|
24
|
-
};
|
|
25
|
-
exports.createFakeRawDriver = createFakeRawDriver;
|
|
26
|
-
//# sourceMappingURL=FakeRawDriver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FakeRawDriver.js","sourceRoot":"","sources":["../../../src/services/FakeRawDriver.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,uBAAuB;IACvB,SAAS,aAAa,KAAI,CAAC;IAE3B,uBAAuB;IACvB,SAAS,GAAG;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;IACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;IACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;IACxB,aAAa,CAAC,KAAK,GAAG,GAAG,CAAC;IAC1B,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;IACzB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;IACxB,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;IACzB,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC;IAC3B,aAAa,CAAC,OAAO,GAAG,GAAG,CAAC;IAE5B,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AApBW,QAAA,mBAAmB,uBAoB9B","sourcesContent":["/**\n * @ignore\n */\nexport const createFakeRawDriver = () => {\n // istanbul ignore next\n function FakeRawDriver() {}\n\n // istanbul ignore next\n function use() {\n return this;\n }\n\n FakeRawDriver.use = use;\n FakeRawDriver.all = use;\n FakeRawDriver.get = use;\n FakeRawDriver.patch = use;\n FakeRawDriver.post = use;\n FakeRawDriver.put = use;\n FakeRawDriver.head = use;\n FakeRawDriver.delete = use;\n FakeRawDriver.options = use;\n\n return FakeRawDriver;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformAdapter.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformAdapter.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {ProviderOpts} from \"@tsed/di\";\n\nexport interface PlatformAdapter<App = TsED.Application, Router = TsED.Router> {\n /**\n * Load providers in top priority\n */\n readonly providers: ProviderOpts[];\n /**\n * Called after the injector instantiation\n */\n onInit?: () => any;\n beforeLoadRoutes?: () => Promise<any>;\n afterLoadRoutes?: () => Promise<any>;\n useRouter?: () => any;\n useContext?: () => any;\n}\n\nexport interface PlatformBuilderSettings<App = TsED.Application, Router = TsED.Router> extends Partial<TsED.Configuration> {\n adapter?: Type<PlatformAdapter<App, Router>>;\n}\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @ignore
|
|
3
|
-
*/
|
|
4
|
-
export const createFakeRawDriver = () => {
|
|
5
|
-
// istanbul ignore next
|
|
6
|
-
function FakeRawDriver() { }
|
|
7
|
-
// istanbul ignore next
|
|
8
|
-
function use() {
|
|
9
|
-
return this;
|
|
10
|
-
}
|
|
11
|
-
FakeRawDriver.use = use;
|
|
12
|
-
FakeRawDriver.all = use;
|
|
13
|
-
FakeRawDriver.get = use;
|
|
14
|
-
FakeRawDriver.patch = use;
|
|
15
|
-
FakeRawDriver.post = use;
|
|
16
|
-
FakeRawDriver.put = use;
|
|
17
|
-
FakeRawDriver.head = use;
|
|
18
|
-
FakeRawDriver.delete = use;
|
|
19
|
-
FakeRawDriver.options = use;
|
|
20
|
-
return FakeRawDriver;
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=FakeRawDriver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FakeRawDriver.js","sourceRoot":"","sources":["../../../src/services/FakeRawDriver.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,uBAAuB;IACvB,SAAS,aAAa,KAAI,CAAC;IAE3B,uBAAuB;IACvB,SAAS,GAAG;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;IACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;IACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;IACxB,aAAa,CAAC,KAAK,GAAG,GAAG,CAAC;IAC1B,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;IACzB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;IACxB,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;IACzB,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC;IAC3B,aAAa,CAAC,OAAO,GAAG,GAAG,CAAC;IAE5B,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC","sourcesContent":["/**\n * @ignore\n */\nexport const createFakeRawDriver = () => {\n // istanbul ignore next\n function FakeRawDriver() {}\n\n // istanbul ignore next\n function use() {\n return this;\n }\n\n FakeRawDriver.use = use;\n FakeRawDriver.all = use;\n FakeRawDriver.get = use;\n FakeRawDriver.patch = use;\n FakeRawDriver.post = use;\n FakeRawDriver.put = use;\n FakeRawDriver.head = use;\n FakeRawDriver.delete = use;\n FakeRawDriver.options = use;\n\n return FakeRawDriver;\n};\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { ProviderOpts } from "@tsed/di";
|
|
3
|
-
export interface PlatformAdapter<App = TsED.Application, Router = TsED.Router> {
|
|
4
|
-
/**
|
|
5
|
-
* Load providers in top priority
|
|
6
|
-
*/
|
|
7
|
-
readonly providers: ProviderOpts[];
|
|
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,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
|
-
};
|