@midwayjs/faas 3.0.0-beta.1 → 3.0.0-beta.10

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 CHANGED
@@ -3,6 +3,93 @@
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.10](https://github.com/midwayjs/midway/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2021-12-20)
7
+
8
+
9
+ ### Features
10
+
11
+ * 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))
12
+ * implement i18n for validate ([#1426](https://github.com/midwayjs/midway/issues/1426)) ([4c7ed2f](https://github.com/midwayjs/midway/commit/4c7ed2ff2e7ccf10f88f62abad230f92f5e76b97))
13
+
14
+
15
+
16
+
17
+
18
+ # [3.0.0-beta.9](https://github.com/midwayjs/midway/compare/v3.0.0-beta.8...v3.0.0-beta.9) (2021-12-09)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * faas missing config in framework ([#1413](https://github.com/midwayjs/midway/issues/1413)) ([7ab16a2](https://github.com/midwayjs/midway/commit/7ab16a24b29d5254a762bfffcdf18385effdf639))
24
+
25
+
26
+
27
+
28
+
29
+ # [3.0.0-beta.8](https://github.com/midwayjs/midway/compare/v3.0.0-beta.7...v3.0.0-beta.8) (2021-12-08)
30
+
31
+ **Note:** Version bump only for package @midwayjs/faas
32
+
33
+
34
+
35
+
36
+
37
+ # [3.0.0-beta.7](https://github.com/midwayjs/midway/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2021-12-03)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * middleware with ctx.body ([#1389](https://github.com/midwayjs/midway/issues/1389)) ([77af5c0](https://github.com/midwayjs/midway/commit/77af5c0b456f1843f4dcfd3dbfd2c0aa244c51bd))
43
+
44
+
45
+
46
+
47
+
48
+ # [3.0.0-beta.6](https://github.com/midwayjs/midway/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2021-11-26)
49
+
50
+ **Note:** Version bump only for package @midwayjs/faas
51
+
52
+
53
+
54
+
55
+
56
+ # [3.0.0-beta.5](https://github.com/midwayjs/midway/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-11-25)
57
+
58
+ **Note:** Version bump only for package @midwayjs/faas
59
+
60
+
61
+
62
+
63
+
64
+ # [3.0.0-beta.4](https://github.com/midwayjs/midway/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-11-24)
65
+
66
+
67
+ ### Features
68
+
69
+ * add i18n ([#1375](https://github.com/midwayjs/midway/issues/1375)) ([bffefe0](https://github.com/midwayjs/midway/commit/bffefe07afe45777d49b5a76b9ab17fc2b9d9a55))
70
+ * auto transform args to type ([#1372](https://github.com/midwayjs/midway/issues/1372)) ([bb3f7d2](https://github.com/midwayjs/midway/commit/bb3f7d2028a034e1926d9df554849332354c3762))
71
+ * support global prefix url ([#1371](https://github.com/midwayjs/midway/issues/1371)) ([cc5fe44](https://github.com/midwayjs/midway/commit/cc5fe44e1d221590562dc71e1f33ae96093e0da7))
72
+
73
+
74
+
75
+
76
+
77
+ # [3.0.0-beta.3](https://github.com/midwayjs/midway/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2021-11-18)
78
+
79
+ **Note:** Version bump only for package @midwayjs/faas
80
+
81
+
82
+
83
+
84
+
85
+ # [3.0.0-beta.2](https://github.com/midwayjs/midway/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2021-11-16)
86
+
87
+ **Note:** Version bump only for package @midwayjs/faas
88
+
89
+
90
+
91
+
92
+
6
93
  # [3.0.0-beta.1](https://github.com/midwayjs/midway/compare/v2.12.4...v3.0.0-beta.1) (2021-11-14)
7
94
 
8
95
 
@@ -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
- await this.framework.run();
35
+ if (!this.framework.isEnable()) {
36
+ await this.framework.run();
37
+ }
36
38
  }
37
39
  };
38
40
  __decorate([
@@ -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): void;
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
- this.configurationOptions = options;
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 false;
37
+ return !this.developmentRun;
32
38
  }
33
39
  async applicationInitialize(options) {
34
40
  var _a;
@@ -73,11 +79,6 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
73
79
  for (const funcInfo of functionList) {
74
80
  this.funMappingStore.set(funcInfo.funcHandlerName, funcInfo);
75
81
  }
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
82
  }, LOCK_KEY);
82
83
  }
83
84
  getFrameworkType() {
@@ -94,8 +95,8 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
94
95
  }
95
96
  const context = this.getContext(args.shift());
96
97
  const isHttpFunction = !!(context.headers && context.get);
97
- const globalMiddlewareFn = await this.getMiddleware();
98
- const middlewareManager = new middlewareManager_1.ContextMiddlewareManager();
98
+ const globalMiddlewareFn = await this.applyMiddleware();
99
+ const middlewareManager = new core_1.ContextMiddlewareManager();
99
100
  middlewareManager.insertLast(globalMiddlewareFn);
100
101
  middlewareManager.insertLast(async (ctx, next) => {
101
102
  const fn = await this.middlewareService.compose([
@@ -112,15 +113,11 @@ let MidwayFaaSFramework = class MidwayFaaSFramework extends core_1.BaseFramework
112
113
  }
113
114
  return result;
114
115
  },
115
- ]);
116
+ ], this.app);
116
117
  return await fn(ctx, next);
117
118
  });
118
- const composeMiddleware = await this.middlewareService.compose(middlewareManager);
119
- const { error, result } = await composeMiddleware(context);
120
- if (error) {
121
- throw error;
122
- }
123
- return result;
119
+ const composeMiddleware = await this.middlewareService.compose(middlewareManager, this.app);
120
+ return await composeMiddleware(context);
124
121
  };
125
122
  }
126
123
  /**
@@ -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.1",
3
+ "version": "3.0.0-beta.10",
4
4
  "main": "dist/index",
5
5
  "typings": "index.d.ts",
6
6
  "dependencies": {
7
- "@midwayjs/core": "^3.0.0-beta.1",
8
- "@midwayjs/faas-typings": "^3.0.0-beta.1",
9
- "@midwayjs/logger": "^3.0.0-beta.1",
7
+ "@midwayjs/core": "^3.0.0-beta.10",
8
+ "@midwayjs/faas-typings": "^3.0.0-beta.10",
9
+ "@midwayjs/logger": "^3.0.0-beta.10",
10
10
  "@midwayjs/simple-lock": "^1.1.4"
11
11
  },
12
12
  "devDependencies": {
13
- "@midwayjs/decorator": "^3.0.0-beta.1",
14
- "@midwayjs/mock": "^3.0.0-beta.1",
15
- "@midwayjs/serverless-fc-starter": "^3.0.0-beta.1",
16
- "@midwayjs/serverless-scf-starter": "^3.0.0-beta.1",
13
+ "@midwayjs/decorator": "^3.0.0-beta.10",
14
+ "@midwayjs/mock": "^3.0.0-beta.10",
15
+ "@midwayjs/serverless-fc-starter": "^3.0.0-beta.10",
16
+ "@midwayjs/serverless-scf-starter": "^3.0.0-beta.10",
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": "72e4d20c678e65a5440c4e9a6d3b70046daa497c"
48
+ "gitHead": "153870f2e2dd6b17673ec7591e49224a6bd51b36"
49
49
  }