@tsed/platform-koa 7.0.0-beta.2 → 7.0.0-beta.20
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/coverage.json +6 -0
- package/jest.config.js +9 -0
- package/lib/cjs/components/PlatformKoa.js +121 -45
- package/lib/cjs/components/PlatformKoa.js.map +1 -1
- package/lib/cjs/exports.js +7 -0
- package/lib/cjs/exports.js.map +1 -0
- package/lib/cjs/index.js +14 -12
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/PlatformKoaSettings.js.map +1 -1
- package/lib/cjs/interfaces/{index.js → interfaces.js} +2 -2
- package/lib/cjs/interfaces/interfaces.js.map +1 -0
- package/lib/cjs/middlewares/staticsMiddleware.js +1 -1
- package/lib/cjs/middlewares/staticsMiddleware.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/PlatformKoaHandler.js +6 -48
- package/lib/cjs/services/PlatformKoaHandler.js.map +1 -1
- package/lib/cjs/services/PlatformKoaRequest.js +8 -18
- package/lib/cjs/services/PlatformKoaRequest.js.map +1 -1
- package/lib/cjs/services/PlatformKoaResponse.js +5 -9
- package/lib/cjs/services/PlatformKoaResponse.js.map +1 -1
- package/lib/cjs/utils/multer.js +26 -1
- package/lib/cjs/utils/multer.js.map +1 -1
- package/lib/esm/components/PlatformKoa.js +121 -46
- package/lib/esm/components/PlatformKoa.js.map +1 -1
- package/lib/esm/exports.js +5 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +14 -12
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/PlatformKoaSettings.js.map +1 -1
- package/lib/esm/interfaces/interfaces.js +2 -0
- package/lib/esm/interfaces/interfaces.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/PlatformKoaHandler.js +8 -50
- package/lib/esm/services/PlatformKoaHandler.js.map +1 -1
- package/lib/esm/services/PlatformKoaRequest.js +8 -18
- package/lib/esm/services/PlatformKoaRequest.js.map +1 -1
- package/lib/esm/services/PlatformKoaResponse.js +4 -9
- package/lib/esm/services/PlatformKoaResponse.js.map +1 -1
- package/lib/esm/utils/multer.js +3 -1
- package/lib/esm/utils/multer.js.map +1 -1
- package/lib/types/components/PlatformKoa.d.ts +31 -16
- package/lib/types/exports.d.ts +1 -0
- package/lib/types/index.d.ts +13 -3
- package/lib/types/interfaces/PlatformKoaSettings.d.ts +10 -3
- package/lib/types/interfaces/{index.d.ts → interfaces.d.ts} +0 -0
- package/lib/types/services/PlatformKoaHandler.d.ts +2 -7
- package/lib/types/services/PlatformKoaRequest.d.ts +3 -6
- package/lib/types/services/PlatformKoaResponse.d.ts +3 -4
- package/package.json +62 -29
- package/readme.md +3 -4
- package/tsconfig.compile.esm.json +1 -12
- package/lib/cjs/decorators/caseSensitive.js +0 -30
- package/lib/cjs/decorators/caseSensitive.js.map +0 -1
- package/lib/cjs/decorators/index.js +0 -9
- package/lib/cjs/decorators/index.js.map +0 -1
- package/lib/cjs/decorators/routerSettings.js +0 -31
- package/lib/cjs/decorators/routerSettings.js.map +0 -1
- package/lib/cjs/decorators/strict.js +0 -31
- package/lib/cjs/decorators/strict.js.map +0 -1
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/cjs/middlewares/resourceNotFoundMiddleware.js +0 -20
- package/lib/cjs/middlewares/resourceNotFoundMiddleware.js.map +0 -1
- package/lib/cjs/services/PlatformKoaApplication.js +0 -32
- package/lib/cjs/services/PlatformKoaApplication.js.map +0 -1
- package/lib/cjs/services/PlatformKoaRouter.js +0 -45
- package/lib/cjs/services/PlatformKoaRouter.js.map +0 -1
- package/lib/cjs/services/index.js +0 -9
- package/lib/cjs/services/index.js.map +0 -1
- package/lib/esm/decorators/caseSensitive.js +0 -26
- package/lib/esm/decorators/caseSensitive.js.map +0 -1
- package/lib/esm/decorators/index.js +0 -6
- package/lib/esm/decorators/index.js.map +0 -1
- package/lib/esm/decorators/routerSettings.js +0 -27
- package/lib/esm/decorators/routerSettings.js.map +0 -1
- package/lib/esm/decorators/strict.js +0 -27
- package/lib/esm/decorators/strict.js.map +0 -1
- package/lib/esm/interfaces/index.js +0 -2
- package/lib/esm/interfaces/index.js.map +0 -1
- package/lib/esm/middlewares/resourceNotFoundMiddleware.js +0 -16
- package/lib/esm/middlewares/resourceNotFoundMiddleware.js.map +0 -1
- package/lib/esm/services/PlatformKoaApplication.js +0 -29
- package/lib/esm/services/PlatformKoaApplication.js.map +0 -1
- package/lib/esm/services/PlatformKoaRouter.js +0 -42
- package/lib/esm/services/PlatformKoaRouter.js.map +0 -1
- package/lib/esm/services/index.js +0 -6
- package/lib/esm/services/index.js.map +0 -1
- package/lib/types/decorators/caseSensitive.d.ts +0 -22
- package/lib/types/decorators/index.d.ts +0 -5
- package/lib/types/decorators/routerSettings.d.ts +0 -24
- package/lib/types/decorators/strict.d.ts +0 -23
- package/lib/types/middlewares/resourceNotFoundMiddleware.d.ts +0 -6
- package/lib/types/services/PlatformKoaApplication.d.ts +0 -22
- package/lib/types/services/PlatformKoaRouter.d.ts +0 -22
- package/lib/types/services/index.d.ts +0 -5
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import KoaRouter from "@koa/router";
|
|
3
|
-
import { PlatformAdapter, PlatformApplication, PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse, PlatformRouter } from "@tsed/common";
|
|
1
|
+
import { InjectorService, PlatformAdapter, PlatformBuilder, PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformRequest, PlatformResponse, PlatformStaticsOptions } from "@tsed/common";
|
|
4
2
|
import { Type } from "@tsed/core";
|
|
3
|
+
import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
|
|
5
4
|
import Koa from "koa";
|
|
6
|
-
import
|
|
5
|
+
import send from "koa-send";
|
|
6
|
+
import { PlatformKoaHandler } from "../services/PlatformKoaHandler";
|
|
7
|
+
import { PlatformKoaRequest } from "../services/PlatformKoaRequest";
|
|
8
|
+
import { PlatformKoaResponse } from "../services/PlatformKoaResponse";
|
|
9
|
+
declare global {
|
|
10
|
+
namespace TsED {
|
|
11
|
+
interface Application extends Koa {
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
namespace TsED {
|
|
15
|
+
interface StaticsOptions extends send.SendOptions {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
7
19
|
/**
|
|
8
20
|
* @platform
|
|
9
21
|
* @koa
|
|
10
22
|
*/
|
|
11
|
-
export declare class PlatformKoa implements PlatformAdapter<Koa
|
|
12
|
-
private
|
|
23
|
+
export declare class PlatformKoa implements PlatformAdapter<Koa> {
|
|
24
|
+
private injector;
|
|
13
25
|
readonly providers: ({
|
|
14
26
|
provide: typeof PlatformResponse;
|
|
15
27
|
useClass: typeof PlatformKoaResponse;
|
|
@@ -19,27 +31,30 @@ export declare class PlatformKoa implements PlatformAdapter<Koa, KoaRouter> {
|
|
|
19
31
|
} | {
|
|
20
32
|
provide: typeof PlatformHandler;
|
|
21
33
|
useClass: typeof PlatformKoaHandler;
|
|
22
|
-
} | {
|
|
23
|
-
provide: typeof PlatformRouter;
|
|
24
|
-
useClass: typeof PlatformKoaRouter;
|
|
25
|
-
} | {
|
|
26
|
-
provide: typeof PlatformApplication;
|
|
27
|
-
useClass: typeof PlatformKoaApplication;
|
|
28
34
|
})[];
|
|
29
|
-
constructor(
|
|
35
|
+
constructor(injector: InjectorService);
|
|
30
36
|
/**
|
|
31
37
|
* Create new serverless application. In this mode, the component scan are disabled.
|
|
32
38
|
* @param module
|
|
33
39
|
* @param settings
|
|
34
40
|
*/
|
|
35
|
-
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext
|
|
41
|
+
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>>;
|
|
36
42
|
/**
|
|
37
43
|
* Bootstrap a server application
|
|
38
44
|
* @param module
|
|
39
45
|
* @param settings
|
|
40
46
|
*/
|
|
41
|
-
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext
|
|
47
|
+
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>>>;
|
|
42
48
|
onInit(): void;
|
|
43
|
-
|
|
49
|
+
mapLayers(layers: PlatformLayer[]): void;
|
|
50
|
+
mapHandler(handler: Function, metadata: PlatformHandlerMetadata): Function;
|
|
44
51
|
useContext(): this;
|
|
52
|
+
app(): {
|
|
53
|
+
app: any;
|
|
54
|
+
callback(): any;
|
|
55
|
+
};
|
|
56
|
+
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
57
|
+
statics(endpoint: string, options: PlatformStaticsOptions): any;
|
|
58
|
+
bodyParser(type: "json" | "urlencoded" | "raw" | "text", additionalOptions?: any): any;
|
|
59
|
+
private getPlatformApplication;
|
|
45
60
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./exports";
|
|
4
5
|
export * from "./components/PlatformKoa";
|
|
6
|
+
export * from "./decorators/ctx";
|
|
7
|
+
export * from "./decorators/state";
|
|
8
|
+
export * from "./interfaces/PlatformKoaSettings";
|
|
9
|
+
export * from "./interfaces/interfaces";
|
|
10
|
+
export * from "./middlewares/staticsMiddleware";
|
|
11
|
+
export * from "./services/PlatformKoaHandler";
|
|
12
|
+
export * from "./services/PlatformKoaRequest";
|
|
13
|
+
export * from "./services/PlatformKoaResponse";
|
|
14
|
+
export * from "./utils/multer";
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
/// <reference types="koa__router" />
|
|
2
|
-
import { RouterOptions } from "@koa/router";
|
|
2
|
+
import type { RouterOptions } from "@koa/router";
|
|
3
|
+
import type { Middleware } from "koa";
|
|
4
|
+
import type { Options } from "koa-bodyparser";
|
|
3
5
|
export interface PlatformKoaSettings {
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* Koa router options
|
|
6
8
|
*/
|
|
7
|
-
router
|
|
9
|
+
router?: RouterOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Body parser options
|
|
12
|
+
* @param opts
|
|
13
|
+
*/
|
|
14
|
+
bodyParser?: ((opts?: Options) => Middleware) | Options;
|
|
8
15
|
}
|
|
File without changes
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlatformContext, PlatformHandler } from "@tsed/common";
|
|
2
2
|
import "./PlatformKoaRequest";
|
|
3
3
|
export declare class PlatformKoaHandler extends PlatformHandler {
|
|
4
|
-
flush(
|
|
5
|
-
protected createRawHandler(metadata: HandlerMetadata): any;
|
|
6
|
-
protected onRequest(requestOptions: OnRequestOptions): Promise<any>;
|
|
7
|
-
protected onError(error: unknown, requestOptions: OnRequestOptions): any;
|
|
8
|
-
protected onCtxRequest(requestOptions: OnRequestOptions): Promise<any>;
|
|
9
|
-
protected throwError(error: any, $ctx: PlatformContext): void;
|
|
4
|
+
flush($ctx: PlatformContext): Promise<void>;
|
|
10
5
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import "@koa/router";
|
|
3
|
-
import {
|
|
4
|
-
import { IncomingMessage } from "http";
|
|
3
|
+
import { PlatformContext, PlatformRequest } from "@tsed/common";
|
|
5
4
|
import Koa from "koa";
|
|
6
5
|
declare module "koa" {
|
|
7
6
|
interface Request {
|
|
@@ -20,8 +19,7 @@ declare global {
|
|
|
20
19
|
* @koa
|
|
21
20
|
*/
|
|
22
21
|
export declare class PlatformKoaRequest extends PlatformRequest<Koa.Request> {
|
|
23
|
-
|
|
24
|
-
constructor(event: IncomingEvent, $ctx: PlatformContext);
|
|
22
|
+
get ctx(): Koa.Context;
|
|
25
23
|
get protocol(): string;
|
|
26
24
|
get host(): string;
|
|
27
25
|
get secure(): boolean;
|
|
@@ -29,6 +27,5 @@ export declare class PlatformKoaRequest extends PlatformRequest<Koa.Request> {
|
|
|
29
27
|
[p: string]: any;
|
|
30
28
|
};
|
|
31
29
|
get session(): any;
|
|
32
|
-
getReq(): IncomingMessage;
|
|
33
|
-
destroy(): void;
|
|
30
|
+
getReq(): import("http").IncomingMessage;
|
|
34
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { PlatformResponse } from "@tsed/common";
|
|
3
3
|
import { ServerResponse } from "http";
|
|
4
4
|
import Koa from "koa";
|
|
5
5
|
declare global {
|
|
@@ -13,8 +13,7 @@ declare global {
|
|
|
13
13
|
* @koa
|
|
14
14
|
*/
|
|
15
15
|
export declare class PlatformKoaResponse extends PlatformResponse<Koa.Response> {
|
|
16
|
-
|
|
17
|
-
constructor(event: IncomingEvent, $ctx: PlatformContext);
|
|
16
|
+
get ctx(): Koa.Context;
|
|
18
17
|
get statusCode(): number;
|
|
19
18
|
get locals(): Koa.DefaultState;
|
|
20
19
|
/**
|
|
@@ -41,7 +40,7 @@ export declare class PlatformKoaResponse extends PlatformResponse<Koa.Response>
|
|
|
41
40
|
* res.type('png');
|
|
42
41
|
*/
|
|
43
42
|
contentType(contentType: string): this;
|
|
44
|
-
getHeaders():
|
|
43
|
+
getHeaders(): import("http").OutgoingHttpHeaders;
|
|
45
44
|
/**
|
|
46
45
|
* Send any data to your consumer.
|
|
47
46
|
*
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-koa",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.20",
|
|
4
4
|
"description": "Koa package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/cjs/index.js",
|
|
8
|
+
"module": "./lib/esm/index.js",
|
|
8
9
|
"typings": "./lib/types/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
11
|
"types": "./lib/types/index.d.ts",
|
|
@@ -13,10 +14,12 @@
|
|
|
13
14
|
"default": "./lib/esm/index.js"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
|
-
"build": "yarn run build:esm && yarn run build:cjs",
|
|
17
|
+
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
17
18
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
18
19
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
19
|
-
"
|
|
20
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
21
|
+
"start": "ts-node -r tsconfig-paths/register test/app/index.ts",
|
|
22
|
+
"test": "cross-env NODE_ENV=test yarn jest --max-workers=2 --testTimeout 10000"
|
|
20
23
|
},
|
|
21
24
|
"keywords": [
|
|
22
25
|
"Koa",
|
|
@@ -45,26 +48,26 @@
|
|
|
45
48
|
"bugs": {
|
|
46
49
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
47
50
|
},
|
|
48
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
51
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/platform/platform-koa",
|
|
49
52
|
"repository": "https://github.com/tsedio/tsed",
|
|
50
53
|
"devDependencies": {
|
|
51
|
-
"@koa/cors": "3.
|
|
52
|
-
"@tsed/common": "7.0.0-beta.
|
|
53
|
-
"@tsed/core": "7.0.0-beta.
|
|
54
|
-
"@tsed/di": "7.0.0-beta.
|
|
55
|
-
"@tsed/platform-test-utils": "7.0.0-beta.
|
|
56
|
-
"@types/koa": "2.
|
|
57
|
-
"@types/koa-bodyparser": "4.3.
|
|
54
|
+
"@koa/cors": "3.3.0",
|
|
55
|
+
"@tsed/common": "7.0.0-beta.20",
|
|
56
|
+
"@tsed/core": "7.0.0-beta.20",
|
|
57
|
+
"@tsed/di": "7.0.0-beta.20",
|
|
58
|
+
"@tsed/platform-test-utils": "7.0.0-beta.20",
|
|
59
|
+
"@types/koa": "2.13.4",
|
|
60
|
+
"@types/koa-bodyparser": "4.3.7",
|
|
58
61
|
"@types/koa-compose": "3.2.5",
|
|
59
|
-
"@types/koa-compress": "4.0.
|
|
60
|
-
"@types/koa-json": "2.0.
|
|
61
|
-
"@types/koa-mount": "4.0.
|
|
62
|
-
"@types/koa-send": "4.1.
|
|
63
|
-
"@types/koa-session": "5.10.
|
|
64
|
-
"@types/koa__router": "8.0.
|
|
65
|
-
"koa": "2.13.
|
|
62
|
+
"@types/koa-compress": "4.0.3",
|
|
63
|
+
"@types/koa-json": "2.0.20",
|
|
64
|
+
"@types/koa-mount": "4.0.1",
|
|
65
|
+
"@types/koa-send": "4.1.3",
|
|
66
|
+
"@types/koa-session": "5.10.6",
|
|
67
|
+
"@types/koa__router": "8.0.11",
|
|
68
|
+
"koa": "2.13.4",
|
|
66
69
|
"koa-bodyparser": "4.3.0",
|
|
67
|
-
"koa-compress": "5.0
|
|
70
|
+
"koa-compress": "5.1.0",
|
|
68
71
|
"koa-override": "3.0.0",
|
|
69
72
|
"koa-qs": "^3.0.0",
|
|
70
73
|
"koa-session": "6.2.0"
|
|
@@ -73,22 +76,52 @@
|
|
|
73
76
|
"@koa/router": "^10.1.1",
|
|
74
77
|
"encodeurl": "^1.0.2",
|
|
75
78
|
"koa-send": "5.0.1",
|
|
76
|
-
"multer": "^1.4.
|
|
77
|
-
"tslib": "2.
|
|
79
|
+
"multer": "^1.4.5-lts.1",
|
|
80
|
+
"tslib": "2.4.0"
|
|
78
81
|
},
|
|
79
82
|
"peerDependencies": {
|
|
80
|
-
"@tsed/common": "^7.0.0-beta.
|
|
81
|
-
"@tsed/core": "^7.0.0-beta.
|
|
82
|
-
"@tsed/di": "^7.0.0-beta.
|
|
83
|
-
"@tsed/json-mapper": "^7.0.0-beta.
|
|
84
|
-
"@tsed/logger": ">=6.
|
|
85
|
-
"@tsed/openspec": "^7.0.0-beta.
|
|
86
|
-
"@tsed/schema": "^7.0.0-beta.
|
|
83
|
+
"@tsed/common": "^7.0.0-beta.20",
|
|
84
|
+
"@tsed/core": "^7.0.0-beta.20",
|
|
85
|
+
"@tsed/di": "^7.0.0-beta.20",
|
|
86
|
+
"@tsed/json-mapper": "^7.0.0-beta.20",
|
|
87
|
+
"@tsed/logger": ">=6.2.0",
|
|
88
|
+
"@tsed/openspec": "^7.0.0-beta.20",
|
|
89
|
+
"@tsed/schema": "^7.0.0-beta.20",
|
|
87
90
|
"koa": ">=2.13.0",
|
|
88
91
|
"koa-bodyparser": ">=4.3.0",
|
|
89
92
|
"koa-compress": ">=5.0.1",
|
|
90
93
|
"koa-override": ">=3.0.0",
|
|
91
94
|
"koa-qs": ">=3.0.0",
|
|
92
|
-
"koa-session": ">=6.2.0"
|
|
95
|
+
"koa-session": ">=6.2.0",
|
|
96
|
+
"multer": "^1.4.5-lts.1"
|
|
97
|
+
},
|
|
98
|
+
"peerDependenciesMeta": {
|
|
99
|
+
"@tsed/common": {
|
|
100
|
+
"optional": false
|
|
101
|
+
},
|
|
102
|
+
"@tsed/core": {
|
|
103
|
+
"optional": false
|
|
104
|
+
},
|
|
105
|
+
"@tsed/di": {
|
|
106
|
+
"optional": false
|
|
107
|
+
},
|
|
108
|
+
"@tsed/json-mapper": {
|
|
109
|
+
"optional": false
|
|
110
|
+
},
|
|
111
|
+
"@tsed/openspec": {
|
|
112
|
+
"optional": false
|
|
113
|
+
},
|
|
114
|
+
"@tsed/schema": {
|
|
115
|
+
"optional": false
|
|
116
|
+
},
|
|
117
|
+
"@tsed/logger": {
|
|
118
|
+
"optional": false
|
|
119
|
+
},
|
|
120
|
+
"multer": {
|
|
121
|
+
"optional": false
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"publishConfig": {
|
|
125
|
+
"tag": "beta"
|
|
93
126
|
}
|
|
94
127
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -44,14 +45,12 @@ Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
|
|
|
44
45
|
|
|
45
46
|
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
46
47
|
|
|
47
|
-
|
|
48
48
|
## Backers
|
|
49
49
|
|
|
50
50
|
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
|
|
51
51
|
|
|
52
52
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
|
|
53
53
|
|
|
54
|
-
|
|
55
54
|
## Sponsors
|
|
56
55
|
|
|
57
56
|
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
|
|
@@ -60,7 +59,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
60
59
|
|
|
61
60
|
The MIT License (MIT)
|
|
62
61
|
|
|
63
|
-
Copyright (c) 2016 -
|
|
62
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
64
63
|
|
|
65
64
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
66
65
|
|
|
@@ -8,16 +8,5 @@
|
|
|
8
8
|
"declaration": true,
|
|
9
9
|
"declarationDir": "./lib/types"
|
|
10
10
|
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"node_modules",
|
|
13
|
-
"test",
|
|
14
|
-
"lib",
|
|
15
|
-
"benchmark",
|
|
16
|
-
"coverage",
|
|
17
|
-
"spec",
|
|
18
|
-
"**/*.benchmark.ts",
|
|
19
|
-
"**/*.spec.ts",
|
|
20
|
-
"keys",
|
|
21
|
-
"jest.config.js"
|
|
22
|
-
]
|
|
11
|
+
"exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
|
|
23
12
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CaseSensitive = void 0;
|
|
4
|
-
const routerSettings_1 = require("./routerSettings");
|
|
5
|
-
/**
|
|
6
|
-
* Specify the behavior of the router controller.
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @Controller("/")
|
|
10
|
-
* @CaseSensitive(true)
|
|
11
|
-
* class MyCtrl {
|
|
12
|
-
*
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* Property | Description | Default
|
|
17
|
-
* ---|---|---
|
|
18
|
-
* CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
|
|
19
|
-
* Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
|
|
20
|
-
*
|
|
21
|
-
* @returns {Function}
|
|
22
|
-
* @decorator
|
|
23
|
-
* @koa
|
|
24
|
-
* @param sensitive
|
|
25
|
-
*/
|
|
26
|
-
function CaseSensitive(sensitive) {
|
|
27
|
-
return (0, routerSettings_1.RouterSettings)({ sensitive });
|
|
28
|
-
}
|
|
29
|
-
exports.CaseSensitive = CaseSensitive;
|
|
30
|
-
//# sourceMappingURL=caseSensitive.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"caseSensitive.js","sourceRoot":"","sources":["../../../src/decorators/caseSensitive.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,aAAa,CAAC,SAAkB;IAC9C,OAAO,IAAA,+BAAc,EAAC,EAAC,SAAS,EAAC,CAAC,CAAC;AACrC,CAAC;AAFD,sCAEC","sourcesContent":["import {RouterSettings} from \"./routerSettings\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @CaseSensitive(true)\n * class MyCtrl {\n *\n * }\n * ```\n *\n * Property | Description | Default\n * ---|---|---\n * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.\n * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.\n *\n * @returns {Function}\n * @decorator\n * @koa\n * @param sensitive\n */\nexport function CaseSensitive(sensitive: boolean) {\n return RouterSettings({sensitive});\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
(0, tslib_1.__exportStar)(require("./routerSettings"), exports);
|
|
5
|
-
(0, tslib_1.__exportStar)(require("./caseSensitive"), exports);
|
|
6
|
-
(0, tslib_1.__exportStar)(require("./strict"), exports);
|
|
7
|
-
(0, tslib_1.__exportStar)(require("./state"), exports);
|
|
8
|
-
(0, tslib_1.__exportStar)(require("./ctx"), exports);
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,gEAAiC;AACjC,+DAAgC;AAChC,wDAAyB;AACzB,uDAAwB;AACxB,qDAAsB","sourcesContent":["export * from \"./routerSettings\";\nexport * from \"./caseSensitive\";\nexport * from \"./strict\";\nexport * from \"./state\";\nexport * from \"./ctx\";\n"]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RouterSettings = void 0;
|
|
4
|
-
const common_1 = require("@tsed/common");
|
|
5
|
-
const core_1 = require("@tsed/core");
|
|
6
|
-
/**
|
|
7
|
-
* Specify the behavior of the router controller.
|
|
8
|
-
*
|
|
9
|
-
* ```typescript
|
|
10
|
-
* @Controller("/")
|
|
11
|
-
* @RouterSettings({sensitive: true})
|
|
12
|
-
* class MyCtrl {
|
|
13
|
-
*
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* Property | Description | Default
|
|
18
|
-
* ---|---|---
|
|
19
|
-
* sensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
|
|
20
|
-
* strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
|
|
21
|
-
*
|
|
22
|
-
* @returns {(target:any)=>void}
|
|
23
|
-
* @decorator
|
|
24
|
-
* @param routerOptions
|
|
25
|
-
* @koa
|
|
26
|
-
*/
|
|
27
|
-
function RouterSettings(routerOptions) {
|
|
28
|
-
return (0, core_1.StoreMerge)(common_1.ROUTER_OPTIONS, routerOptions);
|
|
29
|
-
}
|
|
30
|
-
exports.RouterSettings = RouterSettings;
|
|
31
|
-
//# sourceMappingURL=routerSettings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routerSettings.js","sourceRoot":"","sources":["../../../src/decorators/routerSettings.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAC5C,qCAAsC;AAGtC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,cAAc,CAAC,aAA4B;IACzD,OAAO,IAAA,iBAAU,EAAC,uBAAc,EAAE,aAAa,CAAC,CAAC;AACnD,CAAC;AAFD,wCAEC","sourcesContent":["import {ROUTER_OPTIONS} from \"@tsed/common\";\nimport {StoreMerge} from \"@tsed/core\";\nimport {RouterOptions} from \"@koa/router\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @RouterSettings({sensitive: true})\n * class MyCtrl {\n *\n * }\n * ```\n *\n * Property | Description | Default\n * ---|---|---\n * sensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.\n * strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.\n *\n * @returns {(target:any)=>void}\n * @decorator\n * @param routerOptions\n * @koa\n */\nexport function RouterSettings(routerOptions: RouterOptions): Function {\n return StoreMerge(ROUTER_OPTIONS, routerOptions);\n}\n"]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Strict = void 0;
|
|
4
|
-
const routerSettings_1 = require("./routerSettings");
|
|
5
|
-
/**
|
|
6
|
-
* Specify the behavior of the router controller.
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* @Controller("/")
|
|
10
|
-
* @Strict(true)
|
|
11
|
-
* class MyCtrl {
|
|
12
|
-
*
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* Property | Description | Default
|
|
17
|
-
* ---|---|---
|
|
18
|
-
* CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.
|
|
19
|
-
* MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false
|
|
20
|
-
* Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.
|
|
21
|
-
*
|
|
22
|
-
* @param strict
|
|
23
|
-
* @returns {Function}
|
|
24
|
-
* @decorator
|
|
25
|
-
* @koa
|
|
26
|
-
*/
|
|
27
|
-
function Strict(strict) {
|
|
28
|
-
return (0, routerSettings_1.RouterSettings)({ strict });
|
|
29
|
-
}
|
|
30
|
-
exports.Strict = Strict;
|
|
31
|
-
//# sourceMappingURL=strict.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../../src/decorators/strict.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,MAAM,CAAC,MAAe;IACpC,OAAO,IAAA,+BAAc,EAAC,EAAC,MAAM,EAAC,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC","sourcesContent":["import {RouterSettings} from \"./routerSettings\";\n\n/**\n * Specify the behavior of the router controller.\n *\n * ```typescript\n * @Controller(\"/\")\n * @Strict(true)\n * class MyCtrl {\n *\n * }\n * ```\n *\n * Property | Description | Default\n * ---|---|---\n * CaseSensitive | Enable case sensitivity. | Disabled by default, treating “/Foo” and “/foo” as the same.\n * MergeParams | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child’s value take precedence. | false\n * Strict | Enable strict routing. | Disabled by default, “/foo” and “/foo/” are treated the same by the router.\n *\n * @param strict\n * @returns {Function}\n * @decorator\n * @koa\n */\nexport function Strict(strict: boolean) {\n return RouterSettings({strict});\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAGA,qEAAsC","sourcesContent":["import Koa from \"koa\";\nimport {PlatformKoaSettings} from \"./PlatformKoaSettings\";\n\nexport * from \"./PlatformKoaSettings\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Koa platform application.\n */\n koa: PlatformKoaSettings;\n }\n\n export interface NextFunction extends Koa.Next {}\n }\n}\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resourceNotFoundMiddleware = void 0;
|
|
4
|
-
const common_1 = require("@tsed/common");
|
|
5
|
-
/**
|
|
6
|
-
* @ignore
|
|
7
|
-
* @param ctx
|
|
8
|
-
* @param next
|
|
9
|
-
*/
|
|
10
|
-
async function resourceNotFoundMiddleware(ctx, next) {
|
|
11
|
-
var _a;
|
|
12
|
-
const $ctx = ctx.request.$ctx;
|
|
13
|
-
await next();
|
|
14
|
-
const status = ctx.status || 404;
|
|
15
|
-
if (status === 404 && !$ctx.isDone()) {
|
|
16
|
-
(_a = $ctx.injector.get(common_1.PlatformExceptions)) === null || _a === void 0 ? void 0 : _a.resourceNotFound($ctx);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.resourceNotFoundMiddleware = resourceNotFoundMiddleware;
|
|
20
|
-
//# sourceMappingURL=resourceNotFoundMiddleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resourceNotFoundMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/resourceNotFoundMiddleware.ts"],"names":[],"mappings":";;;AAAA,yCAAiE;AAEjE;;;;GAIG;AACI,KAAK,UAAU,0BAA0B,CAAC,GAAQ,EAAE,IAAS;;IAClE,MAAM,IAAI,GAAoB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;IAC/C,MAAM,IAAI,EAAE,CAAC;IACb,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC;IAEjC,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;QACpC,MAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAqB,2BAAkB,CAAC,0CAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;KACnF;AACH,CAAC;AARD,gEAQC","sourcesContent":["import {PlatformContext, PlatformExceptions} from \"@tsed/common\";\n\n/**\n * @ignore\n * @param ctx\n * @param next\n */\nexport async function resourceNotFoundMiddleware(ctx: any, next: any) {\n const $ctx: PlatformContext = ctx.request.$ctx;\n await next();\n const status = ctx.status || 404;\n\n if (status === 404 && !$ctx.isDone()) {\n $ctx.injector.get<PlatformExceptions>(PlatformExceptions)?.resourceNotFound($ctx);\n }\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatformKoaApplication = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@tsed/common");
|
|
6
|
-
const koa_1 = (0, tslib_1.__importDefault)(require("koa"));
|
|
7
|
-
const PlatformKoaRouter_1 = require("./PlatformKoaRouter");
|
|
8
|
-
const koaQs = require("koa-qs");
|
|
9
|
-
/**
|
|
10
|
-
* @platform
|
|
11
|
-
* @express
|
|
12
|
-
*/
|
|
13
|
-
let PlatformKoaApplication = class PlatformKoaApplication extends PlatformKoaRouter_1.PlatformKoaRouter {
|
|
14
|
-
constructor(platformHandler, configuration) {
|
|
15
|
-
super(platformHandler, configuration, {});
|
|
16
|
-
this.rawApp = configuration.get("koa.app") || new koa_1.default();
|
|
17
|
-
koaQs(this.rawApp, "extended");
|
|
18
|
-
}
|
|
19
|
-
getApp() {
|
|
20
|
-
return this.rawApp;
|
|
21
|
-
}
|
|
22
|
-
callback() {
|
|
23
|
-
return this.getApp().callback();
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
PlatformKoaApplication = (0, tslib_1.__decorate)([
|
|
27
|
-
(0, tslib_1.__param)(0, (0, common_1.Inject)()),
|
|
28
|
-
(0, tslib_1.__param)(1, (0, common_1.Configuration)()),
|
|
29
|
-
(0, tslib_1.__metadata)("design:paramtypes", [common_1.PlatformHandler, Object])
|
|
30
|
-
], PlatformKoaApplication);
|
|
31
|
-
exports.PlatformKoaApplication = PlatformKoaApplication;
|
|
32
|
-
//# sourceMappingURL=PlatformKoaApplication.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformKoaApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaApplication.ts"],"names":[],"mappings":";;;;AACA,yCAAyF;AACzF,2DAAsB;AACtB,2DAAsD;AAEtD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAQhC;;;GAGG;AACH,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,qCAAiB;IAI3D,YAAsB,eAAgC,EAAmB,aAA4B;QACnG,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,aAAG,EAAE,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;CACF,CAAA;AAlBY,sBAAsB;IAIpB,wBAAA,IAAA,eAAM,GAAE,CAAA;IAAoC,wBAAA,IAAA,sBAAa,GAAE,CAAA;kDAAjC,wBAAe;GAJ3C,sBAAsB,CAkBlC;AAlBY,wDAAsB","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {Configuration, Inject, PlatformApplication, PlatformHandler} from \"@tsed/common\";\nimport Koa from \"koa\";\nimport {PlatformKoaRouter} from \"./PlatformKoaRouter\";\n\nconst koaQs = require(\"koa-qs\");\n\ndeclare global {\n namespace TsED {\n export interface Application extends Koa {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformKoaApplication extends PlatformKoaRouter implements PlatformApplication<Koa, KoaRouter> {\n app: Koa;\n rawApp: Koa;\n\n constructor(@Inject() platformHandler: PlatformHandler, @Configuration() configuration: Configuration) {\n super(platformHandler, configuration, {});\n\n this.rawApp = configuration.get(\"koa.app\") || new Koa();\n koaQs(this.rawApp, \"extended\");\n }\n\n getApp(): Koa {\n return this.rawApp;\n }\n\n callback(): any {\n return this.getApp().callback();\n }\n}\n"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatformKoaRouter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const router_1 = (0, tslib_1.__importDefault)(require("@koa/router"));
|
|
6
|
-
const common_1 = require("@tsed/common");
|
|
7
|
-
const di_1 = require("@tsed/di");
|
|
8
|
-
const staticsMiddleware_1 = require("../middlewares/staticsMiddleware");
|
|
9
|
-
const multer_1 = require("../utils/multer");
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
router_1.default.prototype.$$match = router_1.default.prototype.match;
|
|
12
|
-
router_1.default.prototype.match = function match(...args) {
|
|
13
|
-
const matched = this.$$match(...args);
|
|
14
|
-
if (matched) {
|
|
15
|
-
if (matched.path.length) {
|
|
16
|
-
matched.route = true;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return matched;
|
|
20
|
-
};
|
|
21
|
-
let PlatformKoaRouter = class PlatformKoaRouter extends common_1.PlatformRouter {
|
|
22
|
-
constructor(platform, configuration, routerOptions) {
|
|
23
|
-
var _a;
|
|
24
|
-
super(platform);
|
|
25
|
-
const options = Object.assign({}, ((_a = configuration.koa) === null || _a === void 0 ? void 0 : _a.router) || {}, routerOptions);
|
|
26
|
-
this.rawRouter = new router_1.default(options);
|
|
27
|
-
}
|
|
28
|
-
callback() {
|
|
29
|
-
return [this.getRouter().routes(), this.getRouter().allowedMethods()];
|
|
30
|
-
}
|
|
31
|
-
multer(options) {
|
|
32
|
-
return (0, multer_1.getMulter)(options);
|
|
33
|
-
}
|
|
34
|
-
statics(path, options) {
|
|
35
|
-
this.rawRouter.use(path, (0, staticsMiddleware_1.staticsMiddleware)(options));
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
PlatformKoaRouter = (0, tslib_1.__decorate)([
|
|
40
|
-
(0, tslib_1.__param)(1, (0, di_1.Configuration)()),
|
|
41
|
-
(0, tslib_1.__param)(2, (0, di_1.Inject)(common_1.PLATFORM_ROUTER_OPTIONS)),
|
|
42
|
-
(0, tslib_1.__metadata)("design:paramtypes", [common_1.PlatformHandler, Object, Object])
|
|
43
|
-
], PlatformKoaRouter);
|
|
44
|
-
exports.PlatformKoaRouter = PlatformKoaRouter;
|
|
45
|
-
//# sourceMappingURL=PlatformKoaRouter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformKoaRouter.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaRouter.ts"],"names":[],"mappings":";;;;AAAA,sEAAoC;AAGpC,yCAOsB;AACtB,iCAA+C;AAE/C,wEAAmE;AACnE,4CAA0C;AAY1C,aAAa;AACb,gBAAS,CAAC,SAAS,CAAC,OAAO,GAAG,gBAAS,CAAC,SAAS,CAAC,KAAK,CAAC;AACxD,gBAAS,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,KAAK,CAAC,GAAG,IAAW;IACvD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,EAAE;QACX,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE;YACvB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;SACtB;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,uBAAyB;IAC9D,YACE,QAAyB,EACR,aAA4B,EACZ,aAAkB;;QAEnD,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAA,MAAA,aAAa,CAAC,GAAG,0CAAE,MAAM,KAAI,EAAE,EAAE,aAAa,CAAC,CAAC;QAClF,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAS,CAAC,OAAO,CAAQ,CAAC;IACjD,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,OAA+B;QACpC,OAAO,IAAA,kBAAS,EAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,IAAY,EAAE,OAA+B;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAA,qCAAiB,EAAC,OAAO,CAAQ,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,iBAAiB;IAGzB,wBAAA,IAAA,kBAAa,GAAE,CAAA;IACf,wBAAA,IAAA,WAAM,EAAC,gCAAuB,CAAC,CAAA;kDAFtB,wBAAe;GAFhB,iBAAiB,CAyB7B;AAzBY,8CAAiB","sourcesContent":["import KoaRouter from \"@koa/router\";\nimport {RouterOptions as KoaRouterOptions} from \"@koa/router\";\n\nimport {\n PLATFORM_ROUTER_OPTIONS,\n PlatformHandler,\n PlatformMulter,\n PlatformMulterSettings,\n PlatformRouter,\n PlatformStaticsOptions\n} from \"@tsed/common\";\nimport {Configuration, Inject} from \"@tsed/di\";\nimport send from \"koa-send\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\nimport {getMulter} from \"../utils/multer\";\n\ndeclare global {\n namespace TsED {\n export interface Router extends KoaRouter {}\n\n export interface RouterOptions extends KoaRouterOptions {}\n\n export interface StaticsOptions extends send.SendOptions {}\n }\n}\n\n// @ts-ignore\nKoaRouter.prototype.$$match = KoaRouter.prototype.match;\nKoaRouter.prototype.match = function match(...args: any[]) {\n const matched = this.$$match(...args);\n if (matched) {\n if (matched.path.length) {\n matched.route = true;\n }\n }\n\n return matched;\n};\n\nexport class PlatformKoaRouter extends PlatformRouter<KoaRouter> {\n constructor(\n platform: PlatformHandler,\n @Configuration() configuration: Configuration,\n @Inject(PLATFORM_ROUTER_OPTIONS) routerOptions: any\n ) {\n super(platform);\n\n const options = Object.assign({}, configuration.koa?.router || {}, routerOptions);\n this.rawRouter = new KoaRouter(options) as any;\n }\n\n callback() {\n return [this.getRouter().routes(), this.getRouter().allowedMethods()];\n }\n\n multer(options: PlatformMulterSettings): PlatformMulter {\n return getMulter(options);\n }\n\n statics(path: string, options: PlatformStaticsOptions) {\n this.rawRouter.use(path, staticsMiddleware(options) as any);\n\n return this;\n }\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
(0, tslib_1.__exportStar)(require("./PlatformKoaApplication"), exports);
|
|
5
|
-
(0, tslib_1.__exportStar)(require("./PlatformKoaHandler"), exports);
|
|
6
|
-
(0, tslib_1.__exportStar)(require("./PlatformKoaRouter"), exports);
|
|
7
|
-
(0, tslib_1.__exportStar)(require("./PlatformKoaRequest"), exports);
|
|
8
|
-
(0, tslib_1.__exportStar)(require("./PlatformKoaResponse"), exports);
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,wEAAyC;AACzC,oEAAqC;AACrC,mEAAoC;AACpC,oEAAqC;AACrC,qEAAsC","sourcesContent":["export * from \"./PlatformKoaApplication\";\nexport * from \"./PlatformKoaHandler\";\nexport * from \"./PlatformKoaRouter\";\nexport * from \"./PlatformKoaRequest\";\nexport * from \"./PlatformKoaResponse\";\n"]}
|