@midwayjs/fc-starter 3.19.2 → 4.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -8
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -18,7 +18,6 @@ exports.BootstrapStarter = void 0;
|
|
|
18
18
|
const core_1 = require("@midwayjs/core");
|
|
19
19
|
const faas_1 = require("@midwayjs/faas");
|
|
20
20
|
const getRawBody = require("raw-body");
|
|
21
|
-
const async_hooks_context_manager_1 = require("@midwayjs/async-hooks-context-manager");
|
|
22
21
|
const mock_1 = require("./mock");
|
|
23
22
|
__exportStar(require("./mock"), exports);
|
|
24
23
|
__exportStar(require("./interface"), exports);
|
|
@@ -65,7 +64,6 @@ class BootstrapStarter extends faas_1.AbstractBootstrapStarter {
|
|
|
65
64
|
applicationAdapter,
|
|
66
65
|
},
|
|
67
66
|
},
|
|
68
|
-
asyncContextManager: (0, async_hooks_context_manager_1.createContextManager)(),
|
|
69
67
|
...this.options,
|
|
70
68
|
});
|
|
71
69
|
const handlerWrapper = (0, core_1.wrapAsync)(this.onRequest.bind(this));
|
|
@@ -74,7 +72,6 @@ class BootstrapStarter extends faas_1.AbstractBootstrapStarter {
|
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
74
|
async onRequest(event, context, oldContext) {
|
|
77
|
-
var _a, _b, _c, _d;
|
|
78
75
|
const isHTTPMode = event.constructor.name === 'IncomingMessage' ||
|
|
79
76
|
event.constructor.name === 'EventEmitter';
|
|
80
77
|
const isApiGateway = event &&
|
|
@@ -82,16 +79,16 @@ class BootstrapStarter extends faas_1.AbstractBootstrapStarter {
|
|
|
82
79
|
'queryParameters' in event &&
|
|
83
80
|
'httpMethod' in event;
|
|
84
81
|
if (isHTTPMode) {
|
|
85
|
-
if (!
|
|
82
|
+
if (!oldContext.logger?.info) {
|
|
86
83
|
oldContext.logger = console;
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
else {
|
|
90
|
-
if (!
|
|
87
|
+
if (!context.logger?.info) {
|
|
91
88
|
context.logger = console;
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
|
-
let handlerName =
|
|
91
|
+
let handlerName = oldContext?.function.handler || context.function.handler;
|
|
95
92
|
// 聚合部署的情况
|
|
96
93
|
if (this.options.aggregationHandlerName) {
|
|
97
94
|
if (this.options.handlerNameMapping) {
|
|
@@ -200,12 +197,12 @@ class BootstrapStarter extends faas_1.AbstractBootstrapStarter {
|
|
|
200
197
|
res.setHeader('content-type', 'text/plain');
|
|
201
198
|
}
|
|
202
199
|
if (res.send) {
|
|
203
|
-
res.setStatusCode(
|
|
200
|
+
res.setStatusCode(err.status ?? 500);
|
|
204
201
|
res.send(isOutputError() ? err.stack : 'Internal Server Error');
|
|
205
202
|
}
|
|
206
203
|
return {
|
|
207
204
|
isBase64Encoded: false,
|
|
208
|
-
statusCode:
|
|
205
|
+
statusCode: err.status ?? 500,
|
|
209
206
|
headers: {},
|
|
210
207
|
body: isOutputError() ? err.stack : 'Internal Server Error',
|
|
211
208
|
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/fc-starter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@midwayjs/
|
|
8
|
-
"@midwayjs/faas": "^3.19.2",
|
|
7
|
+
"@midwayjs/faas": "^4.0.0-alpha.1",
|
|
9
8
|
"raw-body": "2.5.2"
|
|
10
9
|
},
|
|
11
10
|
"devDependencies": {
|
|
12
|
-
"@midwayjs/core": "^
|
|
11
|
+
"@midwayjs/core": "^4.0.0-alpha.1"
|
|
13
12
|
},
|
|
14
13
|
"engines": {
|
|
15
14
|
"node": ">=12"
|
|
@@ -21,13 +20,13 @@
|
|
|
21
20
|
],
|
|
22
21
|
"scripts": {
|
|
23
22
|
"build": "tsc",
|
|
24
|
-
"test": "node
|
|
25
|
-
"cov": "node
|
|
23
|
+
"test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
|
|
24
|
+
"cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit"
|
|
26
25
|
},
|
|
27
26
|
"repository": {
|
|
28
27
|
"type": "git",
|
|
29
28
|
"url": "git@github.com:midwayjs/midway.git"
|
|
30
29
|
},
|
|
31
30
|
"license": "MIT",
|
|
32
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
|
|
33
32
|
}
|