@tsed/common 6.110.2 → 6.113.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/PlatformHandler.js +1 -1
- package/lib/cjs/services/PlatformHandler.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/PlatformHandler.js +2 -2
- package/lib/esm/services/PlatformHandler.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
|
@@ -8,6 +8,7 @@ import { PlatformRouter } from "../services/PlatformRouter.js";
|
|
|
8
8
|
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
9
9
|
import { Platform } from "../services/Platform.js";
|
|
10
10
|
import { PlatformRequest } from "../services/PlatformRequest.js";
|
|
11
|
+
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
11
12
|
$log.name = "TSED";
|
|
12
13
|
const DEFAULT_PROVIDERS = [
|
|
13
14
|
{ provide: PlatformHandler },
|
|
@@ -17,15 +18,22 @@ const DEFAULT_PROVIDERS = [
|
|
|
17
18
|
{ provide: PlatformApplication },
|
|
18
19
|
{ provide: Platform }
|
|
19
20
|
];
|
|
20
|
-
export function createInjector({
|
|
21
|
+
export function createInjector({ adapter, settings = {} }) {
|
|
21
22
|
const injector = new InjectorService();
|
|
22
23
|
injector.addProvider(PlatformConfiguration);
|
|
23
24
|
injector.settings = injector.invoke(PlatformConfiguration);
|
|
24
25
|
injector.logger = $log;
|
|
25
26
|
injector.settings.set(settings);
|
|
27
|
+
if (adapter) {
|
|
28
|
+
injector.addProvider(PlatformAdapter, {
|
|
29
|
+
useClass: adapter
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
injector.invoke(PlatformAdapter);
|
|
26
33
|
setLoggerLevel(injector);
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
const instance = injector.get(PlatformAdapter);
|
|
35
|
+
instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];
|
|
36
|
+
toMap(instance.providers, "provide").forEach((provider, token) => {
|
|
29
37
|
injector.addProvider(token, provider);
|
|
30
38
|
});
|
|
31
39
|
injector.invoke(PlatformApplication);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAgB,cAAc,EAAC,MAAM,UAAU,CAAC;AACvE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAgB,cAAc,EAAC,MAAM,UAAU,CAAC;AACvE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAE5D,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;AAEnB,MAAM,iBAAiB,GAAG;IACxB,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,gBAAgB,EAAC;IAC3B,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,cAAc,EAAC;IACzB,EAAC,OAAO,EAAE,mBAAmB,EAAC;IAC9B,EAAC,OAAO,EAAE,QAAQ,EAAC;CACpB,CAAC;AAOF,MAAM,UAAU,cAAc,CAAC,EAAC,OAAO,EAAE,QAAQ,GAAG,EAAE,EAAwB;IAC5E,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAE5C,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAC3D,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEhC,IAAI,OAAO,EAAE;QACX,QAAQ,CAAC,WAAW,CAAC,eAAe,EAAE;YACpC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;KACJ;IAED,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAkB,eAAe,CAAE,CAAC;IAEjE,QAAQ,CAAC,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEnE,KAAK,CAAoB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAClF,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAErC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {InjectorService, ProviderOpts, setLoggerLevel} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {toMap, Type} from \"@tsed/core\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\nimport {PlatformHandler} from \"../services/PlatformHandler\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\n\n$log.name = \"TSED\";\n\nconst DEFAULT_PROVIDERS = [\n {provide: PlatformHandler},\n {provide: PlatformResponse},\n {provide: PlatformRequest},\n {provide: PlatformRouter},\n {provide: PlatformApplication},\n {provide: Platform}\n];\n\ninterface CreateInjectorOptions {\n adapter?: Type<PlatformAdapter<any, any>>;\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({adapter, settings = {}}: CreateInjectorOptions) {\n const injector = new InjectorService();\n injector.addProvider(PlatformConfiguration);\n\n injector.settings = injector.invoke(PlatformConfiguration);\n injector.logger = $log;\n injector.settings.set(settings);\n\n if (adapter) {\n injector.addProvider(PlatformAdapter, {\n useClass: adapter\n });\n }\n\n injector.invoke(PlatformAdapter);\n\n setLoggerLevel(injector);\n\n const instance = injector.get<PlatformAdapter>(PlatformAdapter)!;\n\n instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];\n\n toMap<any, ProviderOpts>(instance.providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
|
|
@@ -4,13 +4,13 @@ import { InjectorService, ProviderOpts } from "@tsed/di";
|
|
|
4
4
|
import { Platform } from "../services/Platform";
|
|
5
5
|
import { PlatformApplication } from "../services/PlatformApplication";
|
|
6
6
|
import type { IncomingMessage, ServerResponse } from "http";
|
|
7
|
-
import { PlatformAdapter, PlatformBuilderSettings } from "../
|
|
7
|
+
import { PlatformAdapter, PlatformBuilderSettings } from "../services/PlatformAdapter";
|
|
8
8
|
/**
|
|
9
9
|
* @platform
|
|
10
10
|
*/
|
|
11
11
|
export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {
|
|
12
12
|
#private;
|
|
13
|
-
static adapter: Type<PlatformAdapter
|
|
13
|
+
static adapter: Type<PlatformAdapter<any, any>>;
|
|
14
14
|
readonly name: string;
|
|
15
15
|
protected startedAt: Date;
|
|
16
16
|
protected current: Date;
|
|
@@ -19,6 +19,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
19
19
|
get rootModule(): any;
|
|
20
20
|
get app(): PlatformApplication<App, Router>;
|
|
21
21
|
get platform(): Platform;
|
|
22
|
+
get adapter(): PlatformAdapter<App, Router>;
|
|
22
23
|
/**
|
|
23
24
|
* Return the settings configured by the decorator @@Configuration@@.
|
|
24
25
|
*
|
|
@@ -13,5 +13,6 @@ export declare function createRouter(injector: InjectorService, provider: Contro
|
|
|
13
13
|
* @ignore
|
|
14
14
|
* @param injector
|
|
15
15
|
* @param provider
|
|
16
|
+
* @param parentUseBefore
|
|
16
17
|
*/
|
|
17
|
-
export declare function buildRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter<TsED.Router>;
|
|
18
|
+
export declare function buildRouter(injector: InjectorService, provider: ControllerProvider, parentUseBefore?: any[]): PlatformRouter<TsED.Application, TsED.Router>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -43,7 +43,6 @@ export * from "./interfaces/OnReady";
|
|
|
43
43
|
export * from "./interfaces/OnRequest";
|
|
44
44
|
export * from "./interfaces/OnResponse";
|
|
45
45
|
export * from "./interfaces/OnRoutesInit";
|
|
46
|
-
export * from "./interfaces/PlatformAdapter";
|
|
47
46
|
export * from "./interfaces/PlatformRouteOptions";
|
|
48
47
|
export * from "./interfaces/ResponseErrorObject";
|
|
49
48
|
export * from "./interfaces/Route";
|
|
@@ -52,8 +51,9 @@ export * from "./middlewares/GlobalAcceptMimesMiddleware";
|
|
|
52
51
|
export * from "./middlewares/PlatformAcceptMimesMiddleware";
|
|
53
52
|
export * from "./middlewares/PlatformMulterMiddleware";
|
|
54
53
|
export * from "./middlewares/bindEndpointMiddleware";
|
|
55
|
-
export * from "./services/
|
|
54
|
+
export * from "./services/FakeAdapter";
|
|
56
55
|
export * from "./services/Platform";
|
|
56
|
+
export * from "./services/PlatformAdapter";
|
|
57
57
|
export * from "./services/PlatformApplication";
|
|
58
58
|
export * from "./services/PlatformHandler";
|
|
59
59
|
export * from "./services/PlatformMiddlewaresChain";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ProviderOpts } from "@tsed/di";
|
|
2
|
+
import { PlatformAdapter } from "./PlatformAdapter";
|
|
3
|
+
import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings";
|
|
4
|
+
import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings";
|
|
5
|
+
export declare class FakeAdapter implements PlatformAdapter<any, any> {
|
|
6
|
+
providers: ProviderOpts[];
|
|
7
|
+
static createFakeRawDriver(): {
|
|
8
|
+
(): void;
|
|
9
|
+
use: () => any;
|
|
10
|
+
all: () => any;
|
|
11
|
+
get: () => any;
|
|
12
|
+
patch: () => any;
|
|
13
|
+
post: () => any;
|
|
14
|
+
put: () => any;
|
|
15
|
+
head: () => any;
|
|
16
|
+
delete: () => any;
|
|
17
|
+
options: () => any;
|
|
18
|
+
};
|
|
19
|
+
app(): {
|
|
20
|
+
app: any;
|
|
21
|
+
callback(): any;
|
|
22
|
+
};
|
|
23
|
+
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
24
|
+
router(routerOptions: any): {
|
|
25
|
+
router: any;
|
|
26
|
+
callback(): any;
|
|
27
|
+
};
|
|
28
|
+
statics(endpoint: string, options: PlatformStaticsOptions): any;
|
|
29
|
+
bodyParser(type: string): any;
|
|
30
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { ProviderOpts } from "@tsed/di";
|
|
3
|
+
import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings";
|
|
4
|
+
import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings";
|
|
5
|
+
import { RouterOptions } from "express";
|
|
6
|
+
export declare abstract class PlatformAdapter<App = TsED.Application, Router = TsED.Router> {
|
|
7
|
+
/**
|
|
8
|
+
* Load providers in top priority
|
|
9
|
+
*/
|
|
10
|
+
providers: ProviderOpts[];
|
|
11
|
+
/**
|
|
12
|
+
* Called after the injector instantiation
|
|
13
|
+
*/
|
|
14
|
+
onInit?: () => any;
|
|
15
|
+
beforeLoadRoutes?: () => Promise<any>;
|
|
16
|
+
afterLoadRoutes?: () => Promise<any>;
|
|
17
|
+
useRouter?: () => any;
|
|
18
|
+
useContext?: () => any;
|
|
19
|
+
abstract app(): {
|
|
20
|
+
app: App;
|
|
21
|
+
callback(): any;
|
|
22
|
+
};
|
|
23
|
+
abstract router(routerOptions?: Partial<RouterOptions>): {
|
|
24
|
+
router: Router;
|
|
25
|
+
callback(): any;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Return the statics middlewares
|
|
29
|
+
* @param endpoint
|
|
30
|
+
* @param options
|
|
31
|
+
*/
|
|
32
|
+
abstract statics(endpoint: string, options: PlatformStaticsOptions): any;
|
|
33
|
+
/**
|
|
34
|
+
* Return the multipart middleware
|
|
35
|
+
* @param options
|
|
36
|
+
*/
|
|
37
|
+
abstract multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
38
|
+
/**
|
|
39
|
+
* Return the body parser for the given
|
|
40
|
+
* @param type
|
|
41
|
+
* @param opts
|
|
42
|
+
*/
|
|
43
|
+
abstract bodyParser(type: string, opts?: Record<string, any>): any;
|
|
44
|
+
}
|
|
45
|
+
export interface PlatformBuilderSettings<App = TsED.Application, Router = TsED.Router> extends Partial<TsED.Configuration> {
|
|
46
|
+
adapter?: Type<PlatformAdapter<App, Router>>;
|
|
47
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PlatformHandler } from "./PlatformHandler";
|
|
2
2
|
import { PlatformRouter } from "./PlatformRouter";
|
|
3
|
+
import { PlatformAdapter } from "./PlatformAdapter";
|
|
3
4
|
declare global {
|
|
4
5
|
namespace TsED {
|
|
5
6
|
interface Application {
|
|
@@ -11,11 +12,10 @@ declare global {
|
|
|
11
12
|
*
|
|
12
13
|
* @platform
|
|
13
14
|
*/
|
|
14
|
-
export declare class PlatformApplication<App = TsED.Application, Router = TsED.Router> extends PlatformRouter<Router> {
|
|
15
|
+
export declare class PlatformApplication<App = TsED.Application, Router = TsED.Router> extends PlatformRouter<App, Router> {
|
|
15
16
|
raw: App;
|
|
16
17
|
rawApp: App;
|
|
17
18
|
rawRouter: Router;
|
|
18
|
-
constructor(platformHandler: PlatformHandler);
|
|
19
|
-
protected static createRawApp(): any;
|
|
19
|
+
constructor(platformHandler: PlatformHandler, adapter: PlatformAdapter<App, Router>);
|
|
20
20
|
getApp(): App;
|
|
21
21
|
}
|
|
@@ -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.113.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.113.0",
|
|
65
|
+
"@tsed/core": "6.113.0",
|
|
66
|
+
"@tsed/di": "6.113.0",
|
|
67
|
+
"@tsed/exceptions": "6.113.0",
|
|
68
|
+
"@tsed/json-mapper": "6.113.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.113.0",
|
|
72
|
+
"@tsed/platform-cache": "6.113.0",
|
|
73
|
+
"@tsed/platform-exceptions": "6.113.0",
|
|
74
|
+
"@tsed/platform-log-middleware": "6.113.0",
|
|
75
|
+
"@tsed/platform-middlewares": "6.113.0",
|
|
76
|
+
"@tsed/platform-params": "6.113.0",
|
|
77
|
+
"@tsed/platform-response-filter": "6.113.0",
|
|
78
|
+
"@tsed/platform-views": "6.113.0",
|
|
79
|
+
"@tsed/schema": "6.113.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
|
-
};
|