@midwayjs/faas 3.5.2 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configuration.d.ts +1 -1
- package/dist/configuration.js +9 -10
- package/dist/framework.d.ts +1 -1
- package/dist/framework.js +16 -8
- package/package.json +8 -9
package/dist/configuration.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MidwayFaaSFramework } from './framework';
|
|
2
1
|
import { MidwayDecoratorService } from '@midwayjs/core';
|
|
2
|
+
import { MidwayFaaSFramework } from './framework';
|
|
3
3
|
export declare class FaaSConfiguration {
|
|
4
4
|
framework: MidwayFaaSFramework;
|
|
5
5
|
decoratorService: MidwayDecoratorService;
|
package/dist/configuration.js
CHANGED
|
@@ -10,23 +10,22 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.FaaSConfiguration = void 0;
|
|
13
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
14
|
-
const framework_1 = require("./framework");
|
|
15
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
+
const framework_1 = require("./framework");
|
|
16
15
|
const DefaultConfig = require("./config.default");
|
|
17
16
|
let FaaSConfiguration = class FaaSConfiguration {
|
|
18
17
|
async init() {
|
|
19
|
-
this.decoratorService.registerPropertyHandler(
|
|
18
|
+
this.decoratorService.registerPropertyHandler(core_1.PLUGIN_KEY, (key, meta, target) => {
|
|
20
19
|
var _a;
|
|
21
20
|
return (((_a = target === null || target === void 0 ? void 0 : target[core_1.REQUEST_OBJ_CTX_KEY]) === null || _a === void 0 ? void 0 : _a[key]) ||
|
|
22
21
|
this.framework.getApplication()[key]);
|
|
23
22
|
});
|
|
24
|
-
this.decoratorService.registerPropertyHandler(
|
|
23
|
+
this.decoratorService.registerPropertyHandler(core_1.LOGGER_KEY, (key, meta, target) => {
|
|
25
24
|
var _a;
|
|
26
25
|
return (((_a = target === null || target === void 0 ? void 0 : target[core_1.REQUEST_OBJ_CTX_KEY]) === null || _a === void 0 ? void 0 : _a['logger']) ||
|
|
27
26
|
this.framework.getLogger());
|
|
28
27
|
});
|
|
29
|
-
this.decoratorService.registerParameterHandler(
|
|
28
|
+
this.decoratorService.registerParameterHandler(core_1.WEB_ROUTER_PARAM_KEY, options => {
|
|
30
29
|
return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData, options.originParamType)(options.originArgs[0], options.originArgs[1]);
|
|
31
30
|
});
|
|
32
31
|
}
|
|
@@ -40,25 +39,25 @@ let FaaSConfiguration = class FaaSConfiguration {
|
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
41
|
__decorate([
|
|
43
|
-
(0,
|
|
42
|
+
(0, core_1.Inject)(),
|
|
44
43
|
__metadata("design:type", framework_1.MidwayFaaSFramework)
|
|
45
44
|
], FaaSConfiguration.prototype, "framework", void 0);
|
|
46
45
|
__decorate([
|
|
47
|
-
(0,
|
|
46
|
+
(0, core_1.Inject)(),
|
|
48
47
|
__metadata("design:type", core_1.MidwayDecoratorService)
|
|
49
48
|
], FaaSConfiguration.prototype, "decoratorService", void 0);
|
|
50
49
|
__decorate([
|
|
51
|
-
(0,
|
|
50
|
+
(0, core_1.ApplicationContext)(),
|
|
52
51
|
__metadata("design:type", Object)
|
|
53
52
|
], FaaSConfiguration.prototype, "applicationContext", void 0);
|
|
54
53
|
__decorate([
|
|
55
|
-
(0,
|
|
54
|
+
(0, core_1.Init)(),
|
|
56
55
|
__metadata("design:type", Function),
|
|
57
56
|
__metadata("design:paramtypes", []),
|
|
58
57
|
__metadata("design:returntype", Promise)
|
|
59
58
|
], FaaSConfiguration.prototype, "init", null);
|
|
60
59
|
FaaSConfiguration = __decorate([
|
|
61
|
-
(0,
|
|
60
|
+
(0, core_1.Configuration)({
|
|
62
61
|
namespace: 'faas',
|
|
63
62
|
importConfigs: [
|
|
64
63
|
{
|
package/dist/framework.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare class MidwayFaaSFramework extends BaseFramework<Application, Cont
|
|
|
44
44
|
protected getFunctionHandler(ctx: any, args: any, target: any, method: any): string;
|
|
45
45
|
createLogger(name: string, option?: LoggerOptions): import("@midwayjs/core").ILogger;
|
|
46
46
|
getFrameworkName(): string;
|
|
47
|
-
getServer(): http.Server
|
|
47
|
+
getServer(): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
48
48
|
beforeStop(): Promise<void>;
|
|
49
49
|
protected createHttpContext(req: any, res: any): Promise<unknown>;
|
|
50
50
|
useMiddleware(middleware: CommonMiddlewareUnion<Context, NextFunction, undefined>): void;
|
package/dist/framework.js
CHANGED
|
@@ -11,7 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MidwayFaaSFramework = void 0;
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
15
14
|
const simple_lock_1 = require("@midwayjs/simple-lock");
|
|
16
15
|
const logger_1 = require("@midwayjs/logger");
|
|
17
16
|
const serverless_http_parser_1 = require("@midwayjs/serverless-http-parser");
|
|
@@ -161,6 +160,15 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
161
160
|
...funOptions.controllerMiddleware,
|
|
162
161
|
...funOptions.middleware,
|
|
163
162
|
async (ctx, next) => {
|
|
163
|
+
if (funOptions.controllerClz &&
|
|
164
|
+
typeof funOptions.method === 'string') {
|
|
165
|
+
const isPassed = await this.app
|
|
166
|
+
.getFramework()
|
|
167
|
+
.runGuard(ctx, funOptions.controllerClz, funOptions.method);
|
|
168
|
+
if (!isPassed) {
|
|
169
|
+
throw new core_1.httpError.ForbiddenError();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
164
172
|
if (isHttpFunction) {
|
|
165
173
|
args = [ctx];
|
|
166
174
|
}
|
|
@@ -344,18 +352,18 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
344
352
|
if (isHttpFunction) {
|
|
345
353
|
for (const routerRes of routerResponseData) {
|
|
346
354
|
switch (routerRes.type) {
|
|
347
|
-
case
|
|
355
|
+
case core_1.WEB_RESPONSE_HTTP_CODE:
|
|
348
356
|
context.status = routerRes.code;
|
|
349
357
|
break;
|
|
350
|
-
case
|
|
358
|
+
case core_1.WEB_RESPONSE_HEADER:
|
|
351
359
|
for (const key in (routerRes === null || routerRes === void 0 ? void 0 : routerRes.setHeaders) || {}) {
|
|
352
360
|
context.set(key, routerRes.setHeaders[key]);
|
|
353
361
|
}
|
|
354
362
|
break;
|
|
355
|
-
case
|
|
363
|
+
case core_1.WEB_RESPONSE_CONTENT_TYPE:
|
|
356
364
|
context.type = routerRes.contentType;
|
|
357
365
|
break;
|
|
358
|
-
case
|
|
366
|
+
case core_1.WEB_RESPONSE_REDIRECT:
|
|
359
367
|
context.status = routerRes.code;
|
|
360
368
|
context.redirect(routerRes.url);
|
|
361
369
|
return;
|
|
@@ -412,15 +420,15 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
412
420
|
}
|
|
413
421
|
};
|
|
414
422
|
__decorate([
|
|
415
|
-
(0,
|
|
423
|
+
(0, core_1.Inject)(),
|
|
416
424
|
__metadata("design:type", core_1.MidwayEnvironmentService)
|
|
417
425
|
], MidwayFaaSFramework.prototype, "environmentService", void 0);
|
|
418
426
|
__decorate([
|
|
419
|
-
(0,
|
|
427
|
+
(0, core_1.Inject)(),
|
|
420
428
|
__metadata("design:type", core_1.MidwayMiddlewareService)
|
|
421
429
|
], MidwayFaaSFramework.prototype, "middlewareService", void 0);
|
|
422
430
|
MidwayFaaSFramework = __decorate([
|
|
423
|
-
(0,
|
|
431
|
+
(0, core_1.Framework)()
|
|
424
432
|
], MidwayFaaSFramework);
|
|
425
433
|
exports.MidwayFaaSFramework = MidwayFaaSFramework;
|
|
426
434
|
//# sourceMappingURL=framework.js.map
|
package/package.json
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/faas",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@midwayjs/core": "^3.
|
|
8
|
-
"@midwayjs/faas-typings": "^3.
|
|
7
|
+
"@midwayjs/core": "^3.6.0",
|
|
8
|
+
"@midwayjs/faas-typings": "^3.6.0",
|
|
9
9
|
"@midwayjs/logger": "^2.15.0",
|
|
10
|
-
"@midwayjs/serverless-http-parser": "^3.
|
|
10
|
+
"@midwayjs/serverless-http-parser": "^3.6.0",
|
|
11
11
|
"@midwayjs/simple-lock": "^1.1.4"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@midwayjs/
|
|
15
|
-
"@midwayjs/
|
|
16
|
-
"@midwayjs/serverless-
|
|
17
|
-
"@midwayjs/serverless-scf-starter": "^3.5.2",
|
|
14
|
+
"@midwayjs/mock": "^3.6.0",
|
|
15
|
+
"@midwayjs/serverless-fc-starter": "^3.6.0",
|
|
16
|
+
"@midwayjs/serverless-scf-starter": "^3.6.0",
|
|
18
17
|
"mm": "3.2.0"
|
|
19
18
|
},
|
|
20
19
|
"engines": {
|
|
@@ -46,5 +45,5 @@
|
|
|
46
45
|
"url": "git@github.com:midwayjs/midway.git"
|
|
47
46
|
},
|
|
48
47
|
"license": "MIT",
|
|
49
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "22643b0e8519766bb7c68b975930199fc136336e"
|
|
50
49
|
}
|