forked from uslperera/serverless-step-functions-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.js
44 lines (39 loc) · 977 Bytes
/
handler.js
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
43
44
'use strict';
const AWS = require('aws-sdk');
var stepfunctions = new AWS.StepFunctions();
module.exports.startTimer = (event, context, callback) => {
try {
console.log("Start timer");
var params = {
stateMachineArn: process.env.TIMER_ARN,
input: {}
};
stepfunctions.startExecution(params, function (err, data) {
if (err) {
console.log(err, err.stack);
} else {
console.log("Timer started");
const response = {
statusCode: 200,
body: JSON.stringify({
message: "Timer started"
}),
};
callback(null, response);
}
});
} catch (error) {
console.log(error);
callback(error);
}
};
module.exports.sendNotification = (event, context, callback) => {
try {
console.log("Time is up!!");
console.log("Sending notification");
//Sending notification code
} catch (error) {
console.log(error);
callback(error);
}
};