@midwayjs/fc-starter 3.7.1 → 3.7.3
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 +1 -0
- package/dist/index.js +17 -1
- package/dist/mock.d.ts +134 -0
- package/dist/mock.js +167 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
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
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.BootstrapStarter = void 0;
|
|
4
18
|
const core_1 = require("@midwayjs/core");
|
|
5
19
|
const faas_1 = require("@midwayjs/faas");
|
|
6
20
|
const getRawBody = require("raw-body");
|
|
7
21
|
const async_hooks_context_manager_1 = require("@midwayjs/async-hooks-context-manager");
|
|
22
|
+
const mock_1 = require("./mock");
|
|
23
|
+
__exportStar(require("./mock"), exports);
|
|
8
24
|
function isOutputError() {
|
|
9
25
|
return (process.env.SERVERLESS_OUTPUT_ERROR_STACK === 'true' ||
|
|
10
26
|
['local', 'development'].includes(process.env.MIDWAY_SERVER_ENV) ||
|
|
@@ -33,7 +49,7 @@ class BootstrapStarter extends faas_1.AbstractBootstrapStarter {
|
|
|
33
49
|
}
|
|
34
50
|
return exports;
|
|
35
51
|
}
|
|
36
|
-
async onInit(context, exports) {
|
|
52
|
+
async onInit(context = (0, mock_1.mockContext)(), exports) {
|
|
37
53
|
const applicationAdapter = {
|
|
38
54
|
getFunctionName() {
|
|
39
55
|
return context.function.name;
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare function mockContext(): {
|
|
3
|
+
requestId: string;
|
|
4
|
+
credentials: {
|
|
5
|
+
accessKeyId: string;
|
|
6
|
+
accessKeySecret: string;
|
|
7
|
+
securityToken: string;
|
|
8
|
+
};
|
|
9
|
+
function: {
|
|
10
|
+
name: string;
|
|
11
|
+
handler: string;
|
|
12
|
+
memory: number;
|
|
13
|
+
timeout: number;
|
|
14
|
+
initializer: string;
|
|
15
|
+
initializationTimeout: number;
|
|
16
|
+
};
|
|
17
|
+
service: {
|
|
18
|
+
name: string;
|
|
19
|
+
logProject: string;
|
|
20
|
+
logStore: string;
|
|
21
|
+
qualifier: string;
|
|
22
|
+
versionId: string;
|
|
23
|
+
};
|
|
24
|
+
region: string;
|
|
25
|
+
accountId: string;
|
|
26
|
+
logger: Console;
|
|
27
|
+
};
|
|
28
|
+
export declare function mockCDNEvent(): {
|
|
29
|
+
events: {
|
|
30
|
+
eventName: string;
|
|
31
|
+
eventSource: string;
|
|
32
|
+
region: string;
|
|
33
|
+
eventVersion: string;
|
|
34
|
+
eventTime: string;
|
|
35
|
+
userIdentity: {
|
|
36
|
+
aliUid: string;
|
|
37
|
+
};
|
|
38
|
+
resource: {
|
|
39
|
+
domain: string;
|
|
40
|
+
};
|
|
41
|
+
eventParameter: {
|
|
42
|
+
domain: string;
|
|
43
|
+
endTime: number;
|
|
44
|
+
fileSize: number;
|
|
45
|
+
filePath: string;
|
|
46
|
+
startTime: number;
|
|
47
|
+
};
|
|
48
|
+
traceId: string;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
export declare function mockMNSEvent(): {
|
|
52
|
+
Context: string;
|
|
53
|
+
TopicOwner: string;
|
|
54
|
+
Message: string;
|
|
55
|
+
Subscriber: string;
|
|
56
|
+
PublishTime: number;
|
|
57
|
+
SubscriptionName: string;
|
|
58
|
+
MessageMD5: string;
|
|
59
|
+
TopicName: string;
|
|
60
|
+
MessageId: string;
|
|
61
|
+
};
|
|
62
|
+
export declare function mockOSSEvent(): {
|
|
63
|
+
events: {
|
|
64
|
+
eventName: string;
|
|
65
|
+
eventSource: string;
|
|
66
|
+
eventTime: string;
|
|
67
|
+
eventVersion: string;
|
|
68
|
+
oss: {
|
|
69
|
+
bucket: {
|
|
70
|
+
arn: string;
|
|
71
|
+
name: string;
|
|
72
|
+
ownerIdentity: string;
|
|
73
|
+
virtualBucket: string;
|
|
74
|
+
};
|
|
75
|
+
object: {
|
|
76
|
+
deltaSize: number;
|
|
77
|
+
eTag: string;
|
|
78
|
+
key: string;
|
|
79
|
+
size: number;
|
|
80
|
+
};
|
|
81
|
+
ossSchemaVersion: string;
|
|
82
|
+
ruleId: string;
|
|
83
|
+
};
|
|
84
|
+
region: string;
|
|
85
|
+
requestParameters: {
|
|
86
|
+
sourceIPAddress: string;
|
|
87
|
+
};
|
|
88
|
+
responseElements: {
|
|
89
|
+
requestId: string;
|
|
90
|
+
};
|
|
91
|
+
userIdentity: {
|
|
92
|
+
principalId: string;
|
|
93
|
+
};
|
|
94
|
+
}[];
|
|
95
|
+
};
|
|
96
|
+
export declare function mockSLSEvent(): {
|
|
97
|
+
parameter: {};
|
|
98
|
+
source: {
|
|
99
|
+
endpoint: string;
|
|
100
|
+
projectName: string;
|
|
101
|
+
logstoreName: string;
|
|
102
|
+
shardId: number;
|
|
103
|
+
beginCursor: string;
|
|
104
|
+
endCursor: string;
|
|
105
|
+
};
|
|
106
|
+
jobName: string;
|
|
107
|
+
taskId: string;
|
|
108
|
+
cursorTime: number;
|
|
109
|
+
};
|
|
110
|
+
export declare function mockTableStoreEvent(): {
|
|
111
|
+
Version: string;
|
|
112
|
+
Records: {
|
|
113
|
+
Type: string;
|
|
114
|
+
Info: {
|
|
115
|
+
Timestamp: number;
|
|
116
|
+
};
|
|
117
|
+
PrimaryKey: {
|
|
118
|
+
ColumnName: string;
|
|
119
|
+
Value: string;
|
|
120
|
+
}[];
|
|
121
|
+
Columns: {
|
|
122
|
+
Type: string;
|
|
123
|
+
ColumnName: string;
|
|
124
|
+
Value: string;
|
|
125
|
+
Timestamp: number;
|
|
126
|
+
}[];
|
|
127
|
+
}[];
|
|
128
|
+
};
|
|
129
|
+
export declare function mockTimerEvent(): {
|
|
130
|
+
triggerTime: string;
|
|
131
|
+
triggerName: string;
|
|
132
|
+
payload: string;
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=mock.d.ts.map
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mockTimerEvent = exports.mockTableStoreEvent = exports.mockSLSEvent = exports.mockOSSEvent = exports.mockMNSEvent = exports.mockCDNEvent = exports.mockContext = void 0;
|
|
4
|
+
function mockContext() {
|
|
5
|
+
return {
|
|
6
|
+
requestId: 'b1c5100f-819d-c421-3a5e-7782a27d8a33',
|
|
7
|
+
credentials: {
|
|
8
|
+
accessKeyId: 'STS.access_key_id',
|
|
9
|
+
accessKeySecret: 'access_key_secret',
|
|
10
|
+
securityToken: 'security_token',
|
|
11
|
+
},
|
|
12
|
+
function: {
|
|
13
|
+
name: 'my-func',
|
|
14
|
+
handler: 'index.handler',
|
|
15
|
+
memory: 128,
|
|
16
|
+
timeout: 10,
|
|
17
|
+
initializer: 'index.initializer',
|
|
18
|
+
initializationTimeout: 10,
|
|
19
|
+
},
|
|
20
|
+
service: {
|
|
21
|
+
name: 'my-service',
|
|
22
|
+
logProject: 'my-log-project',
|
|
23
|
+
logStore: 'my-log-store',
|
|
24
|
+
qualifier: 'qualifier',
|
|
25
|
+
versionId: '1',
|
|
26
|
+
},
|
|
27
|
+
region: 'cn-shanghai',
|
|
28
|
+
accountId: '123456',
|
|
29
|
+
logger: console,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.mockContext = mockContext;
|
|
33
|
+
function mockCDNEvent() {
|
|
34
|
+
return {
|
|
35
|
+
events: [
|
|
36
|
+
{
|
|
37
|
+
eventName: 'LogFileCreated',
|
|
38
|
+
eventSource: 'cdn',
|
|
39
|
+
region: 'cn-hangzhou',
|
|
40
|
+
eventVersion: '1.0.0',
|
|
41
|
+
eventTime: 'xxxxx',
|
|
42
|
+
userIdentity: {
|
|
43
|
+
aliUid: '1xxxxxxxxxxxx',
|
|
44
|
+
},
|
|
45
|
+
resource: {
|
|
46
|
+
domain: 'example.com',
|
|
47
|
+
},
|
|
48
|
+
eventParameter: {
|
|
49
|
+
domain: 'example.com',
|
|
50
|
+
endTime: 1000000,
|
|
51
|
+
fileSize: 1788115,
|
|
52
|
+
filePath: 'http://cdnlog.cn-hangzhou.oss.aliyun-inc.com/xxx/xxx/xxx.gz?OSSAccessKeyId=xxxx&Expires=xxxx&Signature=xxxx',
|
|
53
|
+
startTime: 11000000,
|
|
54
|
+
},
|
|
55
|
+
traceId: 'xxxxxx',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exports.mockCDNEvent = mockCDNEvent;
|
|
61
|
+
function mockMNSEvent() {
|
|
62
|
+
return {
|
|
63
|
+
Context: 'user custom info',
|
|
64
|
+
TopicOwner: '1186202104331798',
|
|
65
|
+
Message: 'hello topic',
|
|
66
|
+
Subscriber: '1186202104331798',
|
|
67
|
+
PublishTime: 1550216302888,
|
|
68
|
+
SubscriptionName: 'test-fc-subscibe',
|
|
69
|
+
MessageMD5: 'BA4BA9B48AC81F0F9C66F6C909C39DBB',
|
|
70
|
+
TopicName: 'test-topic',
|
|
71
|
+
MessageId: '2F5B3C281B283D4EAC694B7425288675',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
exports.mockMNSEvent = mockMNSEvent;
|
|
75
|
+
function mockOSSEvent() {
|
|
76
|
+
return {
|
|
77
|
+
events: [
|
|
78
|
+
{
|
|
79
|
+
eventName: 'ObjectCreated:PutObject',
|
|
80
|
+
eventSource: 'acs:oss',
|
|
81
|
+
eventTime: '2017-04-21T12:46:37.000Z',
|
|
82
|
+
eventVersion: '1.0',
|
|
83
|
+
oss: {
|
|
84
|
+
bucket: {
|
|
85
|
+
arn: 'acs:oss:cn-shanghai:123456789:bucketname',
|
|
86
|
+
name: 'testbucket',
|
|
87
|
+
ownerIdentity: '123456789',
|
|
88
|
+
virtualBucket: '',
|
|
89
|
+
},
|
|
90
|
+
object: {
|
|
91
|
+
deltaSize: 122539,
|
|
92
|
+
eTag: '688A7BF4F233DC9C88A80BF985AB7329',
|
|
93
|
+
key: 'image/a.jpg',
|
|
94
|
+
size: 122539,
|
|
95
|
+
},
|
|
96
|
+
ossSchemaVersion: '1.0',
|
|
97
|
+
ruleId: '9adac8e253828f4f7c0466d941fa3db81161e853',
|
|
98
|
+
},
|
|
99
|
+
region: 'cn-shanghai',
|
|
100
|
+
requestParameters: {
|
|
101
|
+
sourceIPAddress: '140.205.128.221',
|
|
102
|
+
},
|
|
103
|
+
responseElements: {
|
|
104
|
+
requestId: '58F9FF2D3DF792092E12044C',
|
|
105
|
+
},
|
|
106
|
+
userIdentity: {
|
|
107
|
+
principalId: '123456789',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
exports.mockOSSEvent = mockOSSEvent;
|
|
114
|
+
function mockSLSEvent() {
|
|
115
|
+
return {
|
|
116
|
+
parameter: {},
|
|
117
|
+
source: {
|
|
118
|
+
endpoint: 'http://cn-shanghai-intranet.log.aliyuncs.com',
|
|
119
|
+
projectName: 'log-com',
|
|
120
|
+
logstoreName: 'log-en',
|
|
121
|
+
shardId: 0,
|
|
122
|
+
beginCursor: 'MTUyOTQ4MDIwOTY1NTk3ODQ2Mw==',
|
|
123
|
+
endCursor: 'MTUyOTQ4MDIwOTY1NTk3ODQ2NA==',
|
|
124
|
+
},
|
|
125
|
+
jobName: '1f7043ced683de1a4e3d8d70b5a412843d817a39',
|
|
126
|
+
taskId: 'c2691505-38da-4d1b-998a-f1d4bb8c9994',
|
|
127
|
+
cursorTime: 1529486425,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
exports.mockSLSEvent = mockSLSEvent;
|
|
131
|
+
function mockTableStoreEvent() {
|
|
132
|
+
return {
|
|
133
|
+
Version: 'string',
|
|
134
|
+
Records: [
|
|
135
|
+
{
|
|
136
|
+
Type: 'string',
|
|
137
|
+
Info: {
|
|
138
|
+
Timestamp: Date.now(),
|
|
139
|
+
},
|
|
140
|
+
PrimaryKey: [
|
|
141
|
+
{
|
|
142
|
+
ColumnName: 'string',
|
|
143
|
+
Value: 'new event',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
Columns: [
|
|
147
|
+
{
|
|
148
|
+
Type: 'string',
|
|
149
|
+
ColumnName: 'string',
|
|
150
|
+
Value: 'new event',
|
|
151
|
+
Timestamp: Date.now(),
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
exports.mockTableStoreEvent = mockTableStoreEvent;
|
|
159
|
+
function mockTimerEvent() {
|
|
160
|
+
return {
|
|
161
|
+
triggerTime: new Date().toJSON(),
|
|
162
|
+
triggerName: 'timer',
|
|
163
|
+
payload: '',
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
exports.mockTimerEvent = mockTimerEvent;
|
|
167
|
+
//# sourceMappingURL=mock.js.map
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/fc-starter",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.3",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@midwayjs/async-hooks-context-manager": "^3.7.0",
|
|
8
|
-
"@midwayjs/faas": "^3.7.
|
|
8
|
+
"@midwayjs/faas": "^3.7.3",
|
|
9
9
|
"raw-body": "2.5.1"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"url": "git@github.com:midwayjs/midway.git"
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "8e6c830bca52818e0086873b542423d16e609aef"
|
|
33
33
|
}
|