@celljs/fc-adapter 3.0.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.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/cell-api-gateway-mode.yml +2 -0
  4. package/cell-event-mode.yml +2 -0
  5. package/cell-http-mode.yml +2 -0
  6. package/cell-mns-topic-mode.yml +2 -0
  7. package/cell-remote.yml +1 -0
  8. package/cell-sample-http-mode.yml +2 -0
  9. package/cell-timer-mode.yml +2 -0
  10. package/cell.yml +0 -0
  11. package/lib/node/account-provider.d.ts +6 -0
  12. package/lib/node/account-provider.d.ts.map +1 -0
  13. package/lib/node/account-provider.js +28 -0
  14. package/lib/node/account-provider.js.map +1 -0
  15. package/lib/node/api-gateway-application-entry.d.ts +2 -0
  16. package/lib/node/api-gateway-application-entry.d.ts.map +1 -0
  17. package/lib/node/api-gateway-application-entry.js +47 -0
  18. package/lib/node/api-gateway-application-entry.js.map +1 -0
  19. package/lib/node/credentials-provider.d.ts +6 -0
  20. package/lib/node/credentials-provider.d.ts.map +1 -0
  21. package/lib/node/credentials-provider.js +30 -0
  22. package/lib/node/credentials-provider.js.map +1 -0
  23. package/lib/node/event-application-entry.d.ts +2 -0
  24. package/lib/node/event-application-entry.d.ts.map +1 -0
  25. package/lib/node/event-application-entry.js +35 -0
  26. package/lib/node/event-application-entry.js.map +1 -0
  27. package/lib/node/http-application-entry.d.ts +2 -0
  28. package/lib/node/http-application-entry.d.ts.map +1 -0
  29. package/lib/node/http-application-entry.js +43 -0
  30. package/lib/node/http-application-entry.js.map +1 -0
  31. package/lib/node/index.d.ts +4 -0
  32. package/lib/node/index.d.ts.map +1 -0
  33. package/lib/node/index.js +20 -0
  34. package/lib/node/index.js.map +1 -0
  35. package/lib/node/module.d.ts +4 -0
  36. package/lib/node/module.d.ts.map +1 -0
  37. package/lib/node/module.js +6 -0
  38. package/lib/node/module.js.map +1 -0
  39. package/lib/node/regin-provider.d.ts +5 -0
  40. package/lib/node/regin-provider.d.ts.map +1 -0
  41. package/lib/node/regin-provider.js +26 -0
  42. package/lib/node/regin-provider.js.map +1 -0
  43. package/lib/node/sample-http-application-entry.d.ts +2 -0
  44. package/lib/node/sample-http-application-entry.d.ts.map +1 -0
  45. package/lib/node/sample-http-application-entry.js +40 -0
  46. package/lib/node/sample-http-application-entry.js.map +1 -0
  47. package/lib/node/timer-application-entry.d.ts +2 -0
  48. package/lib/node/timer-application-entry.d.ts.map +1 -0
  49. package/lib/node/timer-application-entry.js +38 -0
  50. package/lib/node/timer-application-entry.js.map +1 -0
  51. package/lib/package.spec.d.ts +1 -0
  52. package/lib/package.spec.d.ts.map +1 -0
  53. package/lib/package.spec.js +4 -0
  54. package/lib/package.spec.js.map +1 -0
  55. package/package.json +54 -0
  56. package/src/node/account-provider.ts +18 -0
  57. package/src/node/api-gateway-application-entry.ts +47 -0
  58. package/src/node/credentials-provider.ts +20 -0
  59. package/src/node/event-application-entry.ts +33 -0
  60. package/src/node/http-application-entry.ts +43 -0
  61. package/src/node/index.ts +3 -0
  62. package/src/node/module.ts +4 -0
  63. package/src/node/regin-provider.ts +15 -0
  64. package/src/node/sample-http-application-entry.ts +40 -0
  65. package/src/node/timer-application-entry.ts +36 -0
  66. package/src/package.spec.ts +4 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Cellbang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Cell - FC Adapter Component
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/api-gateway-application-entry
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/event-application-entry
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/http-application-entry
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/event-application-entry
@@ -0,0 +1 @@
1
+ mode: "${currentMode|toObjects[.item in [ 'http', 'api-gateway', 'sample-http', 'timer', 'mns-topic', 'event']]|suffix('-mode') || 'http-mode'}"
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/sample-http-application-entry
@@ -0,0 +1,2 @@
1
+ backend:
2
+ entry: lib/node/timer-application-entry
package/cell.yml ADDED
File without changes
@@ -0,0 +1,6 @@
1
+ import { DefaultAccountProvider } from '@celljs/cloud/lib/node';
2
+ import { Account } from '@celljs/cloud';
3
+ export declare class FaaSAccountProvider extends DefaultAccountProvider {
4
+ provide(): Promise<Account | undefined>;
5
+ }
6
+ //# sourceMappingURL=account-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-provider.d.ts","sourceRoot":"","sources":["../../src/node/account-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAmB,OAAO,EAAE,MAAM,eAAe,CAAC;AAEzD,qBACa,mBAAoB,SAAQ,sBAAsB;IAE5C,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;CAUzD"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.FaaSAccountProvider = void 0;
10
+ const core_1 = require("@celljs/core");
11
+ const node_1 = require("@celljs/cloud/lib/node");
12
+ const cloud_1 = require("@celljs/cloud");
13
+ let FaaSAccountProvider = class FaaSAccountProvider extends node_1.DefaultAccountProvider {
14
+ async provide() {
15
+ const account = await super.provide();
16
+ if (account) {
17
+ return account;
18
+ }
19
+ return {
20
+ id: process.env.ALIBABA_ACCOUNT_ID
21
+ };
22
+ }
23
+ };
24
+ FaaSAccountProvider = __decorate([
25
+ (0, core_1.Component)({ id: cloud_1.AccountProvider, rebind: true })
26
+ ], FaaSAccountProvider);
27
+ exports.FaaSAccountProvider = FaaSAccountProvider;
28
+ //# sourceMappingURL=account-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-provider.js","sourceRoot":"","sources":["../../src/node/account-provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyC;AACzC,iDAAgE;AAChE,yCAAyD;AAGlD,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,6BAAsB;IAElD,KAAK,CAAC,OAAO;QAClB,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,OAAO,EAAE;YACT,OAAO,OAAO,CAAC;SAClB;QACD,OAAO;YACH,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAmB;SACtC,CAAC;IACN,CAAC;CAEJ,CAAA;AAZY,mBAAmB;IAD/B,IAAA,gBAAS,EAAC,EAAE,EAAE,EAAE,uBAAe,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACpC,mBAAmB,CAY/B;AAZY,kDAAmB"}
@@ -0,0 +1,2 @@
1
+ export declare function handler(event: string, context: any, callback: any): Promise<void>;
2
+ //# sourceMappingURL=api-gateway-application-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-gateway-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/api-gateway-application-entry.ts"],"names":[],"mappings":"AA8BA,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,iBAgBvE"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = void 0;
4
+ const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
5
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
6
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
7
+ const dispatcher_protocol_1 = require("@celljs/web/lib/node/dispatcher/dispatcher-protocol");
8
+ const context_1 = require("@celljs/web/lib/node/context");
9
+ const event_protocol_1 = require("@celljs/faas-adapter/lib/node/event/event-protocol");
10
+ const express = require("express");
11
+ const proxy = require("@webserverless/fc-express");
12
+ let listeners;
13
+ const app = express();
14
+ const server = new proxy.Server(app);
15
+ async function start() {
16
+ const c = await dynamic_container_1.container;
17
+ container_provider_1.ContainerProvider.set(c);
18
+ app.all('*', async (req, res) => {
19
+ const dispatcher = c.get(dispatcher_protocol_1.Dispatcher);
20
+ const httpContext = new context_1.Context(req, res);
21
+ context_1.Context.run(() => dispatcher.dispatch(httpContext));
22
+ });
23
+ listeners = c.getAll(event_protocol_1.FaaSEventListener);
24
+ return c.get(application_protocol_1.Application).start();
25
+ }
26
+ const startPromise = start();
27
+ async function handler(event, context, callback) {
28
+ var _a, _b, _c;
29
+ process.env.ALIBABA_ACCOUNT_ID = context.accountId;
30
+ process.env.ALIBABA_ACCESS_KEY_ID = (_a = context.credentials) === null || _a === void 0 ? void 0 : _a.accessKeyId;
31
+ process.env.ALIBABA_ACCESS_KEY_SECRET = (_b = context.credentials) === null || _b === void 0 ? void 0 : _b.accessKeySecret;
32
+ process.env.ALIBABA_SECURITY_TOKEN = (_c = context.credentials) === null || _c === void 0 ? void 0 : _c.securityToken;
33
+ process.env.ALIBABA_REQUEST_ID = context.requestId;
34
+ process.env.ALIBABA_REGION = context.region;
35
+ process.env.IGNORE_EVENT_HEADER = 'true';
36
+ process.env.IGNORE_CONTEXT_HEADER = 'true';
37
+ try {
38
+ await startPromise;
39
+ await Promise.all(listeners.map(l => l.onTrigger(event)));
40
+ }
41
+ catch (error) {
42
+ callback(undefined, error);
43
+ }
44
+ server.proxy(event, context, callback);
45
+ }
46
+ exports.handler = handler;
47
+ //# sourceMappingURL=api-gateway-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-gateway-application-entry.js","sourceRoot":"","sources":["../../src/node/api-gateway-application-entry.ts"],"names":[],"mappings":";;;AAAA,2FAAgF;AAChF,mGAAuF;AACvF,6FAAyF;AACzF,6FAAiF;AACjF,0DAAuD;AACvD,uFAAuF;AACvF,mCAAmC;AACnC,mDAAmD;AAEnD,IAAI,SAAyC,CAAC;AAE9C,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;AAEtB,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAErC,KAAK,UAAU,KAAK;IAChB,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;IAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,EAAE;QACtC,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAsB,gCAAU,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,IAAI,iBAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1C,iBAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IACH,SAAS,GAAG,CAAC,CAAC,MAAM,CAA+B,kCAAiB,CAAC,CAAC;IAEtE,OAAO,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;AACnD,CAAC;AAED,MAAM,YAAY,GAAG,KAAK,EAAE,CAAC;AAEtB,KAAK,UAAU,OAAO,CAAC,KAAa,EAAE,OAAY,EAAE,QAAa;;IACpE,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,WAAW,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,eAAe,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,aAAa,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,MAAM,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,MAAM,CAAC;IAC3C,IAAI;QACA,MAAM,YAAY,CAAC;QACnB,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC7D;IAAC,OAAO,KAAK,EAAE;QACZ,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;KAC9B;IACD,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC;AAhBD,0BAgBC"}
@@ -0,0 +1,6 @@
1
+ import { DefaultCredentialsProvider } from '@celljs/cloud/lib/node';
2
+ import { Credentials } from '@celljs/cloud';
3
+ export declare class FaaSCredentialsProvider extends DefaultCredentialsProvider {
4
+ provide(): Promise<Credentials | undefined>;
5
+ }
6
+ //# sourceMappingURL=credentials-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials-provider.d.ts","sourceRoot":"","sources":["../../src/node/credentials-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAuB,MAAM,eAAe,CAAC;AAEjE,qBACa,uBAAwB,SAAQ,0BAA0B;IAEpD,OAAO,IAAI,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;CAY7D"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.FaaSCredentialsProvider = void 0;
10
+ const node_1 = require("@celljs/cloud/lib/node");
11
+ const core_1 = require("@celljs/core");
12
+ const cloud_1 = require("@celljs/cloud");
13
+ let FaaSCredentialsProvider = class FaaSCredentialsProvider extends node_1.DefaultCredentialsProvider {
14
+ async provide() {
15
+ const credentials = await super.provide();
16
+ if (credentials) {
17
+ return credentials;
18
+ }
19
+ return {
20
+ accessKeyId: process.env.ALIBABA_ACCESS_KEY_ID,
21
+ accessKeySecret: process.env.ALIBABA_ACCESS_KEY_SECRET,
22
+ token: process.env.ALIBABA_SECURITY_TOKEN
23
+ };
24
+ }
25
+ };
26
+ FaaSCredentialsProvider = __decorate([
27
+ (0, core_1.Component)({ id: cloud_1.CredentialsProvider, rebind: true })
28
+ ], FaaSCredentialsProvider);
29
+ exports.FaaSCredentialsProvider = FaaSCredentialsProvider;
30
+ //# sourceMappingURL=credentials-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials-provider.js","sourceRoot":"","sources":["../../src/node/credentials-provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iDAAoE;AACpE,uCAAyC;AACzC,yCAAiE;AAG1D,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,iCAA0B;IAE1D,KAAK,CAAC,OAAO;QAClB,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAC1C,IAAI,WAAW,EAAE;YACb,OAAO,WAAW,CAAC;SACtB;QACD,OAAO;YACH,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAsB;YAC/C,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,yBAA0B;YACvD,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;SAC5C,CAAC;IACN,CAAC;CAEJ,CAAA;AAdY,uBAAuB;IADnC,IAAA,gBAAS,EAAC,EAAE,EAAE,EAAE,2BAAmB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACxC,uBAAuB,CAcnC;AAdY,0DAAuB"}
@@ -0,0 +1,2 @@
1
+ export declare function handler(event: string, context: any, callback: any): Promise<void>;
2
+ //# sourceMappingURL=event-application-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/event-application-entry.ts"],"names":[],"mappings":"AAgBA,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,iBAgBvE"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = void 0;
4
+ const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
5
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
6
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
7
+ const event_protocol_1 = require("@celljs/faas-adapter/lib/node/event/event-protocol");
8
+ let listeners;
9
+ async function start() {
10
+ const c = await dynamic_container_1.container;
11
+ container_provider_1.ContainerProvider.set(c);
12
+ await c.get(application_protocol_1.Application).start();
13
+ listeners = c.getAll(event_protocol_1.FaaSEventListener);
14
+ }
15
+ const startPromise = start();
16
+ async function handler(event, context, callback) {
17
+ var _a, _b, _c;
18
+ process.env.ALIBABA_ACCOUNT_ID = context.accountId;
19
+ process.env.ALIBABA_ACCESS_KEY_ID = (_a = context.credentials) === null || _a === void 0 ? void 0 : _a.accessKeyId;
20
+ process.env.ALIBABA_ACCESS_KEY_SECRET = (_b = context.credentials) === null || _b === void 0 ? void 0 : _b.accessKeySecret;
21
+ process.env.ALIBABA_SECURITY_TOKEN = (_c = context.credentials) === null || _c === void 0 ? void 0 : _c.securityToken;
22
+ process.env.ALIBABA_REQUEST_ID = context.requestId;
23
+ process.env.ALIBABA_REGION = context.region;
24
+ try {
25
+ await startPromise;
26
+ let result = await Promise.all(listeners.map(l => l.onTrigger(event)));
27
+ result = result.filter(item => !!item);
28
+ callback(result.length === 1 ? result[0] : result);
29
+ }
30
+ catch (error) {
31
+ callback(undefined, error);
32
+ }
33
+ }
34
+ exports.handler = handler;
35
+ //# sourceMappingURL=event-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-application-entry.js","sourceRoot":"","sources":["../../src/node/event-application-entry.ts"],"names":[],"mappings":";;;AAAA,2FAAgF;AAChF,mGAAuF;AACvF,6FAAyF;AACzF,uFAAuF;AAEvF,IAAI,SAAwC,CAAC;AAE7C,KAAK,UAAU,KAAK;IAChB,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;IAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;IAC9C,SAAS,GAAG,CAAC,CAAC,MAAM,CAA8B,kCAAiB,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,YAAY,GAAG,KAAK,EAAE,CAAC;AAEtB,KAAK,UAAU,OAAO,CAAC,KAAa,EAAE,OAAY,EAAE,QAAa;;IACpE,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,WAAW,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,eAAe,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,aAAa,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAC5C,IAAI;QACA,MAAM,YAAY,CAAC;QACnB,IAAI,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACvC,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;KACtD;IAAC,OAAO,KAAK,EAAE;QACZ,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;KAC9B;AAEL,CAAC;AAhBD,0BAgBC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=http-application-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/http-application-entry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
4
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
5
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
6
+ const dispatcher_protocol_1 = require("@celljs/web/lib/node/dispatcher/dispatcher-protocol");
7
+ const context_1 = require("@celljs/web/lib/node/context");
8
+ const express = require("express");
9
+ const app = express();
10
+ const port = 9000;
11
+ async function bootstrap() {
12
+ try {
13
+ const c = await dynamic_container_1.container;
14
+ container_provider_1.ContainerProvider.set(c);
15
+ await c.get(application_protocol_1.Application).start();
16
+ app.all('*', async (req, res) => {
17
+ process.env.ALIBABA_ACCOUNT_ID = req.get('x-fc-account-id');
18
+ process.env.ALIBABA_ACCESS_KEY_ID = req.get('x-fc-access-key-id');
19
+ process.env.ALIBABA_ACCESS_KEY_SECRET = req.get('x-fc-access-key-secret');
20
+ process.env.ALIBABA_SECURITY_TOKEN = req.get('x-fc-security-token');
21
+ process.env.ALIBABA_REQUEST_ID = req.get('x-fc-request-id');
22
+ process.env.ALIBABA_REGION = req.get('x-fc-region');
23
+ const dispatcher = c.get(dispatcher_protocol_1.Dispatcher);
24
+ const httpContext = new context_1.Context(req, res);
25
+ context_1.Context.run(() => dispatcher.dispatch(httpContext));
26
+ });
27
+ const server = app.listen(port, '0.0.0.0');
28
+ server.timeout = 0;
29
+ server.keepAliveTimeout = 0;
30
+ console.log(`serve ${port}`);
31
+ }
32
+ catch (error) {
33
+ app.all('*', async (req, res) => {
34
+ res.status = 500;
35
+ res.send(error);
36
+ });
37
+ const server = app.listen(port, '0.0.0.0');
38
+ server.timeout = 0;
39
+ server.keepAliveTimeout = 0;
40
+ }
41
+ }
42
+ bootstrap();
43
+ //# sourceMappingURL=http-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-application-entry.js","sourceRoot":"","sources":["../../src/node/http-application-entry.ts"],"names":[],"mappings":";;AAAA,2FAAgF;AAChF,mGAAuF;AACvF,6FAAyF;AACzF,6FAAiF;AACjF,0DAAuD;AACvD,mCAAmC;AAEnC,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;AAEtB,MAAM,IAAI,GAAG,IAAI,CAAC;AAElB,KAAK,UAAU,SAAS;IACpB,IAAI;QACA,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;QAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;QAC9C,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,EAAE;YACtC,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YAClE,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,GAAG,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;YAC1E,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;YACpE,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAsB,gCAAU,CAAC,CAAC;YAC1D,MAAM,WAAW,GAAG,IAAI,iBAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAC1C,iBAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC3C,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;QACnB,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;KAChC;IAAC,OAAO,KAAK,EAAE;QACZ,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,EAAE;YACtC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;YACjB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC3C,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;QACnB,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC;KAC/B;AACL,CAAC;AAED,SAAS,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './account-provider';
2
+ export * from './credentials-provider';
3
+ export * from './regin-provider';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,20 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./account-provider"), exports);
18
+ __exportStar(require("./credentials-provider"), exports);
19
+ __exportStar(require("./regin-provider"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,yDAAuC;AACvC,mDAAiC"}
@@ -0,0 +1,4 @@
1
+ import './index';
2
+ declare const _default: import("inversify/lib/interfaces/interfaces").interfaces.ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,CAAC;;AAEjB,wBAA0B"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@celljs/core");
4
+ require("./index");
5
+ exports.default = (0, core_1.autoBind)();
6
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AACxC,mBAAiB;AAEjB,kBAAe,IAAA,eAAQ,GAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { DefaultRegionProvider } from '@celljs/cloud/lib/node';
2
+ export declare class FaaSRegionProvider extends DefaultRegionProvider {
3
+ provide(): Promise<string | undefined>;
4
+ }
5
+ //# sourceMappingURL=regin-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regin-provider.d.ts","sourceRoot":"","sources":["../../src/node/regin-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,qBACa,kBAAmB,SAAQ,qBAAqB;IAE1C,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAOxD"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.FaaSRegionProvider = void 0;
10
+ const node_1 = require("@celljs/cloud/lib/node");
11
+ const core_1 = require("@celljs/core");
12
+ const cloud_1 = require("@celljs/cloud");
13
+ let FaaSRegionProvider = class FaaSRegionProvider extends node_1.DefaultRegionProvider {
14
+ async provide() {
15
+ const region = await super.provide();
16
+ if (region) {
17
+ return region;
18
+ }
19
+ return process.env.ALIBABA_REGION;
20
+ }
21
+ };
22
+ FaaSRegionProvider = __decorate([
23
+ (0, core_1.Component)({ id: cloud_1.RegionProvider, rebind: true })
24
+ ], FaaSRegionProvider);
25
+ exports.FaaSRegionProvider = FaaSRegionProvider;
26
+ //# sourceMappingURL=regin-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regin-provider.js","sourceRoot":"","sources":["../../src/node/regin-provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iDAA+D;AAC/D,uCAAyC;AACzC,yCAA+C;AAGxC,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,4BAAqB;IAEhD,KAAK,CAAC,OAAO;QAClB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,MAAM,EAAE;YACR,OAAO,MAAM,CAAC;SACjB;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IACtC,CAAC;CACJ,CAAA;AATY,kBAAkB;IAD9B,IAAA,gBAAS,EAAC,EAAE,EAAE,EAAE,sBAAc,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACnC,kBAAkB,CAS9B;AATY,gDAAkB"}
@@ -0,0 +1,2 @@
1
+ export declare function handler(req: any, res: any, context: any): Promise<void>;
2
+ //# sourceMappingURL=sample-http-application-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample-http-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/sample-http-application-entry.ts"],"names":[],"mappings":"AA2BA,wBAAsB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,iBAY7D"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = void 0;
4
+ const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
5
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
6
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
7
+ const dispatcher_protocol_1 = require("@celljs/web/lib/node/dispatcher/dispatcher-protocol");
8
+ const context_1 = require("@celljs/web/lib/node/context");
9
+ const express = require("express");
10
+ const proxy = require("@webserverless/fc-express");
11
+ const getRawBody = require('raw-body');
12
+ const app = express();
13
+ const server = new proxy.Server(app);
14
+ async function start() {
15
+ const c = await dynamic_container_1.container;
16
+ container_provider_1.ContainerProvider.set(c);
17
+ app.all('*', async (req, res) => {
18
+ const dispatcher = c.get(dispatcher_protocol_1.Dispatcher);
19
+ const httpContext = new context_1.Context(req, res);
20
+ context_1.Context.run(() => dispatcher.dispatch(httpContext));
21
+ });
22
+ return c.get(application_protocol_1.Application).start();
23
+ }
24
+ const startPromise = start();
25
+ async function handler(req, res, context) {
26
+ var _a, _b, _c;
27
+ process.env.ALIBABA_ACCOUNT_ID = context.accountId;
28
+ process.env.ALIBABA_ACCESS_KEY_ID = (_a = context.credentials) === null || _a === void 0 ? void 0 : _a.accessKeyId;
29
+ process.env.ALIBABA_ACCESS_KEY_SECRET = (_b = context.credentials) === null || _b === void 0 ? void 0 : _b.accessKeySecret;
30
+ process.env.ALIBABA_SECURITY_TOKEN = (_c = context.credentials) === null || _c === void 0 ? void 0 : _c.securityToken;
31
+ process.env.ALIBABA_REQUEST_ID = context.requestId;
32
+ process.env.ALIBABA_REGION = context.region;
33
+ process.env.IGNORE_EVENT_HEADER = 'true';
34
+ process.env.IGNORE_CONTEXT_HEADER = 'true';
35
+ req.body = await getRawBody(req);
36
+ await startPromise;
37
+ server.httpProxy(req, res, context);
38
+ }
39
+ exports.handler = handler;
40
+ //# sourceMappingURL=sample-http-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample-http-application-entry.js","sourceRoot":"","sources":["../../src/node/sample-http-application-entry.ts"],"names":[],"mappings":";;;AAAA,2FAAgF;AAChF,mGAAuF;AACvF,6FAAyF;AACzF,6FAAiF;AACjF,0DAAuD;AACvD,mCAAmC;AACnC,mDAAmD;AACnD,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEvC,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;AAEtB,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAErC,KAAK,UAAU,KAAK;IAChB,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;IAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,EAAE;QACtC,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAsB,gCAAU,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,IAAI,iBAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1C,iBAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;AACnD,CAAC;AAED,MAAM,YAAY,GAAG,KAAK,EAAE,CAAC;AAEtB,KAAK,UAAU,OAAO,CAAC,GAAQ,EAAE,GAAQ,EAAE,OAAY;;IAC1D,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,WAAW,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,eAAe,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,aAAa,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,MAAM,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,MAAM,CAAC;IAC3C,GAAG,CAAC,IAAI,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,YAAY,CAAC;IACnB,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAZD,0BAYC"}
@@ -0,0 +1,2 @@
1
+ export declare function handler(event: string, context: any, callback: any): Promise<void>;
2
+ //# sourceMappingURL=timer-application-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timer-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/timer-application-entry.ts"],"names":[],"mappings":"AAmBA,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,iBAgBvE"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = void 0;
4
+ const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
5
+ const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
6
+ const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
7
+ const timer_protocol_1 = require("@celljs/faas-adapter/lib/node/timer/timer-protocol");
8
+ const event_protocol_1 = require("@celljs/faas-adapter/lib/node/event/event-protocol");
9
+ let clock;
10
+ let listeners;
11
+ async function start() {
12
+ const c = await dynamic_container_1.container;
13
+ container_provider_1.ContainerProvider.set(c);
14
+ await c.get(application_protocol_1.Application).start();
15
+ clock = c.get(timer_protocol_1.Clock);
16
+ listeners = c.getAll(event_protocol_1.FaaSEventListener);
17
+ }
18
+ const startPromise = start();
19
+ async function handler(event, context, callback) {
20
+ var _a, _b, _c;
21
+ process.env.ALIBABA_ACCOUNT_ID = context.accountId;
22
+ process.env.ALIBABA_ACCESS_KEY_ID = (_a = context.credentials) === null || _a === void 0 ? void 0 : _a.accessKeyId;
23
+ process.env.ALIBABA_ACCESS_KEY_SECRET = (_b = context.credentials) === null || _b === void 0 ? void 0 : _b.accessKeySecret;
24
+ process.env.ALIBABA_SECURITY_TOKEN = (_c = context.credentials) === null || _c === void 0 ? void 0 : _c.securityToken;
25
+ process.env.ALIBABA_REQUEST_ID = context.requestId;
26
+ process.env.ALIBABA_REGION = context.region;
27
+ try {
28
+ await startPromise;
29
+ await Promise.all(listeners.map(l => l.onTrigger(event)));
30
+ await clock.tick();
31
+ callback();
32
+ }
33
+ catch (error) {
34
+ callback(undefined, error);
35
+ }
36
+ }
37
+ exports.handler = handler;
38
+ //# sourceMappingURL=timer-application-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timer-application-entry.js","sourceRoot":"","sources":["../../src/node/timer-application-entry.ts"],"names":[],"mappings":";;;AAAA,2FAAgF;AAChF,mGAAuF;AACvF,6FAAyF;AACzF,uFAA2E;AAC3E,uFAAuF;AAEvF,IAAI,KAAY,CAAC;AACjB,IAAI,SAAyC,CAAC;AAE9C,KAAK,UAAU,KAAK;IAChB,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;IAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;IAC9C,KAAK,GAAG,CAAC,CAAC,GAAG,CAAQ,sBAAK,CAAC,CAAC;IAC5B,SAAS,GAAG,CAAC,CAAC,MAAM,CAA+B,kCAAiB,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,YAAY,GAAG,KAAK,EAAE,CAAC;AAEtB,KAAK,UAAU,OAAO,CAAC,KAAa,EAAE,OAAY,EAAE,QAAa;;IACpE,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,WAAW,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,eAAe,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,aAAa,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAC5C,IAAI;QACA,MAAM,YAAY,CAAC;QACnB,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,QAAQ,EAAE,CAAC;KACd;IAAC,OAAO,KAAK,EAAE;QACZ,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;KAC9B;AAEL,CAAC;AAhBD,0BAgBC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=package.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ describe('fc adapter package', () => {
2
+ it('support code coverage statistics', () => { });
3
+ });
4
+ //# sourceMappingURL=package.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAEhC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@celljs/fc-adapter",
3
+ "version": "3.0.0",
4
+ "description": "",
5
+ "main": "lib/node/index.js",
6
+ "typings": "lib/node/index.d.ts",
7
+ "dependencies": {
8
+ "@celljs/cloud": "3.0.0",
9
+ "@celljs/core": "3.0.0",
10
+ "@celljs/faas-adapter": "3.0.0",
11
+ "@celljs/web": "3.0.0",
12
+ "@webserverless/fc-express": "^1.0.0",
13
+ "express": "^4.17.1",
14
+ "raw-body": "^2.3.3"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "keywords": [
20
+ "cell-component"
21
+ ],
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/cellbang/cell.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/cellbang/cell/issues"
29
+ },
30
+ "homepage": "https://github.com/cellbang/cell",
31
+ "files": [
32
+ "lib",
33
+ "src",
34
+ "cell.yml",
35
+ "cell-remote.yml",
36
+ "cell-http-mode.yml",
37
+ "cell-sample-http-mode.yml",
38
+ "cell-api-gateway-mode.yml",
39
+ "cell-timer-mode.yml",
40
+ "cell-mns-topic-mode.yml",
41
+ "cell-event-mode.yml"
42
+ ],
43
+ "scripts": {
44
+ "lint": "cell-component lint",
45
+ "build": "cell-component build",
46
+ "watch": "cell-component watch",
47
+ "clean": "cell-component clean",
48
+ "test": "cell-component test:js"
49
+ },
50
+ "devDependencies": {
51
+ "@celljs/component": "3.0.0"
52
+ },
53
+ "gitHead": "c0ef8d269e33a795406bcbb240cac4b845c6c24c"
54
+ }
@@ -0,0 +1,18 @@
1
+ import { Component } from '@celljs/core';
2
+ import { DefaultAccountProvider } from '@celljs/cloud/lib/node';
3
+ import { AccountProvider, Account } from '@celljs/cloud';
4
+
5
+ @Component({ id: AccountProvider, rebind: true })
6
+ export class FaaSAccountProvider extends DefaultAccountProvider {
7
+
8
+ override async provide(): Promise<Account | undefined> {
9
+ const account = await super.provide();
10
+ if (account) {
11
+ return account;
12
+ }
13
+ return {
14
+ id: process.env.ALIBABA_ACCOUNT_ID!
15
+ };
16
+ }
17
+
18
+ }
@@ -0,0 +1,47 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Application } from '@celljs/core/lib/common/application/application-protocol';
3
+ import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
4
+ import { Dispatcher } from '@celljs/web/lib/node/dispatcher/dispatcher-protocol';
5
+ import { Context } from '@celljs/web/lib/node/context';
6
+ import { FaaSEventListener } from '@celljs/faas-adapter/lib/node/event/event-protocol';
7
+ import * as express from 'express';
8
+ import * as proxy from '@webserverless/fc-express';
9
+
10
+ let listeners: FaaSEventListener<any, void>[];
11
+
12
+ const app = express();
13
+
14
+ const server = new proxy.Server(app);
15
+
16
+ async function start() {
17
+ const c = await container;
18
+ ContainerProvider.set(c);
19
+ app.all('*', async (req: any, res: any) => {
20
+ const dispatcher = c.get<Dispatcher<Context>>(Dispatcher);
21
+ const httpContext = new Context(req, res);
22
+ Context.run(() => dispatcher.dispatch(httpContext));
23
+ });
24
+ listeners = c.getAll<FaaSEventListener<any, void>>(FaaSEventListener);
25
+
26
+ return c.get<Application>(Application).start();
27
+ }
28
+
29
+ const startPromise = start();
30
+
31
+ export async function handler(event: string, context: any, callback: any) {
32
+ process.env.ALIBABA_ACCOUNT_ID = context.accountId;
33
+ process.env.ALIBABA_ACCESS_KEY_ID = context.credentials?.accessKeyId;
34
+ process.env.ALIBABA_ACCESS_KEY_SECRET = context.credentials?.accessKeySecret;
35
+ process.env.ALIBABA_SECURITY_TOKEN = context.credentials?.securityToken;
36
+ process.env.ALIBABA_REQUEST_ID = context.requestId;
37
+ process.env.ALIBABA_REGION = context.region;
38
+ process.env.IGNORE_EVENT_HEADER = 'true';
39
+ process.env.IGNORE_CONTEXT_HEADER = 'true';
40
+ try {
41
+ await startPromise;
42
+ await Promise.all(listeners.map(l => l.onTrigger(event)));
43
+ } catch (error) {
44
+ callback(undefined, error);
45
+ }
46
+ server.proxy(event, context, callback);
47
+ }
@@ -0,0 +1,20 @@
1
+ import { DefaultCredentialsProvider } from '@celljs/cloud/lib/node';
2
+ import { Component } from '@celljs/core';
3
+ import { Credentials, CredentialsProvider } from '@celljs/cloud';
4
+
5
+ @Component({ id: CredentialsProvider, rebind: true })
6
+ export class FaaSCredentialsProvider extends DefaultCredentialsProvider {
7
+
8
+ override async provide(): Promise<Credentials | undefined> {
9
+ const credentials = await super.provide();
10
+ if (credentials) {
11
+ return credentials;
12
+ }
13
+ return {
14
+ accessKeyId: process.env.ALIBABA_ACCESS_KEY_ID!,
15
+ accessKeySecret: process.env.ALIBABA_ACCESS_KEY_SECRET!,
16
+ token: process.env.ALIBABA_SECURITY_TOKEN
17
+ };
18
+ }
19
+
20
+ }
@@ -0,0 +1,33 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Application } from '@celljs/core/lib/common/application/application-protocol';
3
+ import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
4
+ import { FaaSEventListener } from '@celljs/faas-adapter/lib/node/event/event-protocol';
5
+
6
+ let listeners: FaaSEventListener<any, any>[];
7
+
8
+ async function start() {
9
+ const c = await container;
10
+ ContainerProvider.set(c);
11
+ await c.get<Application>(Application).start();
12
+ listeners = c.getAll<FaaSEventListener<any, any>>(FaaSEventListener);
13
+ }
14
+
15
+ const startPromise = start();
16
+
17
+ export async function handler(event: string, context: any, callback: any) {
18
+ process.env.ALIBABA_ACCOUNT_ID = context.accountId;
19
+ process.env.ALIBABA_ACCESS_KEY_ID = context.credentials?.accessKeyId;
20
+ process.env.ALIBABA_ACCESS_KEY_SECRET = context.credentials?.accessKeySecret;
21
+ process.env.ALIBABA_SECURITY_TOKEN = context.credentials?.securityToken;
22
+ process.env.ALIBABA_REQUEST_ID = context.requestId;
23
+ process.env.ALIBABA_REGION = context.region;
24
+ try {
25
+ await startPromise;
26
+ let result = await Promise.all(listeners.map(l => l.onTrigger(event)));
27
+ result = result.filter(item => !!item);
28
+ callback(result.length === 1 ? result[0] : result);
29
+ } catch (error) {
30
+ callback(undefined, error);
31
+ }
32
+
33
+ }
@@ -0,0 +1,43 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Application } from '@celljs/core/lib/common/application/application-protocol';
3
+ import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
4
+ import { Dispatcher } from '@celljs/web/lib/node/dispatcher/dispatcher-protocol';
5
+ import { Context } from '@celljs/web/lib/node/context';
6
+ import * as express from 'express';
7
+
8
+ const app = express();
9
+
10
+ const port = 9000;
11
+
12
+ async function bootstrap() {
13
+ try {
14
+ const c = await container;
15
+ ContainerProvider.set(c);
16
+ await c.get<Application>(Application).start();
17
+ app.all('*', async (req: any, res: any) => {
18
+ process.env.ALIBABA_ACCOUNT_ID = req.get('x-fc-account-id');
19
+ process.env.ALIBABA_ACCESS_KEY_ID = req.get('x-fc-access-key-id');
20
+ process.env.ALIBABA_ACCESS_KEY_SECRET = req.get('x-fc-access-key-secret');
21
+ process.env.ALIBABA_SECURITY_TOKEN = req.get('x-fc-security-token');
22
+ process.env.ALIBABA_REQUEST_ID = req.get('x-fc-request-id');
23
+ process.env.ALIBABA_REGION = req.get('x-fc-region');
24
+ const dispatcher = c.get<Dispatcher<Context>>(Dispatcher);
25
+ const httpContext = new Context(req, res);
26
+ Context.run(() => dispatcher.dispatch(httpContext));
27
+ });
28
+ const server = app.listen(port, '0.0.0.0');
29
+ server.timeout = 0;
30
+ server.keepAliveTimeout = 0;
31
+ console.log(`serve ${port}`);
32
+ } catch (error) {
33
+ app.all('*', async (req: any, res: any) => {
34
+ res.status = 500;
35
+ res.send(error);
36
+ });
37
+ const server = app.listen(port, '0.0.0.0');
38
+ server.timeout = 0;
39
+ server.keepAliveTimeout = 0;
40
+ }
41
+ }
42
+
43
+ bootstrap();
@@ -0,0 +1,3 @@
1
+ export * from './account-provider';
2
+ export * from './credentials-provider';
3
+ export * from './regin-provider';
@@ -0,0 +1,4 @@
1
+ import { autoBind } from '@celljs/core';
2
+ import './index';
3
+
4
+ export default autoBind();
@@ -0,0 +1,15 @@
1
+ import { DefaultRegionProvider } from '@celljs/cloud/lib/node';
2
+ import { Component } from '@celljs/core';
3
+ import { RegionProvider } from '@celljs/cloud';
4
+
5
+ @Component({ id: RegionProvider, rebind: true })
6
+ export class FaaSRegionProvider extends DefaultRegionProvider {
7
+
8
+ override async provide(): Promise<string | undefined> {
9
+ const region = await super.provide();
10
+ if (region) {
11
+ return region;
12
+ }
13
+ return process.env.ALIBABA_REGION;
14
+ }
15
+ }
@@ -0,0 +1,40 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Application } from '@celljs/core/lib/common/application/application-protocol';
3
+ import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
4
+ import { Dispatcher } from '@celljs/web/lib/node/dispatcher/dispatcher-protocol';
5
+ import { Context } from '@celljs/web/lib/node/context';
6
+ import * as express from 'express';
7
+ import * as proxy from '@webserverless/fc-express';
8
+ const getRawBody = require('raw-body');
9
+
10
+ const app = express();
11
+
12
+ const server = new proxy.Server(app);
13
+
14
+ async function start() {
15
+ const c = await container;
16
+ ContainerProvider.set(c);
17
+ app.all('*', async (req: any, res: any) => {
18
+ const dispatcher = c.get<Dispatcher<Context>>(Dispatcher);
19
+ const httpContext = new Context(req, res);
20
+ Context.run(() => dispatcher.dispatch(httpContext));
21
+ });
22
+
23
+ return c.get<Application>(Application).start();
24
+ }
25
+
26
+ const startPromise = start();
27
+
28
+ export async function handler(req: any, res: any, context: any) {
29
+ process.env.ALIBABA_ACCOUNT_ID = context.accountId;
30
+ process.env.ALIBABA_ACCESS_KEY_ID = context.credentials?.accessKeyId;
31
+ process.env.ALIBABA_ACCESS_KEY_SECRET = context.credentials?.accessKeySecret;
32
+ process.env.ALIBABA_SECURITY_TOKEN = context.credentials?.securityToken;
33
+ process.env.ALIBABA_REQUEST_ID = context.requestId;
34
+ process.env.ALIBABA_REGION = context.region;
35
+ process.env.IGNORE_EVENT_HEADER = 'true';
36
+ process.env.IGNORE_CONTEXT_HEADER = 'true';
37
+ req.body = await getRawBody(req);
38
+ await startPromise;
39
+ server.httpProxy(req, res, context);
40
+ }
@@ -0,0 +1,36 @@
1
+ import { container } from '@celljs/core/lib/common/container/dynamic-container';
2
+ import { Application } from '@celljs/core/lib/common/application/application-protocol';
3
+ import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
4
+ import { Clock } from '@celljs/faas-adapter/lib/node/timer/timer-protocol';
5
+ import { FaaSEventListener } from '@celljs/faas-adapter/lib/node/event/event-protocol';
6
+
7
+ let clock: Clock;
8
+ let listeners: FaaSEventListener<any, void>[];
9
+
10
+ async function start() {
11
+ const c = await container;
12
+ ContainerProvider.set(c);
13
+ await c.get<Application>(Application).start();
14
+ clock = c.get<Clock>(Clock);
15
+ listeners = c.getAll<FaaSEventListener<any, void>>(FaaSEventListener);
16
+ }
17
+
18
+ const startPromise = start();
19
+
20
+ export async function handler(event: string, context: any, callback: any) {
21
+ process.env.ALIBABA_ACCOUNT_ID = context.accountId;
22
+ process.env.ALIBABA_ACCESS_KEY_ID = context.credentials?.accessKeyId;
23
+ process.env.ALIBABA_ACCESS_KEY_SECRET = context.credentials?.accessKeySecret;
24
+ process.env.ALIBABA_SECURITY_TOKEN = context.credentials?.securityToken;
25
+ process.env.ALIBABA_REQUEST_ID = context.requestId;
26
+ process.env.ALIBABA_REGION = context.region;
27
+ try {
28
+ await startPromise;
29
+ await Promise.all(listeners.map(l => l.onTrigger(event)));
30
+ await clock.tick();
31
+ callback();
32
+ } catch (error) {
33
+ callback(undefined, error);
34
+ }
35
+
36
+ }
@@ -0,0 +1,4 @@
1
+ describe('fc adapter package', () => {
2
+
3
+ it('support code coverage statistics', () => {});
4
+ });