@tsed/platform-koa 8.0.0-alpha.5 → 8.0.0-alpha.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/esm/services/PlatformKoaHandler.js.map +1 -1
- package/lib/types/services/PlatformKoaHandler.d.ts +1 -1
- package/lib/types/services/PlatformKoaRequest.d.ts +1 -1
- package/lib/types/services/PlatformKoaResponse.d.ts +2 -2
- package/package.json +15 -16
- package/lib/cjs/components/PlatformKoa.js +0 -168
- package/lib/cjs/components/PlatformKoa.js.map +0 -1
- package/lib/cjs/decorators/ctx.js +0 -32
- package/lib/cjs/decorators/ctx.js.map +0 -1
- package/lib/cjs/decorators/state.js +0 -9
- package/lib/cjs/decorators/state.js.map +0 -1
- package/lib/cjs/index.js +0 -17
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interfaces/PlatformKoaSettings.js +0 -3
- package/lib/cjs/interfaces/PlatformKoaSettings.js.map +0 -1
- package/lib/cjs/interfaces/interfaces.js +0 -5
- package/lib/cjs/interfaces/interfaces.js.map +0 -1
- package/lib/cjs/middlewares/staticsMiddleware.js +0 -35
- package/lib/cjs/middlewares/staticsMiddleware.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/services/PlatformKoaHandler.js +0 -21
- package/lib/cjs/services/PlatformKoaHandler.js.map +0 -1
- package/lib/cjs/services/PlatformKoaRequest.js +0 -34
- package/lib/cjs/services/PlatformKoaRequest.js.map +0 -1
- package/lib/cjs/services/PlatformKoaResponse.js +0 -96
- package/lib/cjs/services/PlatformKoaResponse.js.map +0 -1
- package/lib/cjs/utils/multer.js +0 -80
- package/lib/cjs/utils/multer.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/components/PlatformKoa.d.ts +0 -58
- package/lib/types-esm/decorators/ctx.d.ts +0 -19
- package/lib/types-esm/decorators/state.d.ts +0 -38
- package/lib/types-esm/index.d.ts +0 -13
- package/lib/types-esm/interfaces/PlatformKoaSettings.d.ts +0 -15
- package/lib/types-esm/interfaces/interfaces.d.ts +0 -15
- package/lib/types-esm/middlewares/staticsMiddleware.d.ts +0 -6
- package/lib/types-esm/services/PlatformKoaHandler.d.ts +0 -6
- package/lib/types-esm/services/PlatformKoaRequest.d.ts +0 -31
- package/lib/types-esm/services/PlatformKoaResponse.d.ts +0 -51
- package/lib/types-esm/utils/multer.d.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformKoaHandler.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAyB,MAAM,cAAc,CAAC;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"PlatformKoaHandler.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAyB,MAAM,cAAc,CAAC;AACtF,OAAO,yBAAyB,CAAC;AAEjC,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACrD,SAAS,CAAC,OAA+B,EAAE,IAAqB;QAC9D,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;YAClI,OAAO,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACvC;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,IAAqB;QAChC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE;YACrE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC;SACrC;QAED,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PlatformContext, PlatformHandler, PlatformParamsCallback } from "@tsed/common";
|
|
2
|
-
import "./PlatformKoaRequest";
|
|
2
|
+
import "./PlatformKoaRequest.js";
|
|
3
3
|
export declare class PlatformKoaHandler extends PlatformHandler {
|
|
4
4
|
onRequest(handler: PlatformParamsCallback, $ctx: PlatformContext): Promise<any>;
|
|
5
5
|
flush($ctx: PlatformContext): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { PlatformResponse } from "@tsed/common";
|
|
4
4
|
import { ServerResponse } from "http";
|
|
5
5
|
import Koa from "koa";
|
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-koa",
|
|
3
3
|
"description": "Koa package for Ts.ED framework",
|
|
4
|
-
"type": "
|
|
5
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "8.0.0-alpha.6",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
|
-
"main": "./lib/
|
|
7
|
+
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
9
9
|
"typings": "./lib/types/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./lib/types/index.d.ts",
|
|
13
13
|
"import": "./lib/esm/index.js",
|
|
14
|
-
"require": "./lib/cjs/index.js",
|
|
15
14
|
"default": "./lib/cjs/index.js"
|
|
16
15
|
}
|
|
17
16
|
},
|
|
@@ -54,12 +53,12 @@
|
|
|
54
53
|
"repository": "https://github.com/tsedio/tsed",
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"@koa/cors": "5.0.0",
|
|
57
|
-
"@tsed/barrels": "8.0.0-alpha.
|
|
58
|
-
"@tsed/common": "8.0.0-alpha.
|
|
59
|
-
"@tsed/core": "8.0.0-alpha.
|
|
60
|
-
"@tsed/di": "8.0.0-alpha.
|
|
61
|
-
"@tsed/platform-test-sdk": "8.0.0-alpha.
|
|
62
|
-
"@tsed/typescript": "8.0.0-alpha.
|
|
56
|
+
"@tsed/barrels": "8.0.0-alpha.6",
|
|
57
|
+
"@tsed/common": "8.0.0-alpha.6",
|
|
58
|
+
"@tsed/core": "8.0.0-alpha.6",
|
|
59
|
+
"@tsed/di": "8.0.0-alpha.6",
|
|
60
|
+
"@tsed/platform-test-sdk": "8.0.0-alpha.6",
|
|
61
|
+
"@tsed/typescript": "8.0.0-alpha.6",
|
|
63
62
|
"@types/koa": "2.15.0",
|
|
64
63
|
"@types/koa-bodyparser": "4.3.12",
|
|
65
64
|
"@types/koa-compose": "3.2.8",
|
|
@@ -88,13 +87,13 @@
|
|
|
88
87
|
"tslib": "2.6.1"
|
|
89
88
|
},
|
|
90
89
|
"peerDependencies": {
|
|
91
|
-
"@tsed/common": "8.0.0-alpha.
|
|
92
|
-
"@tsed/core": "8.0.0-alpha.
|
|
93
|
-
"@tsed/di": "8.0.0-alpha.
|
|
94
|
-
"@tsed/json-mapper": "8.0.0-alpha.
|
|
90
|
+
"@tsed/common": "8.0.0-alpha.6",
|
|
91
|
+
"@tsed/core": "8.0.0-alpha.6",
|
|
92
|
+
"@tsed/di": "8.0.0-alpha.6",
|
|
93
|
+
"@tsed/json-mapper": "8.0.0-alpha.6",
|
|
95
94
|
"@tsed/logger": ">=6.7.5",
|
|
96
|
-
"@tsed/openspec": "8.0.0-alpha.
|
|
97
|
-
"@tsed/schema": "8.0.0-alpha.
|
|
95
|
+
"@tsed/openspec": "8.0.0-alpha.6",
|
|
96
|
+
"@tsed/schema": "8.0.0-alpha.6",
|
|
98
97
|
"koa": ">=2.13.0",
|
|
99
98
|
"koa-bodyparser": ">=4.3.0",
|
|
100
99
|
"koa-compress": ">=5.0.1",
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var PlatformKoa_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.PlatformKoa = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const router_1 = tslib_1.__importDefault(require("@koa/router"));
|
|
7
|
-
const common_1 = require("@tsed/common");
|
|
8
|
-
const core_1 = require("@tsed/core");
|
|
9
|
-
const platform_exceptions_1 = require("@tsed/platform-exceptions");
|
|
10
|
-
const platform_router_1 = require("@tsed/platform-router");
|
|
11
|
-
const koa_1 = tslib_1.__importDefault(require("koa"));
|
|
12
|
-
const koa_bodyparser_1 = tslib_1.__importDefault(require("koa-bodyparser"));
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
const koa_qs_1 = tslib_1.__importDefault(require("koa-qs"));
|
|
15
|
-
const staticsMiddleware_js_1 = require("../middlewares/staticsMiddleware.js");
|
|
16
|
-
const PlatformKoaHandler_js_1 = require("../services/PlatformKoaHandler.js");
|
|
17
|
-
const PlatformKoaRequest_js_1 = require("../services/PlatformKoaRequest.js");
|
|
18
|
-
const PlatformKoaResponse_js_1 = require("../services/PlatformKoaResponse.js");
|
|
19
|
-
const multer_js_1 = require("../utils/multer.js");
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
router_1.default.prototype.$$match = router_1.default.prototype.match;
|
|
22
|
-
router_1.default.prototype.match = function match(...args) {
|
|
23
|
-
const matched = this.$$match(...args);
|
|
24
|
-
if (matched) {
|
|
25
|
-
if (matched.path.length) {
|
|
26
|
-
matched.route = true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return matched;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* @platform
|
|
33
|
-
* @koa
|
|
34
|
-
*/
|
|
35
|
-
let PlatformKoa = PlatformKoa_1 = class PlatformKoa extends common_1.PlatformAdapter {
|
|
36
|
-
constructor() {
|
|
37
|
-
super(...arguments);
|
|
38
|
-
this.providers = [
|
|
39
|
-
{
|
|
40
|
-
provide: common_1.PlatformResponse,
|
|
41
|
-
useClass: PlatformKoaResponse_js_1.PlatformKoaResponse
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
provide: common_1.PlatformRequest,
|
|
45
|
-
useClass: PlatformKoaRequest_js_1.PlatformKoaRequest
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
provide: common_1.PlatformHandler,
|
|
49
|
-
useClass: PlatformKoaHandler_js_1.PlatformKoaHandler
|
|
50
|
-
}
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
static { this.NAME = "koa"; }
|
|
54
|
-
/**
|
|
55
|
-
* Create new serverless application. In this mode, the component scan are disabled.
|
|
56
|
-
* @param module
|
|
57
|
-
* @param settings
|
|
58
|
-
*/
|
|
59
|
-
static create(module, settings = {}) {
|
|
60
|
-
return common_1.PlatformBuilder.create(module, {
|
|
61
|
-
...settings,
|
|
62
|
-
adapter: PlatformKoa_1
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Bootstrap a server application
|
|
67
|
-
* @param module
|
|
68
|
-
* @param settings
|
|
69
|
-
*/
|
|
70
|
-
static bootstrap(module, settings = {}) {
|
|
71
|
-
return common_1.PlatformBuilder.bootstrap(module, {
|
|
72
|
-
...settings,
|
|
73
|
-
adapter: PlatformKoa_1
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
onInit() {
|
|
77
|
-
this.app.getApp().silent = true;
|
|
78
|
-
}
|
|
79
|
-
mapLayers(layers) {
|
|
80
|
-
const { settings } = this.injector;
|
|
81
|
-
const { app } = this;
|
|
82
|
-
const options = settings.get("koa.router", {});
|
|
83
|
-
const rawRouter = new router_1.default(options);
|
|
84
|
-
layers.forEach((layer) => {
|
|
85
|
-
switch (layer.method) {
|
|
86
|
-
case "statics":
|
|
87
|
-
rawRouter.use(layer.path, this.statics(layer.path, layer.opts));
|
|
88
|
-
break;
|
|
89
|
-
default:
|
|
90
|
-
rawRouter[layer.method](...layer.getArgs());
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
app.getApp().use(rawRouter.routes()).use(rawRouter.allowedMethods());
|
|
94
|
-
}
|
|
95
|
-
mapHandler(handler, metadata) {
|
|
96
|
-
return async (koaContext, next) => {
|
|
97
|
-
const { $ctx } = koaContext.request;
|
|
98
|
-
$ctx.next = next;
|
|
99
|
-
const error = await (0, core_1.catchAsyncError)(() => handler($ctx));
|
|
100
|
-
if (error) {
|
|
101
|
-
$ctx.error = error;
|
|
102
|
-
}
|
|
103
|
-
if (metadata.type !== platform_router_1.PlatformHandlerType.RESPONSE_FN) {
|
|
104
|
-
return $ctx.next && $ctx.error ? $ctx.next($ctx.error) : $ctx.next();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
useContext() {
|
|
109
|
-
const { app } = this;
|
|
110
|
-
const invoke = (0, common_1.createContext)(this.injector);
|
|
111
|
-
const platformExceptions = this.injector.get(platform_exceptions_1.PlatformExceptions);
|
|
112
|
-
app.use((koaContext, next) => {
|
|
113
|
-
const $ctx = invoke({
|
|
114
|
-
request: koaContext.request,
|
|
115
|
-
response: koaContext.response,
|
|
116
|
-
koaContext
|
|
117
|
-
});
|
|
118
|
-
return (0, common_1.runInContext)($ctx, async () => {
|
|
119
|
-
try {
|
|
120
|
-
await $ctx.start();
|
|
121
|
-
await next();
|
|
122
|
-
const status = koaContext.status || 404;
|
|
123
|
-
if (status === 404 && !$ctx.isDone()) {
|
|
124
|
-
platformExceptions?.resourceNotFound($ctx);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
platformExceptions?.catch(error, $ctx);
|
|
129
|
-
}
|
|
130
|
-
finally {
|
|
131
|
-
await $ctx.finish();
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
return this;
|
|
136
|
-
}
|
|
137
|
-
createApp() {
|
|
138
|
-
const app = this.injector.settings.get("koa.app") || new koa_1.default();
|
|
139
|
-
(0, koa_qs_1.default)(app, "extended");
|
|
140
|
-
return {
|
|
141
|
-
app,
|
|
142
|
-
callback() {
|
|
143
|
-
return app.callback();
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
multipart(options) {
|
|
148
|
-
return (0, multer_js_1.getMulter)(options);
|
|
149
|
-
}
|
|
150
|
-
statics(endpoint, options) {
|
|
151
|
-
return (0, staticsMiddleware_js_1.staticsMiddleware)(options);
|
|
152
|
-
}
|
|
153
|
-
bodyParser(type, additionalOptions = {}) {
|
|
154
|
-
const opts = this.injector.settings.get(`koa.bodyParser`);
|
|
155
|
-
let parser = koa_bodyparser_1.default;
|
|
156
|
-
let options = {};
|
|
157
|
-
if ((0, core_1.isFunction)(opts)) {
|
|
158
|
-
parser = opts;
|
|
159
|
-
options = {};
|
|
160
|
-
}
|
|
161
|
-
return parser({ ...options, ...additionalOptions });
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
PlatformKoa = PlatformKoa_1 = tslib_1.__decorate([
|
|
165
|
-
(0, common_1.PlatformProvider)()
|
|
166
|
-
], PlatformKoa);
|
|
167
|
-
exports.PlatformKoa = PlatformKoa;
|
|
168
|
-
//# sourceMappingURL=PlatformKoa.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformKoa.js","sourceRoot":"","sources":["../../../src/components/PlatformKoa.ts"],"names":[],"mappings":";;;;;AAAA,iEAAoC;AACpC,yCAYsB;AACtB,qCAA6D;AAC7D,mEAA6D;AAC7D,2DAAkG;AAClG,sDAAuC;AACvC,4EAAsD;AACtD,aAAa;AACb,4DAA2B;AAE3B,8EAAsE;AACtE,6EAAqE;AACrE,6EAAqE;AACrE,+EAAuE;AACvE,kDAA6C;A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,CAAC;IAED,SAAS;QACP,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,aAAG,EAAE,CAAC;QAC/D,IAAA,gBAAK,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAEvB,OAAO;YACL,GAAG;YACH,QAAQ;gBACN,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;YACxB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,IAAA,qBAAS,EAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,IAAA,wCAAiB,EAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,UAAU,CAAC,IAA4C,EAAE,oBAAyB,EAAE;QAClF,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,MAAM,GAAQ,wBAAa,CAAC;QAEhC,IAAI,OAAO,GAAY,EAAE,CAAC;QAE1B,IAAI,IAAA,iBAAU,EAAC,IAAI,CAAC,EAAE;YACpB,MAAM,GAAG,IAAI,CAAC;YACd,OAAO,GAAG,EAAE,CAAC;SACd;QAED,OAAO,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,GAAG,iBAAiB,EAAC,CAAC,CAAC;IACpD,CAAC;;AApJU,WAAW;IADvB,IAAA,yBAAgB,GAAE;GACN,WAAW,CAqJvB;AArJY,kCAAW"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Ctx = exports.KoaCtx = void 0;
|
|
4
|
-
const common_1 = require("@tsed/common");
|
|
5
|
-
/**
|
|
6
|
-
* Return the original Koa context.
|
|
7
|
-
* @decorator
|
|
8
|
-
* @operation
|
|
9
|
-
* @input
|
|
10
|
-
* @koa
|
|
11
|
-
*/
|
|
12
|
-
function KoaCtx() {
|
|
13
|
-
return (0, common_1.UseParam)({
|
|
14
|
-
paramType: "KOA_CTX",
|
|
15
|
-
dataPath: "$ctx.request.ctx",
|
|
16
|
-
useMapper: false,
|
|
17
|
-
useValidation: false
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
exports.KoaCtx = KoaCtx;
|
|
21
|
-
/**
|
|
22
|
-
* Return the original Koa context.
|
|
23
|
-
* @decorator
|
|
24
|
-
* @operation
|
|
25
|
-
* @input
|
|
26
|
-
* @koa
|
|
27
|
-
*/
|
|
28
|
-
function Ctx() {
|
|
29
|
-
return KoaCtx();
|
|
30
|
-
}
|
|
31
|
-
exports.Ctx = Ctx;
|
|
32
|
-
//# sourceMappingURL=ctx.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ctx.js","sourceRoot":"","sources":["../../../src/decorators/ctx.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAGtC;;;;;;GAMG;AACH,SAAgB,MAAM;IACpB,OAAO,IAAA,iBAAQ,EAAC;QACd,SAAS,EAAE,SAAS;QACpB,QAAQ,EAAE,kBAAkB;QAC5B,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC;AAPD,wBAOC;AAED;;;;;;GAMG;AACH,SAAgB,GAAG;IACjB,OAAO,MAAM,EAAE,CAAC;AAClB,CAAC;AAFD,kBAEC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.State = void 0;
|
|
4
|
-
const common_1 = require("@tsed/common");
|
|
5
|
-
function State(...args) {
|
|
6
|
-
return common_1.Locals(...args);
|
|
7
|
-
}
|
|
8
|
-
exports.State = State;
|
|
9
|
-
//# sourceMappingURL=state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/decorators/state.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAwCpC,SAAgB,KAAK,CAAC,GAAG,IAAW;IAClC,OAAQ,eAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AAClC,CAAC;AAFD,sBAEC"}
|
package/lib/cjs/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
/**
|
|
5
|
-
* @file Automatically generated by @tsed/barrels.
|
|
6
|
-
*/
|
|
7
|
-
tslib_1.__exportStar(require("./components/PlatformKoa.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./decorators/ctx.js"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./decorators/state.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./interfaces/interfaces.js"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./interfaces/PlatformKoaSettings.js"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./middlewares/staticsMiddleware.js"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./services/PlatformKoaHandler.js"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./services/PlatformKoaRequest.js"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./services/PlatformKoaResponse.js"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./utils/multer.js"), exports);
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,sEAA4C;AAC5C,8DAAoC;AACpC,gEAAsC;AACtC,qEAA2C;AAC3C,8EAAoD;AACpD,6EAAmD;AACnD,2EAAiD;AACjD,2EAAiD;AACjD,4EAAkD;AAClD,4DAAkC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformKoaSettings.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformKoaSettings.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":";;;AAGA,mEAAyC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.staticsMiddleware = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const koa_send_1 = tslib_1.__importDefault(require("koa-send"));
|
|
6
|
-
/**
|
|
7
|
-
* @ignore
|
|
8
|
-
* @param options
|
|
9
|
-
*/
|
|
10
|
-
function staticsMiddleware(options) {
|
|
11
|
-
if (options.index !== false)
|
|
12
|
-
options.index = options.index || "index.html";
|
|
13
|
-
return async (ctx, next) => {
|
|
14
|
-
if (["GET", "HEAD"].includes(ctx.method) && !ctx.body) {
|
|
15
|
-
let path = ctx.path;
|
|
16
|
-
if (ctx._matchedRoute && ctx._matchedRoute !== "/") {
|
|
17
|
-
path = path.replace(String(ctx._matchedRoute).replace("/(.*)", ""), "");
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const done = await (0, koa_send_1.default)(ctx, path, options);
|
|
21
|
-
if (done) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
if (err.status !== 404) {
|
|
27
|
-
throw err;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return next();
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
exports.staticsMiddleware = staticsMiddleware;
|
|
35
|
-
//# sourceMappingURL=staticsMiddleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"staticsMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/staticsMiddleware.ts"],"names":[],"mappings":";;;;AAEA,gEAA4B;AAE5B;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,OAA+B;IAC/D,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK;QAAE,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC;IAE3E,OAAO,KAAK,EAAE,GAAY,EAAE,IAAS,EAAE,EAAE;QACvC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;YACrD,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;YAEpB,IAAI,GAAG,CAAC,aAAa,IAAI,GAAG,CAAC,aAAa,KAAK,GAAG,EAAE;gBAClD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;aACzE;YACD,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAA,kBAAI,EAAC,GAAU,EAAE,IAAI,EAAE,OAA2B,CAAC,CAAC;gBAEvE,IAAI,IAAI,EAAE;oBACR,OAAO;iBACR;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;oBACtB,MAAM,GAAG,CAAC;iBACX;aACF;SACF;QAED,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAzBD,8CAyBC"}
|
package/lib/cjs/package.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatformKoaHandler = void 0;
|
|
4
|
-
const common_1 = require("@tsed/common");
|
|
5
|
-
require("./PlatformKoaRequest");
|
|
6
|
-
class PlatformKoaHandler extends common_1.PlatformHandler {
|
|
7
|
-
onRequest(handler, $ctx) {
|
|
8
|
-
if (!(($ctx.error instanceof Error && !$ctx.handlerMetadata.hasErrorParam) || ($ctx.handlerMetadata.hasErrorParam && !$ctx.error))) {
|
|
9
|
-
return super.onRequest(handler, $ctx);
|
|
10
|
-
}
|
|
11
|
-
return Promise.resolve();
|
|
12
|
-
}
|
|
13
|
-
flush($ctx) {
|
|
14
|
-
if (!$ctx.error && $ctx.data === undefined && $ctx.getResponse().body) {
|
|
15
|
-
$ctx.data = $ctx.getResponse().body;
|
|
16
|
-
}
|
|
17
|
-
return super.flush($ctx);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.PlatformKoaHandler = PlatformKoaHandler;
|
|
21
|
-
//# sourceMappingURL=PlatformKoaHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformKoaHandler.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaHandler.ts"],"names":[],"mappings":";;;AAAA,yCAAsF;AACtF,gCAA8B;AAE9B,MAAa,kBAAmB,SAAQ,wBAAe;IACrD,SAAS,CAAC,OAA+B,EAAE,IAAqB;QAC9D,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;YAClI,OAAO,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACvC;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,IAAqB;QAChC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE;YACrE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC;SACrC;QAED,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;CACF;AAhBD,gDAgBC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatformKoaRequest = void 0;
|
|
4
|
-
require("@koa/router");
|
|
5
|
-
const common_1 = require("@tsed/common");
|
|
6
|
-
/**
|
|
7
|
-
* @platform
|
|
8
|
-
* @koa
|
|
9
|
-
*/
|
|
10
|
-
class PlatformKoaRequest extends common_1.PlatformRequest {
|
|
11
|
-
get ctx() {
|
|
12
|
-
return this.$ctx.event.koaContext;
|
|
13
|
-
}
|
|
14
|
-
get protocol() {
|
|
15
|
-
return this.ctx.request.protocol;
|
|
16
|
-
}
|
|
17
|
-
get host() {
|
|
18
|
-
return this.ctx.request.host;
|
|
19
|
-
}
|
|
20
|
-
get secure() {
|
|
21
|
-
return this.ctx.request.secure;
|
|
22
|
-
}
|
|
23
|
-
get cookies() {
|
|
24
|
-
return this.ctx.cookie || this.ctx.cookies;
|
|
25
|
-
}
|
|
26
|
-
get session() {
|
|
27
|
-
return this.ctx.session;
|
|
28
|
-
}
|
|
29
|
-
getReq() {
|
|
30
|
-
return this.ctx.request.req;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.PlatformKoaRequest = PlatformKoaRequest;
|
|
34
|
-
//# sourceMappingURL=PlatformKoaRequest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformKoaRequest.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaRequest.ts"],"names":[],"mappings":";;;AAAA,uBAAqB;AACrB,yCAA8D;AAgB9D;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,wBAA4B;IAClE,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAyB,CAAC;IACnD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;IAC7C,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;IAC9B,CAAC;CACF;AA5BD,gDA4BC"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatformKoaResponse = void 0;
|
|
4
|
-
const common_1 = require("@tsed/common");
|
|
5
|
-
/**
|
|
6
|
-
* @platform
|
|
7
|
-
* @koa
|
|
8
|
-
*/
|
|
9
|
-
class PlatformKoaResponse extends common_1.PlatformResponse {
|
|
10
|
-
get ctx() {
|
|
11
|
-
return this.raw.ctx;
|
|
12
|
-
}
|
|
13
|
-
get statusCode() {
|
|
14
|
-
return this.raw.status;
|
|
15
|
-
}
|
|
16
|
-
get locals() {
|
|
17
|
-
return this.ctx.state;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Return the Node.js response object
|
|
21
|
-
*/
|
|
22
|
-
getRes() {
|
|
23
|
-
return this.raw.res;
|
|
24
|
-
}
|
|
25
|
-
hasStatus() {
|
|
26
|
-
// KOA set 404 by default
|
|
27
|
-
return this.statusCode !== 404;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Sets the HTTP status for the response.
|
|
31
|
-
*
|
|
32
|
-
* @param status
|
|
33
|
-
*/
|
|
34
|
-
status(status) {
|
|
35
|
-
this.raw.status = status;
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Set `Content-Type` response header with `type` through `mime.lookup()`
|
|
40
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
41
|
-
*
|
|
42
|
-
* Examples:
|
|
43
|
-
*
|
|
44
|
-
* res.type('.html');
|
|
45
|
-
* res.type('html');
|
|
46
|
-
* res.type('json');
|
|
47
|
-
* res.type('application/json');
|
|
48
|
-
* res.type('png');
|
|
49
|
-
*/
|
|
50
|
-
contentType(contentType) {
|
|
51
|
-
this.raw.type = contentType;
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
getHeaders() {
|
|
55
|
-
return this.raw.headers;
|
|
56
|
-
}
|
|
57
|
-
stream(data) {
|
|
58
|
-
this.raw.body = data;
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
getBody() {
|
|
62
|
-
return this.raw.body;
|
|
63
|
-
}
|
|
64
|
-
cookie(name, value, opts) {
|
|
65
|
-
if (value === null) {
|
|
66
|
-
this.ctx.cookies.set(name);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
this.ctx.cookies.set(name, value, opts);
|
|
70
|
-
}
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
json(data) {
|
|
74
|
-
this.end(data);
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
buffer(data) {
|
|
78
|
-
this.end(data);
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
end(data) {
|
|
82
|
-
if ([301, 302, 303, 307, 308].includes(this.statusCode)) {
|
|
83
|
-
if (this.request.method === "HEAD") {
|
|
84
|
-
this.getRes().end();
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
this.getRes().end(data);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
this.raw.body = data;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.PlatformKoaResponse = PlatformKoaResponse;
|
|
96
|
-
//# sourceMappingURL=PlatformKoaResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformKoaResponse.js","sourceRoot":"","sources":["../../../src/services/PlatformKoaResponse.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAU9C;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,yBAA8B;IACrE,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,SAAS;QACP,yBAAyB;QACzB,OAAO,IAAI,CAAC,UAAU,KAAK,GAAG,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAc;QACnB,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QAEzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,WAAmB;QAC7B,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,WAAW,CAAC;QAE5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,IAAS;QACd,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,IAAY,EAAE,KAAoB,EAAE,IAAyB;QAClE,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SAC5B;aAAM;YACL,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACzC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAES,IAAI,CAAC,IAAS;QACtB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAES,MAAM,CAAC,IAAY;QAC3B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAES,GAAG,CAAC,IAAsB;QAClC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YACvD,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE;gBAClC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;aACrB;iBAAM;gBACL,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aACzB;SACF;aAAM;YACL,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;SACtB;IACH,CAAC;CACF;AAjGD,kDAiGC"}
|
package/lib/cjs/utils/multer.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getMulter = void 0;
|
|
27
|
-
const util_1 = require("util");
|
|
28
|
-
let multer;
|
|
29
|
-
Promise.resolve().then(() => __importStar(require("multer"))).then(({ default: m }) => (multer = m));
|
|
30
|
-
/**
|
|
31
|
-
* @ignore
|
|
32
|
-
*/
|
|
33
|
-
function createRawMiddleware(middleware) {
|
|
34
|
-
return async (request) => {
|
|
35
|
-
const ctx = request.ctx;
|
|
36
|
-
await middleware(ctx.req, ctx.res);
|
|
37
|
-
const forwardKey = (key) => {
|
|
38
|
-
if (ctx.req[key]) {
|
|
39
|
-
ctx.request[key] = ctx.req[key];
|
|
40
|
-
ctx[key] = ctx.req[key];
|
|
41
|
-
delete ctx.req[key];
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
if ("request" in ctx) {
|
|
45
|
-
if (ctx.req.body) {
|
|
46
|
-
ctx.request.body = ctx.req.body;
|
|
47
|
-
delete ctx.req.body;
|
|
48
|
-
}
|
|
49
|
-
forwardKey("file");
|
|
50
|
-
forwardKey("files");
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* @ignore
|
|
56
|
-
*/
|
|
57
|
-
function makePromise(multer, name) {
|
|
58
|
-
// istanbul ignore next
|
|
59
|
-
if (!multer[name])
|
|
60
|
-
return;
|
|
61
|
-
const fn = multer[name];
|
|
62
|
-
multer[name] = function apply(...args) {
|
|
63
|
-
const middleware = Reflect.apply(fn, this, args);
|
|
64
|
-
return createRawMiddleware((0, util_1.promisify)(middleware));
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* @ignore
|
|
69
|
-
*/
|
|
70
|
-
function getMulter(options) {
|
|
71
|
-
const m = multer(options);
|
|
72
|
-
makePromise(m, "any");
|
|
73
|
-
makePromise(m, "array");
|
|
74
|
-
makePromise(m, "fields");
|
|
75
|
-
makePromise(m, "none");
|
|
76
|
-
makePromise(m, "single");
|
|
77
|
-
return m;
|
|
78
|
-
}
|
|
79
|
-
exports.getMulter = getMulter;
|
|
80
|
-
//# sourceMappingURL=multer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multer.js","sourceRoot":"","sources":["../../../src/utils/multer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+BAA+B;AAE/B,IAAI,MAAW,CAAC;AAChB,kDAAO,QAAQ,IAAE,IAAI,CAAC,CAAC,EAAC,OAAO,EAAE,CAAC,EAAC,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAEtD;;GAEG;AACH,SAAS,mBAAmB,CAAC,UAAe;IAC1C,OAAO,KAAK,EAAE,OAAoB,EAAE,EAAE;QACp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,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,OAAY;IACpC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAE1B,WAAW,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACtB,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACxB,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzB,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACvB,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAEzB,OAAO,CAAC,CAAC;AACX,CAAC;AAVD,8BAUC"}
|
package/lib/esm/package.json
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { PlatformAdapter, PlatformBuilder, PlatformHandler, PlatformMulter, PlatformMulterSettings, PlatformRequest, PlatformResponse, PlatformStaticsOptions } from "@tsed/common";
|
|
2
|
-
import { Type } from "@tsed/core";
|
|
3
|
-
import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
|
|
4
|
-
import Koa, { Context, Next } from "koa";
|
|
5
|
-
import send from "koa-send";
|
|
6
|
-
import { PlatformKoaHandler } from "../services/PlatformKoaHandler.js";
|
|
7
|
-
import { PlatformKoaRequest } from "../services/PlatformKoaRequest.js";
|
|
8
|
-
import { PlatformKoaResponse } from "../services/PlatformKoaResponse.js";
|
|
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
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* @platform
|
|
21
|
-
* @koa
|
|
22
|
-
*/
|
|
23
|
-
export declare class PlatformKoa extends PlatformAdapter<Koa> {
|
|
24
|
-
static readonly NAME = "koa";
|
|
25
|
-
readonly providers: ({
|
|
26
|
-
provide: typeof PlatformResponse;
|
|
27
|
-
useClass: typeof PlatformKoaResponse;
|
|
28
|
-
} | {
|
|
29
|
-
provide: typeof PlatformRequest;
|
|
30
|
-
useClass: typeof PlatformKoaRequest;
|
|
31
|
-
} | {
|
|
32
|
-
provide: typeof PlatformHandler;
|
|
33
|
-
useClass: typeof PlatformKoaHandler;
|
|
34
|
-
})[];
|
|
35
|
-
/**
|
|
36
|
-
* Create new serverless application. In this mode, the component scan are disabled.
|
|
37
|
-
* @param module
|
|
38
|
-
* @param settings
|
|
39
|
-
*/
|
|
40
|
-
static create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>>;
|
|
41
|
-
/**
|
|
42
|
-
* Bootstrap a server application
|
|
43
|
-
* @param module
|
|
44
|
-
* @param settings
|
|
45
|
-
*/
|
|
46
|
-
static bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder<Koa<Koa.DefaultState, Koa.DefaultContext>>>;
|
|
47
|
-
onInit(): void;
|
|
48
|
-
mapLayers(layers: PlatformLayer[]): void;
|
|
49
|
-
mapHandler(handler: Function, metadata: PlatformHandlerMetadata): (koaContext: Koa.Context, next: Koa.Next) => Promise<any>;
|
|
50
|
-
useContext(): this;
|
|
51
|
-
createApp(): {
|
|
52
|
-
app: any;
|
|
53
|
-
callback(): any;
|
|
54
|
-
};
|
|
55
|
-
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
56
|
-
statics(endpoint: string, options: PlatformStaticsOptions): any;
|
|
57
|
-
bodyParser(type: "json" | "urlencoded" | "raw" | "text", additionalOptions?: any): any;
|
|
58
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Context } from "koa";
|
|
2
|
-
/**
|
|
3
|
-
* Return the original Koa context.
|
|
4
|
-
* @decorator
|
|
5
|
-
* @operation
|
|
6
|
-
* @input
|
|
7
|
-
* @koa
|
|
8
|
-
*/
|
|
9
|
-
export declare function KoaCtx(): ParameterDecorator;
|
|
10
|
-
/**
|
|
11
|
-
* Return the original Koa context.
|
|
12
|
-
* @decorator
|
|
13
|
-
* @operation
|
|
14
|
-
* @input
|
|
15
|
-
* @koa
|
|
16
|
-
*/
|
|
17
|
-
export declare function Ctx(): ParameterDecorator;
|
|
18
|
-
export type Ctx = Context;
|
|
19
|
-
export type KoaCtx = Context;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* State return the value from koa.ctx.state object.
|
|
3
|
-
*
|
|
4
|
-
* #### Example
|
|
5
|
-
*
|
|
6
|
-
* ```typescript
|
|
7
|
-
* * @Middleware()
|
|
8
|
-
* class StateMiddleware {
|
|
9
|
-
* use(@State() state: any) {
|
|
10
|
-
* // set some on locals
|
|
11
|
-
* state.user = "user"
|
|
12
|
-
* }
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* @Controller('/')
|
|
16
|
-
* @UseBefore(StateMiddleware)
|
|
17
|
-
* class MyCtrl {
|
|
18
|
-
* @Get('/')
|
|
19
|
-
* @View('home.ejs') // will use locals and returned data to render the page
|
|
20
|
-
* get(@State('user') user: any) {
|
|
21
|
-
* console.log('user', user);
|
|
22
|
-
*
|
|
23
|
-
* return {
|
|
24
|
-
* description: 'Hello world'
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @param expression The path of the property to get.
|
|
31
|
-
* @decorator
|
|
32
|
-
* @operation
|
|
33
|
-
* @input
|
|
34
|
-
* @response
|
|
35
|
-
* @koa
|
|
36
|
-
*/
|
|
37
|
-
export declare function State(expression: string): ParameterDecorator;
|
|
38
|
-
export declare function State(): ParameterDecorator;
|
package/lib/types-esm/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Automatically generated by @tsed/barrels.
|
|
3
|
-
*/
|
|
4
|
-
export * from "./components/PlatformKoa.js";
|
|
5
|
-
export * from "./decorators/ctx.js";
|
|
6
|
-
export * from "./decorators/state.js";
|
|
7
|
-
export * from "./interfaces/interfaces.js";
|
|
8
|
-
export * from "./interfaces/PlatformKoaSettings.js";
|
|
9
|
-
export * from "./middlewares/staticsMiddleware.js";
|
|
10
|
-
export * from "./services/PlatformKoaHandler.js";
|
|
11
|
-
export * from "./services/PlatformKoaRequest.js";
|
|
12
|
-
export * from "./services/PlatformKoaResponse.js";
|
|
13
|
-
export * from "./utils/multer.js";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="koa__router" />
|
|
2
|
-
import type { RouterOptions } from "@koa/router";
|
|
3
|
-
import type { Middleware } from "koa";
|
|
4
|
-
import type { Options } from "koa-bodyparser";
|
|
5
|
-
export interface PlatformKoaSettings {
|
|
6
|
-
/**
|
|
7
|
-
* Koa router options
|
|
8
|
-
*/
|
|
9
|
-
router?: RouterOptions;
|
|
10
|
-
/**
|
|
11
|
-
* Body parser options
|
|
12
|
-
* @param opts
|
|
13
|
-
*/
|
|
14
|
-
bodyParser?: ((opts?: Options) => Middleware) | Options;
|
|
15
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import Koa from "koa";
|
|
2
|
-
import { PlatformKoaSettings } from "./PlatformKoaSettings.js";
|
|
3
|
-
export * from "./PlatformKoaSettings.js";
|
|
4
|
-
declare global {
|
|
5
|
-
namespace TsED {
|
|
6
|
-
interface Configuration {
|
|
7
|
-
/**
|
|
8
|
-
* Configuration related to Koa platform application.
|
|
9
|
-
*/
|
|
10
|
-
koa: PlatformKoaSettings;
|
|
11
|
-
}
|
|
12
|
-
interface NextFunction extends Koa.Next {
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { PlatformContext, PlatformHandler, PlatformParamsCallback } from "@tsed/common";
|
|
2
|
-
import "./PlatformKoaRequest";
|
|
3
|
-
export declare class PlatformKoaHandler extends PlatformHandler {
|
|
4
|
-
onRequest(handler: PlatformParamsCallback, $ctx: PlatformContext): Promise<any>;
|
|
5
|
-
flush($ctx: PlatformContext): Promise<void>;
|
|
6
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import "@koa/router";
|
|
3
|
-
import { PlatformContext, PlatformRequest } from "@tsed/common";
|
|
4
|
-
import Koa from "koa";
|
|
5
|
-
declare module "koa" {
|
|
6
|
-
interface Request {
|
|
7
|
-
id: string;
|
|
8
|
-
$ctx: PlatformContext;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
declare global {
|
|
12
|
-
namespace TsED {
|
|
13
|
-
interface Request extends Koa.Request {
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @platform
|
|
19
|
-
* @koa
|
|
20
|
-
*/
|
|
21
|
-
export declare class PlatformKoaRequest extends PlatformRequest<Koa.Request> {
|
|
22
|
-
get ctx(): Koa.Context;
|
|
23
|
-
get protocol(): string;
|
|
24
|
-
get host(): string;
|
|
25
|
-
get secure(): boolean;
|
|
26
|
-
get cookies(): {
|
|
27
|
-
[p: string]: any;
|
|
28
|
-
};
|
|
29
|
-
get session(): any;
|
|
30
|
-
getReq(): import("http").IncomingMessage;
|
|
31
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { PlatformResponse } from "@tsed/common";
|
|
4
|
-
import { ServerResponse } from "http";
|
|
5
|
-
import Koa from "koa";
|
|
6
|
-
declare global {
|
|
7
|
-
namespace TsED {
|
|
8
|
-
interface Response extends Koa.Response {
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @platform
|
|
14
|
-
* @koa
|
|
15
|
-
*/
|
|
16
|
-
export declare class PlatformKoaResponse extends PlatformResponse<Koa.Response> {
|
|
17
|
-
get ctx(): Koa.Context;
|
|
18
|
-
get statusCode(): number;
|
|
19
|
-
get locals(): Koa.DefaultState;
|
|
20
|
-
/**
|
|
21
|
-
* Return the Node.js response object
|
|
22
|
-
*/
|
|
23
|
-
getRes(): ServerResponse;
|
|
24
|
-
hasStatus(): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Sets the HTTP status for the response.
|
|
27
|
-
*
|
|
28
|
-
* @param status
|
|
29
|
-
*/
|
|
30
|
-
status(status: number): this;
|
|
31
|
-
/**
|
|
32
|
-
* Set `Content-Type` response header with `type` through `mime.lookup()`
|
|
33
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
34
|
-
*
|
|
35
|
-
* Examples:
|
|
36
|
-
*
|
|
37
|
-
* res.type('.html');
|
|
38
|
-
* res.type('html');
|
|
39
|
-
* res.type('json');
|
|
40
|
-
* res.type('application/json');
|
|
41
|
-
* res.type('png');
|
|
42
|
-
*/
|
|
43
|
-
contentType(contentType: string): this;
|
|
44
|
-
getHeaders(): import("http").OutgoingHttpHeaders;
|
|
45
|
-
stream(data: any): this;
|
|
46
|
-
getBody(): any;
|
|
47
|
-
cookie(name: string, value: string | null, opts?: TsED.SetCookieOpts): this;
|
|
48
|
-
protected json(data: any): this;
|
|
49
|
-
protected buffer(data: Buffer): this;
|
|
50
|
-
protected end(data?: string | Buffer): void;
|
|
51
|
-
}
|