@tsed/platform-express 7.0.0-beta.3 → 7.0.0-beta.6
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/components/PlatformExpress.js +102 -43
- package/lib/cjs/components/PlatformExpress.js.map +1 -1
- package/lib/cjs/exports.js +7 -0
- package/lib/cjs/exports.js.map +1 -0
- package/lib/cjs/index.js +16 -12
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/PlatformExpressSettings.js.map +1 -1
- package/lib/cjs/interfaces/interfaces.js +3 -0
- 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/PlatformExpressRequest.js.map +1 -1
- package/lib/esm/components/PlatformExpress.js +100 -22
- package/lib/esm/components/PlatformExpress.js.map +1 -1
- package/lib/esm/decorators/caseSensitive.js +1 -1
- package/lib/esm/decorators/mergeParams.js +1 -1
- package/lib/esm/decorators/strict.js +1 -1
- package/lib/esm/exports.js +5 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +16 -12
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/PlatformExpressSettings.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/PlatformExpressRequest.js.map +1 -1
- package/lib/types/components/PlatformExpress.d.ts +41 -8
- package/lib/types/exports.d.ts +1 -0
- package/lib/types/index.d.ts +15 -3
- package/lib/types/interfaces/PlatformExpressSettings.d.ts +15 -1
- package/lib/types/interfaces/{index.d.ts → interfaces.d.ts} +0 -2
- package/lib/types/services/PlatformExpressRequest.d.ts +1 -15
- package/package.json +52 -22
- package/readme.md +0 -2
- package/tsconfig.compile.esm.json +1 -12
- package/lib/cjs/decorators/index.js +0 -8
- package/lib/cjs/decorators/index.js.map +0 -1
- package/lib/cjs/interfaces/index.js +0 -6
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/cjs/middlewares/rawBodyMiddleware.js +0 -27
- package/lib/cjs/middlewares/rawBodyMiddleware.js.map +0 -1
- package/lib/cjs/services/PlatformExpressApplication.js +0 -32
- package/lib/cjs/services/PlatformExpressApplication.js.map +0 -1
- package/lib/cjs/services/PlatformExpressRouter.js +0 -34
- package/lib/cjs/services/PlatformExpressRouter.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/index.js +0 -5
- package/lib/esm/decorators/index.js.map +0 -1
- package/lib/esm/interfaces/index.js +0 -3
- package/lib/esm/interfaces/index.js.map +0 -1
- package/lib/esm/middlewares/rawBodyMiddleware.js +0 -22
- package/lib/esm/middlewares/rawBodyMiddleware.js.map +0 -1
- package/lib/esm/services/PlatformExpressApplication.js +0 -29
- package/lib/esm/services/PlatformExpressApplication.js.map +0 -1
- package/lib/esm/services/PlatformExpressRouter.js +0 -31
- package/lib/esm/services/PlatformExpressRouter.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/index.d.ts +0 -4
- package/lib/types/middlewares/rawBodyMiddleware.d.ts +0 -4
- package/lib/types/services/PlatformExpressApplication.d.ts +0 -24
- package/lib/types/services/PlatformExpressRouter.d.ts +0 -18
- package/lib/types/services/index.d.ts +0 -5
package/lib/esm/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export * from "./
|
|
7
|
-
|
|
8
|
-
export * from "./decorators";
|
|
9
|
-
|
|
10
|
-
export * from "./
|
|
11
|
-
|
|
12
|
-
export * from "./
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./exports.js";
|
|
5
|
+
export * from "./components/PlatformExpress.js";
|
|
6
|
+
export * from "./decorators/caseSensitive.js";
|
|
7
|
+
export * from "./decorators/mergeParams.js";
|
|
8
|
+
export * from "./decorators/routerSettings.js";
|
|
9
|
+
export * from "./decorators/strict.js";
|
|
10
|
+
export * from "./interfaces/PlatformExpressSettings.js";
|
|
11
|
+
export * from "./interfaces/PlatformExpressStaticsOptions.js";
|
|
12
|
+
export * from "./interfaces/interfaces.js";
|
|
13
|
+
export * from "./middlewares/staticsMiddleware.js";
|
|
14
|
+
export * from "./services/PlatformExpressHandler.js";
|
|
15
|
+
export * from "./services/PlatformExpressRequest.js";
|
|
16
|
+
export * from "./services/PlatformExpressResponse.js";
|
|
13
17
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./components/PlatformExpress\";\nexport * from \"./decorators/caseSensitive\";\nexport * from \"./decorators/mergeParams\";\nexport * from \"./decorators/routerSettings\";\nexport * from \"./decorators/strict\";\nexport * from \"./interfaces/PlatformExpressSettings\";\nexport * from \"./interfaces/PlatformExpressStaticsOptions\";\nexport * from \"./interfaces/interfaces\";\nexport * from \"./middlewares/staticsMiddleware\";\nexport * from \"./services/PlatformExpressHandler\";\nexport * from \"./services/PlatformExpressRequest\";\nexport * from \"./services/PlatformExpressResponse\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpressSettings.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformExpressSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {RouterOptions} from \"express\";\n\nexport interface PlatformExpressSettings {\n /**\n * Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).\n */\n router?: RouterOptions;\n\n app?: Express.Application;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PlatformExpressSettings.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformExpressSettings.ts"],"names":[],"mappings":"","sourcesContent":["import type {RouterOptions} from \"express\";\nimport type {OptionsJson, OptionsText, Options, OptionsUrlencoded} from \"body-parser\";\nimport type {NextHandleFunction} from \"connect\";\n\nexport interface PlatformExpressSettings {\n /**\n * Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).\n */\n router?: RouterOptions;\n /**\n * Express application\n */\n app?: Express.Application;\n\n /**\n * body parser configuration\n */\n bodyParser?: {\n json?: (opts?: OptionsJson) => NextHandleFunction | OptionsJson;\n text?: (opts?: OptionsText) => NextHandleFunction | OptionsText;\n raw?: (opts?: Options) => NextHandleFunction | Options;\n urlencoded?: (opts?: OptionsUrlencoded) => NextHandleFunction | OptionsUrlencoded;\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import Express from \"express\";\nimport {PlatformExpressSettings} from \"./PlatformExpressSettings\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Express platform application.\n */\n express: PlatformExpressSettings;\n }\n\n export interface NextFunction extends Express.NextFunction {}\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpressRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"PlatformExpressRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAC,MAAM,cAAc,CAAC;AAG9D;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,eAAgC;CAAG","sourcesContent":["import {PlatformContext, PlatformRequest} from \"@tsed/common\";\nimport type Express from \"express\";\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressRequest extends PlatformRequest<Express.Request> {}\n"]}
|
|
@@ -1,17 +1,38 @@
|
|
|
1
|
-
import Express from "express";
|
|
2
|
-
import { PlatformAdapter, PlatformBuilder, PlatformHandler, PlatformRequest, PlatformResponse,
|
|
1
|
+
import Express, { RouterOptions } from "express";
|
|
2
|
+
import { InjectorService, PlatformAdapter, PlatformBuilder, PlatformContext, PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformRequest, PlatformResponse, PlatformStaticsOptions } from "@tsed/common";
|
|
3
3
|
import { Type } from "@tsed/core";
|
|
4
|
-
import { PlatformExpressHandler
|
|
4
|
+
import { PlatformExpressHandler } from "../services/PlatformExpressHandler";
|
|
5
|
+
import { PlatformExpressResponse } from "../services/PlatformExpressResponse";
|
|
6
|
+
import { PlatformExpressRequest } from "../services/PlatformExpressRequest";
|
|
7
|
+
import { PlatformExpressStaticsOptions } from "../interfaces/PlatformExpressStaticsOptions";
|
|
8
|
+
declare module "express" {
|
|
9
|
+
interface Request {
|
|
10
|
+
id: string;
|
|
11
|
+
$ctx: PlatformContext;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
declare global {
|
|
15
|
+
namespace TsED {
|
|
16
|
+
interface Router extends Express.Router {
|
|
17
|
+
}
|
|
18
|
+
interface Application extends Express.Application {
|
|
19
|
+
}
|
|
20
|
+
interface StaticsOptions extends PlatformExpressStaticsOptions {
|
|
21
|
+
}
|
|
22
|
+
interface Request extends Express.Request {
|
|
23
|
+
id: string;
|
|
24
|
+
$ctx: PlatformContext;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
5
28
|
/**
|
|
6
29
|
* @platform
|
|
7
30
|
* @express
|
|
8
31
|
*/
|
|
9
32
|
export declare class PlatformExpress implements PlatformAdapter<Express.Application, Express.Router> {
|
|
10
|
-
private
|
|
33
|
+
#private;
|
|
34
|
+
protected injector: InjectorService;
|
|
11
35
|
readonly providers: ({
|
|
12
|
-
provide: typeof PlatformRouter;
|
|
13
|
-
useClass: typeof PlatformExpressRouter;
|
|
14
|
-
} | {
|
|
15
36
|
provide: typeof PlatformHandler;
|
|
16
37
|
useClass: typeof PlatformExpressHandler;
|
|
17
38
|
} | {
|
|
@@ -21,7 +42,7 @@ export declare class PlatformExpress implements PlatformAdapter<Express.Applicat
|
|
|
21
42
|
provide: typeof PlatformRequest;
|
|
22
43
|
useClass: typeof PlatformExpressRequest;
|
|
23
44
|
})[];
|
|
24
|
-
constructor(
|
|
45
|
+
constructor(injector: InjectorService);
|
|
25
46
|
/**
|
|
26
47
|
* Create new serverless application. In this mode, the component scan are disabled.
|
|
27
48
|
* @param module
|
|
@@ -34,9 +55,21 @@ export declare class PlatformExpress implements PlatformAdapter<Express.Applicat
|
|
|
34
55
|
* @param settings
|
|
35
56
|
*/
|
|
36
57
|
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Express.Application, Express.Router>>;
|
|
58
|
+
onInit(): void;
|
|
37
59
|
useRouter(): this;
|
|
38
60
|
beforeLoadRoutes(): Promise<void>;
|
|
39
61
|
afterLoadRoutes(): Promise<void>;
|
|
40
62
|
useContext(): this;
|
|
63
|
+
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
64
|
+
app(): {
|
|
65
|
+
app: any;
|
|
66
|
+
callback(): any;
|
|
67
|
+
};
|
|
68
|
+
router(routerOptions?: Partial<RouterOptions>): {
|
|
69
|
+
router: import("express-serve-static-core").Router;
|
|
70
|
+
callback(): import("express-serve-static-core").Router;
|
|
71
|
+
};
|
|
72
|
+
statics(endpoint: string, options: PlatformStaticsOptions): (request: any, response: any, next: any) => void;
|
|
73
|
+
bodyParser(type: "json" | "raw" | "text" | "urlencoded", additionalOptions?: any): any;
|
|
41
74
|
private configureViewsEngine;
|
|
42
75
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./exports";
|
|
4
5
|
export * from "./components/PlatformExpress";
|
|
6
|
+
export * from "./decorators/caseSensitive";
|
|
7
|
+
export * from "./decorators/mergeParams";
|
|
8
|
+
export * from "./decorators/routerSettings";
|
|
9
|
+
export * from "./decorators/strict";
|
|
10
|
+
export * from "./interfaces/PlatformExpressSettings";
|
|
11
|
+
export * from "./interfaces/PlatformExpressStaticsOptions";
|
|
12
|
+
export * from "./interfaces/interfaces";
|
|
13
|
+
export * from "./middlewares/staticsMiddleware";
|
|
14
|
+
export * from "./services/PlatformExpressHandler";
|
|
15
|
+
export * from "./services/PlatformExpressRequest";
|
|
16
|
+
export * from "./services/PlatformExpressResponse";
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
/// <reference types="express-serve-static-core" />
|
|
2
|
-
import { RouterOptions } from "express";
|
|
2
|
+
import type { RouterOptions } from "express";
|
|
3
|
+
import type { OptionsJson, OptionsText, Options, OptionsUrlencoded } from "body-parser";
|
|
4
|
+
import type { NextHandleFunction } from "connect";
|
|
3
5
|
export interface PlatformExpressSettings {
|
|
4
6
|
/**
|
|
5
7
|
* Global configuration for the Express.Router. See express [documentation](http://expressjs.com/en/api.html#express.router).
|
|
6
8
|
*/
|
|
7
9
|
router?: RouterOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Express application
|
|
12
|
+
*/
|
|
8
13
|
app?: Express.Application;
|
|
14
|
+
/**
|
|
15
|
+
* body parser configuration
|
|
16
|
+
*/
|
|
17
|
+
bodyParser?: {
|
|
18
|
+
json?: (opts?: OptionsJson) => NextHandleFunction | OptionsJson;
|
|
19
|
+
text?: (opts?: OptionsText) => NextHandleFunction | OptionsText;
|
|
20
|
+
raw?: (opts?: Options) => NextHandleFunction | Options;
|
|
21
|
+
urlencoded?: (opts?: OptionsUrlencoded) => NextHandleFunction | OptionsUrlencoded;
|
|
22
|
+
};
|
|
9
23
|
}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlatformRequest } from "@tsed/common";
|
|
2
2
|
import type Express from "express";
|
|
3
|
-
declare module "express" {
|
|
4
|
-
interface Request {
|
|
5
|
-
id: string;
|
|
6
|
-
$ctx: PlatformContext;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
declare global {
|
|
10
|
-
namespace TsED {
|
|
11
|
-
interface Request extends Express.Request {
|
|
12
|
-
id: string;
|
|
13
|
-
$ctx: PlatformContext;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
3
|
/**
|
|
18
4
|
* @platform
|
|
19
5
|
* @express
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-express",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.6",
|
|
4
4
|
"description": "A TypeScript Framework on top of Express",
|
|
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,9 +14,10 @@
|
|
|
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",
|
|
20
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
19
21
|
"start": "ts-node -r tsconfig-paths/register test/app/index.ts",
|
|
20
22
|
"start:emulate": "ts-node -r tsconfig-paths/register test/app/emulate.ts"
|
|
21
23
|
},
|
|
@@ -46,41 +48,69 @@
|
|
|
46
48
|
"bugs": {
|
|
47
49
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
48
50
|
},
|
|
49
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
51
|
+
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/platform/platform-express",
|
|
50
52
|
"repository": "https://github.com/tsedio/tsed",
|
|
51
53
|
"dependencies": {
|
|
52
54
|
"express": "^4.17.1",
|
|
53
55
|
"multer": "^1.4.2",
|
|
54
|
-
"tslib": "2.
|
|
56
|
+
"tslib": "2.3.1"
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
|
-
"@tsed/common": "7.0.0-beta.
|
|
58
|
-
"@tsed/core": "7.0.0-beta.
|
|
59
|
-
"@tsed/di": "7.0.0-beta.
|
|
60
|
-
"@tsed/platform-test-utils": "7.0.0-beta.
|
|
61
|
-
"@
|
|
62
|
-
"@types/
|
|
59
|
+
"@tsed/common": "7.0.0-beta.6",
|
|
60
|
+
"@tsed/core": "7.0.0-beta.6",
|
|
61
|
+
"@tsed/di": "7.0.0-beta.6",
|
|
62
|
+
"@tsed/platform-test-utils": "7.0.0-beta.6",
|
|
63
|
+
"@tsed/platform-views": "7.0.0-beta.6",
|
|
64
|
+
"@types/body-parser": "1.19.2",
|
|
65
|
+
"@types/compression": "1.7.2",
|
|
63
66
|
"@types/cookie-parser": "1.4.2",
|
|
64
67
|
"@types/express": "^4.17.7",
|
|
65
|
-
"@types/express-session": "1.17.
|
|
66
|
-
"@types/method-override": "0.0.
|
|
68
|
+
"@types/express-session": "1.17.4",
|
|
69
|
+
"@types/method-override": "0.0.32",
|
|
67
70
|
"@types/multer": "^1.4.3",
|
|
68
|
-
"body-parser": "1.19.
|
|
71
|
+
"body-parser": "1.19.2",
|
|
69
72
|
"compression": "1.7.4",
|
|
70
|
-
"cookie-parser": "1.4.
|
|
73
|
+
"cookie-parser": "1.4.6",
|
|
71
74
|
"cors": "2.8.5",
|
|
72
|
-
"express-session": "1.17.
|
|
75
|
+
"express-session": "1.17.2",
|
|
73
76
|
"method-override": "3.0.0"
|
|
74
77
|
},
|
|
75
78
|
"peerDependencies": {
|
|
76
|
-
"@tsed/common": "^7.0.0-beta.
|
|
77
|
-
"@tsed/core": "^7.0.0-beta.
|
|
78
|
-
"@tsed/di": "^7.0.0-beta.
|
|
79
|
-
"@tsed/json-mapper": "^7.0.0-beta.
|
|
80
|
-
"@tsed/logger": ">=6.
|
|
81
|
-
"@tsed/openspec": "^7.0.0-beta.
|
|
82
|
-
"@tsed/
|
|
79
|
+
"@tsed/common": "^7.0.0-beta.6",
|
|
80
|
+
"@tsed/core": "^7.0.0-beta.6",
|
|
81
|
+
"@tsed/di": "^7.0.0-beta.6",
|
|
82
|
+
"@tsed/json-mapper": "^7.0.0-beta.6",
|
|
83
|
+
"@tsed/logger": ">=6.1.1",
|
|
84
|
+
"@tsed/openspec": "^7.0.0-beta.6",
|
|
85
|
+
"@tsed/platform-views": "^7.0.0-beta.6",
|
|
86
|
+
"@tsed/schema": "^7.0.0-beta.6",
|
|
83
87
|
"@types/multer": "^1.4.5",
|
|
84
88
|
"body-parser": "1.19.0"
|
|
89
|
+
},
|
|
90
|
+
"peerDependenciesMeta": {
|
|
91
|
+
"@tsed/common": {
|
|
92
|
+
"optional": false
|
|
93
|
+
},
|
|
94
|
+
"@tsed/core": {
|
|
95
|
+
"optional": false
|
|
96
|
+
},
|
|
97
|
+
"@tsed/di": {
|
|
98
|
+
"optional": false
|
|
99
|
+
},
|
|
100
|
+
"@tsed/json-mapper": {
|
|
101
|
+
"optional": false
|
|
102
|
+
},
|
|
103
|
+
"@tsed/openspec": {
|
|
104
|
+
"optional": false
|
|
105
|
+
},
|
|
106
|
+
"@tsed/platform-views": {
|
|
107
|
+
"optional": true
|
|
108
|
+
},
|
|
109
|
+
"@tsed/schema": {
|
|
110
|
+
"optional": false
|
|
111
|
+
},
|
|
112
|
+
"@tsed/logger": {
|
|
113
|
+
"optional": false
|
|
114
|
+
}
|
|
85
115
|
}
|
|
86
116
|
}
|
package/readme.md
CHANGED
|
@@ -44,14 +44,12 @@ Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
|
|
|
44
44
|
|
|
45
45
|
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
46
46
|
|
|
47
|
-
|
|
48
47
|
## Backers
|
|
49
48
|
|
|
50
49
|
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
|
|
51
50
|
|
|
52
51
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
|
|
53
52
|
|
|
54
|
-
|
|
55
53
|
## Sponsors
|
|
56
54
|
|
|
57
55
|
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)]
|
|
@@ -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,8 +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("./mergeParams"), exports);
|
|
7
|
-
(0, tslib_1.__exportStar)(require("./strict"), exports);
|
|
8
|
-
//# 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,6DAA8B;AAC9B,wDAAyB","sourcesContent":["export * from \"./routerSettings\";\nexport * from \"./caseSensitive\";\nexport * from \"./mergeParams\";\nexport * from \"./strict\";\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
(0, tslib_1.__exportStar)(require("./PlatformExpressSettings"), exports);
|
|
5
|
-
(0, tslib_1.__exportStar)(require("./PlatformExpressStaticsOptions"), exports);
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAGA,yEAA0C;AAC1C,+EAAgD","sourcesContent":["import Express from \"express\";\nimport {PlatformExpressSettings} from \"./PlatformExpressSettings\";\n\nexport * from \"./PlatformExpressSettings\";\nexport * from \"./PlatformExpressStaticsOptions\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Express platform application.\n */\n express: PlatformExpressSettings;\n }\n\n export interface NextFunction extends Express.NextFunction {}\n }\n}\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rawBodyMiddleware = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const bytes_1 = (0, tslib_1.__importDefault)(require("bytes"));
|
|
6
|
-
const limit = bytes_1.default.parse("100kb");
|
|
7
|
-
function isLimitReached(length) {
|
|
8
|
-
return limit !== null && length !== null && length > limit;
|
|
9
|
-
}
|
|
10
|
-
function getContentLength(request) {
|
|
11
|
-
const contentLength = request.get("content-length");
|
|
12
|
-
return contentLength != null && !isNaN(contentLength) ? parseInt(contentLength, 10) : null;
|
|
13
|
-
}
|
|
14
|
-
function rawBodyMiddleware(request, response, next) {
|
|
15
|
-
if (request.method !== "GET") {
|
|
16
|
-
const length = getContentLength(request);
|
|
17
|
-
if (!isLimitReached(length) && request.is(["application/x-www-form-urlencoded", "application/json"])) {
|
|
18
|
-
request.rawBody = "";
|
|
19
|
-
request.on("data", (chunk) => {
|
|
20
|
-
request.rawBody += chunk;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
next();
|
|
25
|
-
}
|
|
26
|
-
exports.rawBodyMiddleware = rawBodyMiddleware;
|
|
27
|
-
//# sourceMappingURL=rawBodyMiddleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rawBodyMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/rawBodyMiddleware.ts"],"names":[],"mappings":";;;;AACA,+DAA0B;AAE1B,MAAM,KAAK,GAAG,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAEnC,SAAS,cAAc,CAAC,MAAqB;IAC3C,OAAO,KAAK,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,GAAG,KAAK,CAAC;AAC7D,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAoC;IAC5D,MAAM,aAAa,GAAQ,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACzD,OAAO,aAAa,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7F,CAAC;AAED,SAAgB,iBAAiB,CAAC,OAAoC,EAAE,QAAa,EAAE,IAAS;IAC9F,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE;QAC5B,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC,mCAAmC,EAAE,kBAAkB,CAAC,CAAC,EAAE;YACpG,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;YACrB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;gBACnC,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;YAC3B,CAAC,CAAC,CAAC;SACJ;KACF;IAED,IAAI,EAAE,CAAC;AACT,CAAC;AAbD,8CAaC","sourcesContent":["import {Request} from \"express\";\nimport bytes from \"bytes\";\n\nconst limit = bytes.parse(\"100kb\");\n\nfunction isLimitReached(length: number | null) {\n return limit !== null && length !== null && length > limit;\n}\n\nfunction getContentLength(request: Request & {rawBody: string}) {\n const contentLength: any = request.get(\"content-length\");\n return contentLength != null && !isNaN(contentLength) ? parseInt(contentLength, 10) : null;\n}\n\nexport function rawBodyMiddleware(request: Request & {rawBody: string}, response: any, next: any) {\n if (request.method !== \"GET\") {\n const length = getContentLength(request);\n\n if (!isLimitReached(length) && request.is([\"application/x-www-form-urlencoded\", \"application/json\"])) {\n request.rawBody = \"\";\n request.on(\"data\", (chunk: string) => {\n request.rawBody += chunk;\n });\n }\n }\n\n next();\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatformExpressApplication = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@tsed/common");
|
|
6
|
-
const express_1 = (0, tslib_1.__importDefault)(require("express"));
|
|
7
|
-
const PlatformExpressRouter_1 = require("./PlatformExpressRouter");
|
|
8
|
-
/**
|
|
9
|
-
* @platform
|
|
10
|
-
* @express
|
|
11
|
-
*/
|
|
12
|
-
let PlatformExpressApplication = class PlatformExpressApplication extends PlatformExpressRouter_1.PlatformExpressRouter {
|
|
13
|
-
constructor(platformHandler, configuration) {
|
|
14
|
-
super(platformHandler, configuration, {
|
|
15
|
-
mergeParams: true
|
|
16
|
-
});
|
|
17
|
-
this.rawApp = configuration.get("express.app") || (0, express_1.default)();
|
|
18
|
-
}
|
|
19
|
-
getApp() {
|
|
20
|
-
return this.rawApp;
|
|
21
|
-
}
|
|
22
|
-
callback() {
|
|
23
|
-
return this.rawApp;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
PlatformExpressApplication = (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
|
-
], PlatformExpressApplication);
|
|
31
|
-
exports.PlatformExpressApplication = PlatformExpressApplication;
|
|
32
|
-
//# sourceMappingURL=PlatformExpressApplication.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpressApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressApplication.ts"],"names":[],"mappings":";;;;AAAA,yCAAwG;AACxG,mEAA8B;AAE9B,mEAA8D;AAU9D;;;GAGG;AACH,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,6CAAqB;IAKnE,YAAsB,eAAgC,EAAmB,aAA4B;QACnG,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE;YACpC,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAA,iBAAO,GAAE,CAAC;IAC9D,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF,CAAA;AApBY,0BAA0B;IAKxB,wBAAA,IAAA,eAAM,GAAE,CAAA;IAAoC,wBAAA,IAAA,sBAAa,GAAE,CAAA;kDAAjC,wBAAe;GAL3C,0BAA0B,CAoBtC;AApBY,gEAA0B","sourcesContent":["import {Configuration, createContext, Inject, PlatformApplication, PlatformHandler} from \"@tsed/common\";\nimport Express from \"express\";\nimport {PlatformExpressStaticsOptions} from \"../interfaces/PlatformExpressStaticsOptions\";\nimport {PlatformExpressRouter} from \"./PlatformExpressRouter\";\n\ndeclare global {\n namespace TsED {\n export interface Application extends Express.Application {}\n\n export interface StaticsOptions extends PlatformExpressStaticsOptions {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressApplication extends PlatformExpressRouter implements PlatformApplication<Express.Application, Express.Router> {\n app: Express.Application;\n rawApp: Express.Application;\n rawRouter: Express.Router;\n\n constructor(@Inject() platformHandler: PlatformHandler, @Configuration() configuration: Configuration) {\n super(platformHandler, configuration, {\n mergeParams: true\n });\n\n this.rawApp = configuration.get(\"express.app\") || Express();\n }\n\n getApp() {\n return this.rawApp;\n }\n\n callback() {\n return this.rawApp;\n }\n}\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatformExpressRouter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@tsed/common");
|
|
6
|
-
const di_1 = require("@tsed/di");
|
|
7
|
-
const express_1 = (0, tslib_1.__importDefault)(require("express"));
|
|
8
|
-
const staticsMiddleware_1 = require("../middlewares/staticsMiddleware");
|
|
9
|
-
/**
|
|
10
|
-
* @platform
|
|
11
|
-
* @express
|
|
12
|
-
*/
|
|
13
|
-
let PlatformExpressRouter = class PlatformExpressRouter extends common_1.PlatformRouter {
|
|
14
|
-
constructor(platform, configuration, routerOptions = {}) {
|
|
15
|
-
var _a;
|
|
16
|
-
super(platform);
|
|
17
|
-
const options = Object.assign({
|
|
18
|
-
mergeParams: true
|
|
19
|
-
}, ((_a = configuration.express) === null || _a === void 0 ? void 0 : _a.router) || {}, routerOptions);
|
|
20
|
-
this.rawRouter = this.raw = express_1.default.Router(options);
|
|
21
|
-
}
|
|
22
|
-
statics(endpoint, options) {
|
|
23
|
-
const { root, ...props } = options;
|
|
24
|
-
this.use(endpoint, (0, staticsMiddleware_1.staticsMiddleware)(root, props));
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
PlatformExpressRouter = (0, tslib_1.__decorate)([
|
|
29
|
-
(0, tslib_1.__param)(1, (0, di_1.Configuration)()),
|
|
30
|
-
(0, tslib_1.__param)(2, (0, di_1.Inject)(common_1.PLATFORM_ROUTER_OPTIONS)),
|
|
31
|
-
(0, tslib_1.__metadata)("design:paramtypes", [common_1.PlatformHandler, Object, Object])
|
|
32
|
-
], PlatformExpressRouter);
|
|
33
|
-
exports.PlatformExpressRouter = PlatformExpressRouter;
|
|
34
|
-
//# sourceMappingURL=PlatformExpressRouter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpressRouter.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressRouter.ts"],"names":[],"mappings":";;;;AAAA,yCAA8G;AAC9G,iCAA+C;AAC/C,mEAA8B;AAE9B,wEAAmE;AAQnE;;;GAGG;AACH,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,uBAA8B;IACvE,YACE,QAAyB,EACR,aAA4B,EACZ,gBAAwC,EAAE;;QAE3E,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAC3B;YACE,WAAW,EAAE,IAAI;SAClB,EACD,CAAA,MAAA,aAAa,CAAC,OAAO,0CAAE,MAAM,KAAI,EAAE,EACnC,aAAa,CACd,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,GAAG,iBAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,MAAM,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,GAAG,OAAO,CAAC;QAEjC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAA,qCAAiB,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzBY,qBAAqB;IAG7B,wBAAA,IAAA,kBAAa,GAAE,CAAA;IACf,wBAAA,IAAA,WAAM,EAAC,gCAAuB,CAAC,CAAA;kDAFtB,wBAAe;GAFhB,qBAAqB,CAyBjC;AAzBY,sDAAqB","sourcesContent":["import {PLATFORM_ROUTER_OPTIONS, PlatformHandler, PlatformRouter, PlatformStaticsOptions} from \"@tsed/common\";\nimport {Configuration, Inject} from \"@tsed/di\";\nimport Express from \"express\";\nimport {RouterOptions} from \"express\";\nimport {staticsMiddleware} from \"../middlewares/staticsMiddleware\";\n\ndeclare global {\n namespace TsED {\n export interface Router extends Express.Router {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressRouter extends PlatformRouter<Express.Router> {\n constructor(\n platform: PlatformHandler,\n @Configuration() configuration: Configuration,\n @Inject(PLATFORM_ROUTER_OPTIONS) routerOptions: Partial<RouterOptions> = {}\n ) {\n super(platform);\n\n const options = Object.assign(\n {\n mergeParams: true\n },\n configuration.express?.router || {},\n routerOptions\n );\n this.rawRouter = this.raw = Express.Router(options);\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions) {\n const {root, ...props} = options;\n\n this.use(endpoint, staticsMiddleware(root, props));\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("./PlatformExpressApplication"), exports);
|
|
5
|
-
(0, tslib_1.__exportStar)(require("./PlatformExpressHandler"), exports);
|
|
6
|
-
(0, tslib_1.__exportStar)(require("./PlatformExpressResponse"), exports);
|
|
7
|
-
(0, tslib_1.__exportStar)(require("./PlatformExpressRequest"), exports);
|
|
8
|
-
(0, tslib_1.__exportStar)(require("./PlatformExpressRouter"), exports);
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,4EAA6C;AAC7C,wEAAyC;AACzC,yEAA0C;AAC1C,wEAAyC;AACzC,uEAAwC","sourcesContent":["export * from \"./PlatformExpressApplication\";\nexport * from \"./PlatformExpressHandler\";\nexport * from \"./PlatformExpressResponse\";\nexport * from \"./PlatformExpressRequest\";\nexport * from \"./PlatformExpressRouter\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC","sourcesContent":["export * from \"./routerSettings\";\nexport * from \"./caseSensitive\";\nexport * from \"./mergeParams\";\nexport * from \"./strict\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAGA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC","sourcesContent":["import Express from \"express\";\nimport {PlatformExpressSettings} from \"./PlatformExpressSettings\";\n\nexport * from \"./PlatformExpressSettings\";\nexport * from \"./PlatformExpressStaticsOptions\";\n\ndeclare global {\n namespace TsED {\n export interface Configuration {\n /**\n * Configuration related to Express platform application.\n */\n express: PlatformExpressSettings;\n }\n\n export interface NextFunction extends Express.NextFunction {}\n }\n}\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import bytes from "bytes";
|
|
2
|
-
const limit = bytes.parse("100kb");
|
|
3
|
-
function isLimitReached(length) {
|
|
4
|
-
return limit !== null && length !== null && length > limit;
|
|
5
|
-
}
|
|
6
|
-
function getContentLength(request) {
|
|
7
|
-
const contentLength = request.get("content-length");
|
|
8
|
-
return contentLength != null && !isNaN(contentLength) ? parseInt(contentLength, 10) : null;
|
|
9
|
-
}
|
|
10
|
-
export function rawBodyMiddleware(request, response, next) {
|
|
11
|
-
if (request.method !== "GET") {
|
|
12
|
-
const length = getContentLength(request);
|
|
13
|
-
if (!isLimitReached(length) && request.is(["application/x-www-form-urlencoded", "application/json"])) {
|
|
14
|
-
request.rawBody = "";
|
|
15
|
-
request.on("data", (chunk) => {
|
|
16
|
-
request.rawBody += chunk;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
next();
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=rawBodyMiddleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rawBodyMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/rawBodyMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAEnC,SAAS,cAAc,CAAC,MAAqB;IAC3C,OAAO,KAAK,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,GAAG,KAAK,CAAC;AAC7D,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAoC;IAC5D,MAAM,aAAa,GAAQ,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACzD,OAAO,aAAa,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAoC,EAAE,QAAa,EAAE,IAAS;IAC9F,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE;QAC5B,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC,mCAAmC,EAAE,kBAAkB,CAAC,CAAC,EAAE;YACpG,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;YACrB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;gBACnC,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;YAC3B,CAAC,CAAC,CAAC;SACJ;KACF;IAED,IAAI,EAAE,CAAC;AACT,CAAC","sourcesContent":["import {Request} from \"express\";\nimport bytes from \"bytes\";\n\nconst limit = bytes.parse(\"100kb\");\n\nfunction isLimitReached(length: number | null) {\n return limit !== null && length !== null && length > limit;\n}\n\nfunction getContentLength(request: Request & {rawBody: string}) {\n const contentLength: any = request.get(\"content-length\");\n return contentLength != null && !isNaN(contentLength) ? parseInt(contentLength, 10) : null;\n}\n\nexport function rawBodyMiddleware(request: Request & {rawBody: string}, response: any, next: any) {\n if (request.method !== \"GET\") {\n const length = getContentLength(request);\n\n if (!isLimitReached(length) && request.is([\"application/x-www-form-urlencoded\", \"application/json\"])) {\n request.rawBody = \"\";\n request.on(\"data\", (chunk: string) => {\n request.rawBody += chunk;\n });\n }\n }\n\n next();\n}\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
-
import { Configuration, Inject, PlatformHandler } from "@tsed/common";
|
|
3
|
-
import Express from "express";
|
|
4
|
-
import { PlatformExpressRouter } from "./PlatformExpressRouter";
|
|
5
|
-
/**
|
|
6
|
-
* @platform
|
|
7
|
-
* @express
|
|
8
|
-
*/
|
|
9
|
-
let PlatformExpressApplication = class PlatformExpressApplication extends PlatformExpressRouter {
|
|
10
|
-
constructor(platformHandler, configuration) {
|
|
11
|
-
super(platformHandler, configuration, {
|
|
12
|
-
mergeParams: true
|
|
13
|
-
});
|
|
14
|
-
this.rawApp = configuration.get("express.app") || Express();
|
|
15
|
-
}
|
|
16
|
-
getApp() {
|
|
17
|
-
return this.rawApp;
|
|
18
|
-
}
|
|
19
|
-
callback() {
|
|
20
|
-
return this.rawApp;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
PlatformExpressApplication = __decorate([
|
|
24
|
-
__param(0, Inject()),
|
|
25
|
-
__param(1, Configuration()),
|
|
26
|
-
__metadata("design:paramtypes", [PlatformHandler, Object])
|
|
27
|
-
], PlatformExpressApplication);
|
|
28
|
-
export { PlatformExpressApplication };
|
|
29
|
-
//# sourceMappingURL=PlatformExpressApplication.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformExpressApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformExpressApplication.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAiB,MAAM,EAAuB,eAAe,EAAC,MAAM,cAAc,CAAC;AACxG,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAU9D;;;GAGG;AACH,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,qBAAqB;IAKnE,YAAsB,eAAgC,EAAmB,aAA4B;QACnG,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE;YACpC,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,EAAE,CAAC;IAC9D,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF,CAAA;AApBY,0BAA0B;IAKxB,WAAA,MAAM,EAAE,CAAA;IAAoC,WAAA,aAAa,EAAE,CAAA;qCAAjC,eAAe;GAL3C,0BAA0B,CAoBtC;SApBY,0BAA0B","sourcesContent":["import {Configuration, createContext, Inject, PlatformApplication, PlatformHandler} from \"@tsed/common\";\nimport Express from \"express\";\nimport {PlatformExpressStaticsOptions} from \"../interfaces/PlatformExpressStaticsOptions\";\nimport {PlatformExpressRouter} from \"./PlatformExpressRouter\";\n\ndeclare global {\n namespace TsED {\n export interface Application extends Express.Application {}\n\n export interface StaticsOptions extends PlatformExpressStaticsOptions {}\n }\n}\n\n/**\n * @platform\n * @express\n */\nexport class PlatformExpressApplication extends PlatformExpressRouter implements PlatformApplication<Express.Application, Express.Router> {\n app: Express.Application;\n rawApp: Express.Application;\n rawRouter: Express.Router;\n\n constructor(@Inject() platformHandler: PlatformHandler, @Configuration() configuration: Configuration) {\n super(platformHandler, configuration, {\n mergeParams: true\n });\n\n this.rawApp = configuration.get(\"express.app\") || Express();\n }\n\n getApp() {\n return this.rawApp;\n }\n\n callback() {\n return this.rawApp;\n }\n}\n"]}
|