@celljs/scf-adapter 4.0.0 → 4.2.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/esm/node/api-gateway-application-entry.js +6 -10
- package/esm/node/api-gateway-application-entry.js.map +1 -1
- package/esm/node/http-application-entry.js +13 -19
- package/esm/node/http-application-entry.js.map +1 -1
- package/esm/node/module.d.ts +1 -1
- package/lib/node/api-gateway-application-entry.d.ts.map +1 -1
- package/lib/node/api-gateway-application-entry.js +6 -13
- package/lib/node/api-gateway-application-entry.js.map +1 -1
- package/lib/node/http-application-entry.js +13 -22
- package/lib/node/http-application-entry.js.map +1 -1
- package/lib/node/module.d.ts +1 -1
- package/package.json +9 -8
- package/src/node/api-gateway-application-entry.ts +7 -12
- package/src/node/http-application-entry.ts +13 -19
|
@@ -13,25 +13,21 @@ import { container } from '@celljs/core/lib/common/container/dynamic-container';
|
|
|
13
13
|
import { Application } from '@celljs/core/lib/common/application/application-protocol';
|
|
14
14
|
import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
|
|
15
15
|
import { FaaSUtils } from '@celljs/faas-adapter/lib/node/utils';
|
|
16
|
-
import {
|
|
17
|
-
import { Context } from '@celljs/web/lib/node/context';
|
|
16
|
+
import { HttpServerUtil } from '@celljs/web/lib/node/server';
|
|
18
17
|
import { FaaSEventListener } from '@celljs/faas-adapter/lib/node/event/event-protocol';
|
|
19
|
-
import express from 'express';
|
|
20
18
|
const { createServer, proxy } = require('tencent-serverless-http');
|
|
21
|
-
|
|
19
|
+
/** Set once the application has started; the proxy only passes requests on after that. */
|
|
20
|
+
let handle;
|
|
21
|
+
const app = (req, res) => handle(req, res);
|
|
22
22
|
const server = createServer(app);
|
|
23
23
|
let listeners;
|
|
24
24
|
function start() {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
const c = yield container;
|
|
27
27
|
ContainerProvider.set(c);
|
|
28
|
-
app.all('*', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const dispatcher = c.get(Dispatcher);
|
|
30
|
-
const httpContext = new Context(req, res);
|
|
31
|
-
Context.run(() => dispatcher.dispatch(httpContext));
|
|
32
|
-
}));
|
|
33
28
|
listeners = c.getAll(FaaSEventListener);
|
|
34
|
-
|
|
29
|
+
yield c.get(Application).start();
|
|
30
|
+
handle = HttpServerUtil.createHandler(c);
|
|
35
31
|
});
|
|
36
32
|
}
|
|
37
33
|
const startPromise = start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-gateway-application-entry.js","sourceRoot":"","sources":["../../src/node/api-gateway-application-entry.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"api-gateway-application-entry.js","sourceRoot":"","sources":["../../src/node/api-gateway-application-entry.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAmB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AACvF,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAEnE,0FAA0F;AAC1F,IAAI,MAAuB,CAAC;AAE5B,MAAM,GAAG,GAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAE5D,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AAEjC,IAAI,SAAyC,CAAC;AAE9C,SAAe,KAAK;;QAChB,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC;QAC1B,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,SAAS,GAAG,CAAC,CAAC,MAAM,CAA+B,iBAAiB,CAAC,CAAC;QACtE,MAAM,CAAC,CAAC,GAAG,CAAc,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC;QAC9C,MAAM,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;CAAA;AAED,MAAM,YAAY,GAAG,KAAK,EAAE,CAAC;AAE7B,MAAM,UAAgB,OAAO,CAAC,KAAa,EAAE,OAAY;;QACrD,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,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAC9D,OAAO,CAAC,8BAA8B,GAAG,SAAS,CAAC,iCAAiC,EAAE,CAAC;QACvF,OAAO,MAAM,CAAC,OAAO,CAAC;IAC1B,CAAC;CAAA"}
|
|
@@ -10,35 +10,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { container } from '@celljs/core/lib/common/container/dynamic-container';
|
|
11
11
|
import { Application } from '@celljs/core/lib/common/application/application-protocol';
|
|
12
12
|
import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
|
|
13
|
-
import {
|
|
14
|
-
import { Context } from '@celljs/web/lib/node/context';
|
|
15
|
-
import express from 'express';
|
|
16
|
-
const app = express();
|
|
13
|
+
import { HttpServerUtil } from '@celljs/web/lib/node/server';
|
|
17
14
|
const port = 9000;
|
|
15
|
+
function listen(handler) {
|
|
16
|
+
const server = HttpServerUtil.createHttpServer(handler).listen(port, '0.0.0.0');
|
|
17
|
+
server.timeout = 0;
|
|
18
|
+
server.keepAliveTimeout = 0;
|
|
19
|
+
return server;
|
|
20
|
+
}
|
|
18
21
|
function bootstrap() {
|
|
19
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
23
|
try {
|
|
21
24
|
const c = yield container;
|
|
22
25
|
ContainerProvider.set(c);
|
|
23
26
|
yield c.get(Application).start();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const httpContext = new Context(req, res);
|
|
27
|
-
Context.run(() => dispatcher.dispatch(httpContext));
|
|
28
|
-
}));
|
|
29
|
-
const server = app.listen(port, '0.0.0.0');
|
|
30
|
-
server.timeout = 0;
|
|
31
|
-
server.keepAliveTimeout = 0;
|
|
27
|
+
const handle = HttpServerUtil.createHandler(c);
|
|
28
|
+
listen(handle);
|
|
32
29
|
console.log(`serve ${port}`);
|
|
33
30
|
}
|
|
34
31
|
catch (error) {
|
|
35
|
-
|
|
36
|
-
res.
|
|
37
|
-
res.
|
|
38
|
-
})
|
|
39
|
-
const server = app.listen(port, '0.0.0.0');
|
|
40
|
-
server.timeout = 0;
|
|
41
|
-
server.keepAliveTimeout = 0;
|
|
32
|
+
listen((req, res) => {
|
|
33
|
+
res.statusCode = 500;
|
|
34
|
+
res.end(String(error));
|
|
35
|
+
});
|
|
42
36
|
}
|
|
43
37
|
});
|
|
44
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-application-entry.js","sourceRoot":"","sources":["../../src/node/http-application-entry.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AACzF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"http-application-entry.js","sourceRoot":"","sources":["../../src/node/http-application-entry.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AACzF,OAAO,EAAE,cAAc,EAAmB,MAAM,6BAA6B,CAAC;AAE9E,MAAM,IAAI,GAAG,IAAI,CAAC;AAElB,SAAS,MAAM,CAAC,OAAwB;IACpC,MAAM,MAAM,GAAG,cAAc,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAChF,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAe,SAAS;;QACpB,IAAI,CAAC;YACD,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC;YAC1B,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,CAAC,CAAC,GAAG,CAAc,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC;YAC9C,MAAM,MAAM,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YAC/C,MAAM,CAAC,MAAM,CAAC,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;gBAChB,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;gBACrB,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CAAA;AAED,SAAS,EAAE,CAAC"}
|
package/esm/node/module.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-gateway-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/api-gateway-application-entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-gateway-application-entry.d.ts","sourceRoot":"","sources":["../../src/node/api-gateway-application-entry.ts"],"names":[],"mappings":"AA2BA,wBAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,gBAMxD"}
|
|
@@ -8,34 +8,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.handler = handler;
|
|
16
13
|
const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
|
|
17
14
|
const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
|
|
18
15
|
const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
|
|
19
16
|
const utils_1 = require("@celljs/faas-adapter/lib/node/utils");
|
|
20
|
-
const
|
|
21
|
-
const context_1 = require("@celljs/web/lib/node/context");
|
|
17
|
+
const server_1 = require("@celljs/web/lib/node/server");
|
|
22
18
|
const event_protocol_1 = require("@celljs/faas-adapter/lib/node/event/event-protocol");
|
|
23
|
-
const express_1 = __importDefault(require("express"));
|
|
24
19
|
const { createServer, proxy } = require('tencent-serverless-http');
|
|
25
|
-
|
|
20
|
+
/** Set once the application has started; the proxy only passes requests on after that. */
|
|
21
|
+
let handle;
|
|
22
|
+
const app = (req, res) => handle(req, res);
|
|
26
23
|
const server = createServer(app);
|
|
27
24
|
let listeners;
|
|
28
25
|
function start() {
|
|
29
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
27
|
const c = yield dynamic_container_1.container;
|
|
31
28
|
container_provider_1.ContainerProvider.set(c);
|
|
32
|
-
app.all('*', (req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const dispatcher = c.get(dispatcher_protocol_1.Dispatcher);
|
|
34
|
-
const httpContext = new context_1.Context(req, res);
|
|
35
|
-
context_1.Context.run(() => dispatcher.dispatch(httpContext));
|
|
36
|
-
}));
|
|
37
29
|
listeners = c.getAll(event_protocol_1.FaaSEventListener);
|
|
38
|
-
|
|
30
|
+
yield c.get(application_protocol_1.Application).start();
|
|
31
|
+
handle = server_1.HttpServerUtil.createHandler(c);
|
|
39
32
|
});
|
|
40
33
|
}
|
|
41
34
|
const startPromise = start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-gateway-application-entry.js","sourceRoot":"","sources":["../../src/node/api-gateway-application-entry.ts"],"names":[],"mappings":"
|
|
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,+DAAgE;AAChE,wDAA8E;AAC9E,uFAAuF;AACvF,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAEnE,0FAA0F;AAC1F,IAAI,MAAuB,CAAC;AAE5B,MAAM,GAAG,GAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAE5D,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AAEjC,IAAI,SAAyC,CAAC;AAE9C,SAAe,KAAK;;QAChB,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;QAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,SAAS,GAAG,CAAC,CAAC,MAAM,CAA+B,kCAAiB,CAAC,CAAC;QACtE,MAAM,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;QAC9C,MAAM,GAAG,uBAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;CAAA;AAED,MAAM,YAAY,GAAG,KAAK,EAAE,CAAC;AAE7B,iBAA8B,KAAa,EAAE,OAAY;;QACrD,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,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAC9D,OAAO,CAAC,8BAA8B,GAAG,iBAAS,CAAC,iCAAiC,EAAE,CAAC;QACvF,OAAO,MAAM,CAAC,OAAO,CAAC;IAC1B,CAAC;CAAA"}
|
|
@@ -8,42 +8,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
const dynamic_container_1 = require("@celljs/core/lib/common/container/dynamic-container");
|
|
16
13
|
const application_protocol_1 = require("@celljs/core/lib/common/application/application-protocol");
|
|
17
14
|
const container_provider_1 = require("@celljs/core/lib/common/container/container-provider");
|
|
18
|
-
const
|
|
19
|
-
const context_1 = require("@celljs/web/lib/node/context");
|
|
20
|
-
const express_1 = __importDefault(require("express"));
|
|
21
|
-
const app = (0, express_1.default)();
|
|
15
|
+
const server_1 = require("@celljs/web/lib/node/server");
|
|
22
16
|
const port = 9000;
|
|
17
|
+
function listen(handler) {
|
|
18
|
+
const server = server_1.HttpServerUtil.createHttpServer(handler).listen(port, '0.0.0.0');
|
|
19
|
+
server.timeout = 0;
|
|
20
|
+
server.keepAliveTimeout = 0;
|
|
21
|
+
return server;
|
|
22
|
+
}
|
|
23
23
|
function bootstrap() {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
try {
|
|
26
26
|
const c = yield dynamic_container_1.container;
|
|
27
27
|
container_provider_1.ContainerProvider.set(c);
|
|
28
28
|
yield c.get(application_protocol_1.Application).start();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const httpContext = new context_1.Context(req, res);
|
|
32
|
-
context_1.Context.run(() => dispatcher.dispatch(httpContext));
|
|
33
|
-
}));
|
|
34
|
-
const server = app.listen(port, '0.0.0.0');
|
|
35
|
-
server.timeout = 0;
|
|
36
|
-
server.keepAliveTimeout = 0;
|
|
29
|
+
const handle = server_1.HttpServerUtil.createHandler(c);
|
|
30
|
+
listen(handle);
|
|
37
31
|
console.log(`serve ${port}`);
|
|
38
32
|
}
|
|
39
33
|
catch (error) {
|
|
40
|
-
|
|
41
|
-
res.
|
|
42
|
-
res.
|
|
43
|
-
})
|
|
44
|
-
const server = app.listen(port, '0.0.0.0');
|
|
45
|
-
server.timeout = 0;
|
|
46
|
-
server.keepAliveTimeout = 0;
|
|
34
|
+
listen((req, res) => {
|
|
35
|
+
res.statusCode = 500;
|
|
36
|
+
res.end(String(error));
|
|
37
|
+
});
|
|
47
38
|
}
|
|
48
39
|
});
|
|
49
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-application-entry.js","sourceRoot":"","sources":["../../src/node/http-application-entry.ts"],"names":[],"mappings":"
|
|
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,wDAA8E;AAE9E,MAAM,IAAI,GAAG,IAAI,CAAC;AAElB,SAAS,MAAM,CAAC,OAAwB;IACpC,MAAM,MAAM,GAAG,uBAAc,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAChF,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAe,SAAS;;QACpB,IAAI,CAAC;YACD,MAAM,CAAC,GAAG,MAAM,6BAAS,CAAC;YAC1B,sCAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,CAAC,CAAC,GAAG,CAAc,kCAAW,CAAC,CAAC,KAAK,EAAE,CAAC;YAC9C,MAAM,MAAM,GAAG,uBAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YAC/C,MAAM,CAAC,MAAM,CAAC,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;gBAChB,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;gBACrB,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CAAA;AAED,SAAS,EAAE,CAAC"}
|
package/lib/node/module.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/scf-adapter",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cell-component"
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"url": "https://github.com/cellbang/cell.git"
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18.0.0"
|
|
19
|
+
},
|
|
17
20
|
"main": "lib/node/index.js",
|
|
18
21
|
"typings": "lib/node/index.d.ts",
|
|
19
22
|
"files": [
|
|
@@ -34,13 +37,11 @@
|
|
|
34
37
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
35
38
|
},
|
|
36
39
|
"dependencies": {
|
|
37
|
-
"@celljs/cloud": "4.
|
|
38
|
-
"@celljs/core": "4.
|
|
39
|
-
"@celljs/faas-adapter": "4.
|
|
40
|
-
"@celljs/web": "4.
|
|
41
|
-
"
|
|
42
|
-
"tencent-serverless-http": "^1.3.2",
|
|
43
|
-
"tslib": "^2.8.0"
|
|
40
|
+
"@celljs/cloud": "4.2.0",
|
|
41
|
+
"@celljs/core": "4.2.0",
|
|
42
|
+
"@celljs/faas-adapter": "4.2.0",
|
|
43
|
+
"@celljs/web": "4.2.0",
|
|
44
|
+
"tencent-serverless-http": "^1.3.2"
|
|
44
45
|
},
|
|
45
46
|
"publishConfig": {
|
|
46
47
|
"access": "public"
|
|
@@ -2,13 +2,14 @@ import { container } from '@celljs/core/lib/common/container/dynamic-container';
|
|
|
2
2
|
import { Application } from '@celljs/core/lib/common/application/application-protocol';
|
|
3
3
|
import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
|
|
4
4
|
import { FaaSUtils } from '@celljs/faas-adapter/lib/node/utils';
|
|
5
|
-
import {
|
|
6
|
-
import { Context } from '@celljs/web/lib/node/context';
|
|
5
|
+
import { HttpServerUtil, RequestListener } from '@celljs/web/lib/node/server';
|
|
7
6
|
import { FaaSEventListener } from '@celljs/faas-adapter/lib/node/event/event-protocol';
|
|
8
|
-
import express from 'express';
|
|
9
7
|
const { createServer, proxy } = require('tencent-serverless-http');
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
/** Set once the application has started; the proxy only passes requests on after that. */
|
|
10
|
+
let handle: RequestListener;
|
|
11
|
+
|
|
12
|
+
const app: RequestListener = (req, res) => handle(req, res);
|
|
12
13
|
|
|
13
14
|
const server = createServer(app);
|
|
14
15
|
|
|
@@ -17,15 +18,9 @@ let listeners: FaaSEventListener<any, void>[];
|
|
|
17
18
|
async function start() {
|
|
18
19
|
const c = await container;
|
|
19
20
|
ContainerProvider.set(c);
|
|
20
|
-
app.all('*', async (req: any, res: any) => {
|
|
21
|
-
const dispatcher = c.get<Dispatcher<Context>>(Dispatcher);
|
|
22
|
-
const httpContext = new Context(req, res);
|
|
23
|
-
Context.run(() => dispatcher.dispatch(httpContext));
|
|
24
|
-
});
|
|
25
|
-
|
|
26
21
|
listeners = c.getAll<FaaSEventListener<any, void>>(FaaSEventListener);
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
await c.get<Application>(Application).start();
|
|
23
|
+
handle = HttpServerUtil.createHandler(c);
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
const startPromise = start();
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
import { container } from '@celljs/core/lib/common/container/dynamic-container';
|
|
2
2
|
import { Application } from '@celljs/core/lib/common/application/application-protocol';
|
|
3
3
|
import { ContainerProvider } from '@celljs/core/lib/common/container/container-provider';
|
|
4
|
-
import {
|
|
5
|
-
import { Context } from '@celljs/web/lib/node/context';
|
|
6
|
-
import express from 'express';
|
|
7
|
-
|
|
8
|
-
const app = express();
|
|
4
|
+
import { HttpServerUtil, RequestListener } from '@celljs/web/lib/node/server';
|
|
9
5
|
|
|
10
6
|
const port = 9000;
|
|
11
7
|
|
|
8
|
+
function listen(handler: RequestListener) {
|
|
9
|
+
const server = HttpServerUtil.createHttpServer(handler).listen(port, '0.0.0.0');
|
|
10
|
+
server.timeout = 0;
|
|
11
|
+
server.keepAliveTimeout = 0;
|
|
12
|
+
return server;
|
|
13
|
+
}
|
|
14
|
+
|
|
12
15
|
async function bootstrap() {
|
|
13
16
|
try {
|
|
14
17
|
const c = await container;
|
|
15
18
|
ContainerProvider.set(c);
|
|
16
19
|
await c.get<Application>(Application).start();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const httpContext = new Context(req, res);
|
|
20
|
-
Context.run(() => dispatcher.dispatch(httpContext));
|
|
21
|
-
});
|
|
22
|
-
const server = app.listen(port, '0.0.0.0');
|
|
23
|
-
server.timeout = 0;
|
|
24
|
-
server.keepAliveTimeout = 0;
|
|
20
|
+
const handle = HttpServerUtil.createHandler(c);
|
|
21
|
+
listen(handle);
|
|
25
22
|
console.log(`serve ${port}`);
|
|
26
23
|
} catch (error) {
|
|
27
|
-
|
|
28
|
-
res.
|
|
29
|
-
res.
|
|
24
|
+
listen((req, res) => {
|
|
25
|
+
res.statusCode = 500;
|
|
26
|
+
res.end(String(error));
|
|
30
27
|
});
|
|
31
|
-
const server = app.listen(port, '0.0.0.0');
|
|
32
|
-
server.timeout = 0;
|
|
33
|
-
server.keepAliveTimeout = 0;
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
30
|
|