-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinvoke.ts
42 lines (38 loc) · 1.08 KB
/
invoke.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import type { Context, EventBridgeEvent } from 'aws-lambda';
import { handler as revolverHandle } from './revolver.js';
const timeStamp = process.env.CURRENT_TIME || new Date().toISOString();
const event: EventBridgeEvent<'Scheduled Event', 'test-event'> = {
id: '0',
'detail-type': 'Scheduled Event',
version: '0',
account: '0',
time: timeStamp,
region: 'ap-southeast-2',
source: 'revolver',
resources: [],
detail: 'test-event',
};
const context: Context = {
callbackWaitsForEmptyEventLoop: false,
functionName: 'revolver',
functionVersion: '0',
invokedFunctionArn: 'arn:aws:lambda:ap-southeast-2:0:function:revolver',
memoryLimitInMB: '512',
awsRequestId: '0',
logGroupName: 'revolver',
logStreamName: '0',
getRemainingTimeInMillis: () => 0,
done: () => {},
fail: () => {},
succeed: () => {},
};
console.log(`Running revolver at timestamp [${timeStamp}]`);
const r = revolverHandle(event, context, () => {});
if (r instanceof Promise) {
r.then(() => {
console.log('Done');
}).catch((e: Error) => {
console.error(e);
process.exit(1);
});
}