@midwayjs/fc-starter 3.8.0 → 3.10.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/dist/index.d.ts +27 -0
- package/dist/index.js +12 -14
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { AbstractBootstrapStarter, FC } from '@midwayjs/faas';
|
|
2
3
|
export * from './mock';
|
|
3
4
|
export declare class BootstrapStarter extends AbstractBootstrapStarter {
|
|
@@ -5,5 +6,31 @@ export declare class BootstrapStarter extends AbstractBootstrapStarter {
|
|
|
5
6
|
onInit(context: FC.InitializeContext, exports: any): Promise<void>;
|
|
6
7
|
onRequest(event: any, context: any, oldContext: any): Promise<any>;
|
|
7
8
|
onClose(): Promise<void>;
|
|
9
|
+
protected createDefaultMockContext(): {
|
|
10
|
+
requestId: string;
|
|
11
|
+
credentials: {
|
|
12
|
+
accessKeyId: string;
|
|
13
|
+
accessKeySecret: string;
|
|
14
|
+
securityToken: string;
|
|
15
|
+
};
|
|
16
|
+
function: {
|
|
17
|
+
name: string;
|
|
18
|
+
handler: string;
|
|
19
|
+
memory: number;
|
|
20
|
+
timeout: number;
|
|
21
|
+
initializer: string;
|
|
22
|
+
initializationTimeout: number;
|
|
23
|
+
};
|
|
24
|
+
service: {
|
|
25
|
+
name: string;
|
|
26
|
+
logProject: string;
|
|
27
|
+
logStore: string;
|
|
28
|
+
qualifier: string;
|
|
29
|
+
versionId: string;
|
|
30
|
+
};
|
|
31
|
+
region: string;
|
|
32
|
+
accountId: string;
|
|
33
|
+
logger: Console;
|
|
34
|
+
};
|
|
8
35
|
}
|
|
9
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -49,7 +49,7 @@ class BootstrapStarter extends faas_1.AbstractBootstrapStarter {
|
|
|
49
49
|
}
|
|
50
50
|
return exports;
|
|
51
51
|
}
|
|
52
|
-
async onInit(context =
|
|
52
|
+
async onInit(context = this.createDefaultMockContext(), exports) {
|
|
53
53
|
const applicationAdapter = {
|
|
54
54
|
getFunctionName() {
|
|
55
55
|
return context.function.name;
|
|
@@ -90,6 +90,14 @@ class BootstrapStarter extends faas_1.AbstractBootstrapStarter {
|
|
|
90
90
|
context.logger = console;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
let handlerName = (oldContext === null || oldContext === void 0 ? void 0 : oldContext.function.handler) || context.function.handler;
|
|
94
|
+
// 聚合部署的情况
|
|
95
|
+
if (this.options.aggregationHandlerName) {
|
|
96
|
+
if (this.options.handlerNameMapping) {
|
|
97
|
+
[handlerName, event, context, oldContext] =
|
|
98
|
+
this.options.handlerNameMapping(handlerName, event, context, oldContext);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
93
101
|
let ctx;
|
|
94
102
|
if (isHTTPMode) {
|
|
95
103
|
event.getOriginContext = () => {
|
|
@@ -126,22 +134,9 @@ class BootstrapStarter extends faas_1.AbstractBootstrapStarter {
|
|
|
126
134
|
logger: context.logger,
|
|
127
135
|
};
|
|
128
136
|
}
|
|
129
|
-
let handlerName = (oldContext === null || oldContext === void 0 ? void 0 : oldContext.function.handler) || context.function.handler;
|
|
130
|
-
// 聚合部署的情况
|
|
131
|
-
if (this.options.aggregationHandlerName) {
|
|
132
|
-
if (this.options.handlerNameMapping) {
|
|
133
|
-
[handlerName, event, context, oldContext] =
|
|
134
|
-
this.options.handlerNameMapping(handlerName, event, context, oldContext);
|
|
135
|
-
}
|
|
136
|
-
else if (isHTTPMode) {
|
|
137
|
-
handlerName = ctx.path;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
137
|
try {
|
|
141
138
|
const result = await this.framework.invokeTriggerFunction(ctx, handlerName, {
|
|
142
139
|
isHttpFunction: isHTTPMode || isApiGateway,
|
|
143
|
-
originEvent: event,
|
|
144
|
-
originContext: context,
|
|
145
140
|
});
|
|
146
141
|
if (isHTTPMode || isApiGateway) {
|
|
147
142
|
const { isBase64Encoded, statusCode, headers, body } = result;
|
|
@@ -216,6 +211,9 @@ class BootstrapStarter extends faas_1.AbstractBootstrapStarter {
|
|
|
216
211
|
}
|
|
217
212
|
}
|
|
218
213
|
async onClose() { }
|
|
214
|
+
createDefaultMockContext() {
|
|
215
|
+
return (0, mock_1.mockContext)();
|
|
216
|
+
}
|
|
219
217
|
}
|
|
220
218
|
exports.BootstrapStarter = BootstrapStarter;
|
|
221
219
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/fc-starter",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@midwayjs/async-hooks-context-manager": "^3.
|
|
8
|
-
"@midwayjs/faas": "^3.
|
|
7
|
+
"@midwayjs/async-hooks-context-manager": "^3.10.0",
|
|
8
|
+
"@midwayjs/faas": "^3.10.0",
|
|
9
9
|
"raw-body": "2.5.1"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@midwayjs/core": "^3.
|
|
13
|
-
"@midwayjs/serverless-http-parser": "^3.
|
|
12
|
+
"@midwayjs/core": "^3.10.0",
|
|
13
|
+
"@midwayjs/serverless-http-parser": "^3.10.0"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=12"
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"url": "git@github.com:midwayjs/midway.git"
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "33d28f1a020963404488e866432916fd15c0952c"
|
|
33
33
|
}
|