@midwayjs/faas 3.0.0-beta.1 → 3.0.0-beta.13
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/CHANGELOG.md +114 -0
- package/dist/configuration.js +4 -2
- package/dist/framework.d.ts +4 -3
- package/dist/framework.js +17 -17
- package/dist/interface.d.ts +2 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,120 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0-beta.13](https://github.com/midwayjs/midway/compare/v3.0.0-beta.12...v3.0.0-beta.13) (2021-12-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @midwayjs/faas
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.0.0-beta.12](https://github.com/midwayjs/midway/compare/v3.0.0-beta.11...v3.0.0-beta.12) (2021-12-28)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* support throw err status ([#1440](https://github.com/midwayjs/midway/issues/1440)) ([7b98110](https://github.com/midwayjs/midway/commit/7b98110d65c5287a8fcb3eb5356dea2d7a32cee9))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [3.0.0-beta.11](https://github.com/midwayjs/midway/compare/v3.0.0-beta.10...v3.0.0-beta.11) (2021-12-21)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @midwayjs/faas
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [3.0.0-beta.10](https://github.com/midwayjs/midway/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2021-12-20)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* default add session & bodyparser support for koa/express/faas ([#1420](https://github.com/midwayjs/midway/issues/1420)) ([cdaff31](https://github.com/midwayjs/midway/commit/cdaff317c3e862a95494a167995a28280af639bf))
|
|
39
|
+
* implement i18n for validate ([#1426](https://github.com/midwayjs/midway/issues/1426)) ([4c7ed2f](https://github.com/midwayjs/midway/commit/4c7ed2ff2e7ccf10f88f62abad230f92f5e76b97))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# [3.0.0-beta.9](https://github.com/midwayjs/midway/compare/v3.0.0-beta.8...v3.0.0-beta.9) (2021-12-09)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Bug Fixes
|
|
49
|
+
|
|
50
|
+
* faas missing config in framework ([#1413](https://github.com/midwayjs/midway/issues/1413)) ([7ab16a2](https://github.com/midwayjs/midway/commit/7ab16a24b29d5254a762bfffcdf18385effdf639))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# [3.0.0-beta.8](https://github.com/midwayjs/midway/compare/v3.0.0-beta.7...v3.0.0-beta.8) (2021-12-08)
|
|
57
|
+
|
|
58
|
+
**Note:** Version bump only for package @midwayjs/faas
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# [3.0.0-beta.7](https://github.com/midwayjs/midway/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2021-12-03)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Bug Fixes
|
|
68
|
+
|
|
69
|
+
* middleware with ctx.body ([#1389](https://github.com/midwayjs/midway/issues/1389)) ([77af5c0](https://github.com/midwayjs/midway/commit/77af5c0b456f1843f4dcfd3dbfd2c0aa244c51bd))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# [3.0.0-beta.6](https://github.com/midwayjs/midway/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2021-11-26)
|
|
76
|
+
|
|
77
|
+
**Note:** Version bump only for package @midwayjs/faas
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# [3.0.0-beta.5](https://github.com/midwayjs/midway/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-11-25)
|
|
84
|
+
|
|
85
|
+
**Note:** Version bump only for package @midwayjs/faas
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# [3.0.0-beta.4](https://github.com/midwayjs/midway/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-11-24)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
### Features
|
|
95
|
+
|
|
96
|
+
* add i18n ([#1375](https://github.com/midwayjs/midway/issues/1375)) ([bffefe0](https://github.com/midwayjs/midway/commit/bffefe07afe45777d49b5a76b9ab17fc2b9d9a55))
|
|
97
|
+
* auto transform args to type ([#1372](https://github.com/midwayjs/midway/issues/1372)) ([bb3f7d2](https://github.com/midwayjs/midway/commit/bb3f7d2028a034e1926d9df554849332354c3762))
|
|
98
|
+
* support global prefix url ([#1371](https://github.com/midwayjs/midway/issues/1371)) ([cc5fe44](https://github.com/midwayjs/midway/commit/cc5fe44e1d221590562dc71e1f33ae96093e0da7))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# [3.0.0-beta.3](https://github.com/midwayjs/midway/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2021-11-18)
|
|
105
|
+
|
|
106
|
+
**Note:** Version bump only for package @midwayjs/faas
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# [3.0.0-beta.2](https://github.com/midwayjs/midway/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2021-11-16)
|
|
113
|
+
|
|
114
|
+
**Note:** Version bump only for package @midwayjs/faas
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
6
120
|
# [3.0.0-beta.1](https://github.com/midwayjs/midway/compare/v2.12.4...v3.0.0-beta.1) (2021-11-14)
|
|
7
121
|
|
|
8
122
|
|
package/dist/configuration.js
CHANGED
|
@@ -27,12 +27,14 @@ let FaaSConfiguration = class FaaSConfiguration {
|
|
|
27
27
|
this.framework.getLogger());
|
|
28
28
|
});
|
|
29
29
|
this.decoratorService.registerParameterHandler(decorator_1.WEB_ROUTER_PARAM_KEY, options => {
|
|
30
|
-
return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData)(options.originArgs[0], options.originArgs[1]);
|
|
30
|
+
return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData, options.originParamType)(options.originArgs[0], options.originArgs[1]);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
async onReady(container) { }
|
|
34
34
|
async onServerReady() {
|
|
35
|
-
|
|
35
|
+
if (!this.framework.isEnable()) {
|
|
36
|
+
await this.framework.run();
|
|
37
|
+
}
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
40
|
__decorate([
|
package/dist/framework.d.ts
CHANGED
|
@@ -8,9 +8,10 @@ export declare class MidwayFaaSFramework extends BaseFramework<IMidwayFaaSApplic
|
|
|
8
8
|
private lock;
|
|
9
9
|
app: IMidwayFaaSApplication;
|
|
10
10
|
private isReplaceLogger;
|
|
11
|
+
private developmentRun;
|
|
11
12
|
environmentService: MidwayEnvironmentService;
|
|
12
|
-
middlewareService: MidwayMiddlewareService<FaaSContext>;
|
|
13
|
-
configure(options: IFaaSConfigurationOptions):
|
|
13
|
+
middlewareService: MidwayMiddlewareService<FaaSContext, any>;
|
|
14
|
+
configure(options: IFaaSConfigurationOptions): any;
|
|
14
15
|
isEnable(): boolean;
|
|
15
16
|
applicationInitialize(options: IMidwayBootstrapOptions): Promise<void>;
|
|
16
17
|
run(): Promise<void>;
|
|
@@ -20,7 +21,7 @@ export declare class MidwayFaaSFramework extends BaseFramework<IMidwayFaaSApplic
|
|
|
20
21
|
* @deprecated
|
|
21
22
|
* @param middlewareId
|
|
22
23
|
*/
|
|
23
|
-
generateMiddleware(middlewareId: string): Promise<FunctionMiddleware<FaaSContext>>;
|
|
24
|
+
generateMiddleware(middlewareId: string): Promise<FunctionMiddleware<FaaSContext, any>>;
|
|
24
25
|
getContext(context: any): any;
|
|
25
26
|
private invokeHandler;
|
|
26
27
|
protected getFunctionHandler(ctx: any, args: any, target: any, method: any): string;
|
package/dist/framework.js
CHANGED
|
@@ -14,7 +14,6 @@ const core_1 = require("@midwayjs/core");
|
|
|
14
14
|
const decorator_1 = require("@midwayjs/decorator");
|
|
15
15
|
const simple_lock_1 = require("@midwayjs/simple-lock");
|
|
16
16
|
const logger_1 = require("@midwayjs/logger");
|
|
17
|
-
const middlewareManager_1 = require("@midwayjs/core/dist/util/middlewareManager");
|
|
18
17
|
const LOCK_KEY = '_faas_starter_start_key';
|
|
19
18
|
let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework {
|
|
20
19
|
constructor() {
|
|
@@ -23,12 +22,19 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
23
22
|
this.funMappingStore = new Map();
|
|
24
23
|
this.lock = new simple_lock_1.default();
|
|
25
24
|
this.isReplaceLogger = process.env['MIDWAY_SERVERLESS_REPLACE_LOGGER'] === 'true';
|
|
25
|
+
this.developmentRun = false;
|
|
26
26
|
}
|
|
27
27
|
configure(options) {
|
|
28
|
-
|
|
28
|
+
if (options) {
|
|
29
|
+
this.developmentRun = true;
|
|
30
|
+
this.configurationOptions = options;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return this.configService.getConfiguration('faas');
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
36
|
isEnable() {
|
|
31
|
-
return
|
|
37
|
+
return !this.developmentRun;
|
|
32
38
|
}
|
|
33
39
|
async applicationInitialize(options) {
|
|
34
40
|
var _a;
|
|
@@ -61,6 +67,9 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
61
67
|
return (_a = this.configurationOptions.applicationAdapter) === null || _a === void 0 ? void 0 : _a.getFunctionServiceName();
|
|
62
68
|
},
|
|
63
69
|
});
|
|
70
|
+
// hack use method
|
|
71
|
+
this.app.originUse = this.app.use;
|
|
72
|
+
this.app.use = this.app.useMiddleware;
|
|
64
73
|
}
|
|
65
74
|
async run() {
|
|
66
75
|
return this.lock.sureOnce(async () => {
|
|
@@ -73,11 +82,6 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
73
82
|
for (const funcInfo of functionList) {
|
|
74
83
|
this.funMappingStore.set(funcInfo.funcHandlerName, funcInfo);
|
|
75
84
|
}
|
|
76
|
-
// bind func and controller module
|
|
77
|
-
const routerModules = await collector.getRouterModules();
|
|
78
|
-
for (const module of routerModules) {
|
|
79
|
-
this.getApplicationContext().bindClass(module);
|
|
80
|
-
}
|
|
81
85
|
}, LOCK_KEY);
|
|
82
86
|
}
|
|
83
87
|
getFrameworkType() {
|
|
@@ -94,8 +98,8 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
94
98
|
}
|
|
95
99
|
const context = this.getContext(args.shift());
|
|
96
100
|
const isHttpFunction = !!(context.headers && context.get);
|
|
97
|
-
const globalMiddlewareFn = await this.
|
|
98
|
-
const middlewareManager = new
|
|
101
|
+
const globalMiddlewareFn = await this.applyMiddleware();
|
|
102
|
+
const middlewareManager = new core_1.ContextMiddlewareManager();
|
|
99
103
|
middlewareManager.insertLast(globalMiddlewareFn);
|
|
100
104
|
middlewareManager.insertLast(async (ctx, next) => {
|
|
101
105
|
const fn = await this.middlewareService.compose([
|
|
@@ -112,15 +116,11 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
|
|
|
112
116
|
}
|
|
113
117
|
return result;
|
|
114
118
|
},
|
|
115
|
-
]);
|
|
119
|
+
], this.app);
|
|
116
120
|
return await fn(ctx, next);
|
|
117
121
|
});
|
|
118
|
-
const composeMiddleware = await this.middlewareService.compose(middlewareManager);
|
|
119
|
-
|
|
120
|
-
if (error) {
|
|
121
|
-
throw error;
|
|
122
|
-
}
|
|
123
|
-
return result;
|
|
122
|
+
const composeMiddleware = await this.middlewareService.compose(middlewareManager, this.app);
|
|
123
|
+
return await composeMiddleware(context);
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
/**
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MidwayRequestContainer, IMidwayApplication, IConfigurationOptions, IMidwayContext } from '@midwayjs/core';
|
|
1
|
+
import { MidwayRequestContainer, IMidwayApplication, IConfigurationOptions, IMidwayContext, NextFunction as BaseNextFunction } from '@midwayjs/core';
|
|
2
2
|
import { FaaSHTTPContext } from '@midwayjs/faas-typings';
|
|
3
3
|
import { ILogger } from '@midwayjs/logger';
|
|
4
4
|
export interface FaaSContext extends IMidwayContext<FaaSHTTPContext> {
|
|
@@ -29,6 +29,7 @@ export interface Application extends IMidwayFaaSApplication {
|
|
|
29
29
|
}
|
|
30
30
|
export interface Context extends FaaSContext {
|
|
31
31
|
}
|
|
32
|
+
export declare type NextFunction = BaseNextFunction;
|
|
32
33
|
export interface IFaaSConfigurationOptions extends IConfigurationOptions {
|
|
33
34
|
config?: object;
|
|
34
35
|
initializeContext?: object;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/faas",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.13",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@midwayjs/core": "^3.0.0-beta.
|
|
8
|
-
"@midwayjs/faas-typings": "^3.0.0-beta.
|
|
9
|
-
"@midwayjs/logger": "^3.0.0-beta.
|
|
7
|
+
"@midwayjs/core": "^3.0.0-beta.13",
|
|
8
|
+
"@midwayjs/faas-typings": "^3.0.0-beta.13",
|
|
9
|
+
"@midwayjs/logger": "^3.0.0-beta.13",
|
|
10
10
|
"@midwayjs/simple-lock": "^1.1.4"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@midwayjs/decorator": "^3.0.0-beta.
|
|
14
|
-
"@midwayjs/mock": "^3.0.0-beta.
|
|
15
|
-
"@midwayjs/serverless-fc-starter": "^3.0.0-beta.
|
|
16
|
-
"@midwayjs/serverless-scf-starter": "^3.0.0-beta.
|
|
13
|
+
"@midwayjs/decorator": "^3.0.0-beta.13",
|
|
14
|
+
"@midwayjs/mock": "^3.0.0-beta.13",
|
|
15
|
+
"@midwayjs/serverless-fc-starter": "^3.0.0-beta.13",
|
|
16
|
+
"@midwayjs/serverless-scf-starter": "^3.0.0-beta.13",
|
|
17
17
|
"mm": "3"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"url": "git@github.com:midwayjs/midway.git"
|
|
46
46
|
},
|
|
47
47
|
"license": "MIT",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "d3c47770fee9dce33a8d148882173fd7782864ad"
|
|
49
49
|
}
|