-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.js
46 lines (38 loc) · 934 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
45
46
module.exports.sendMessage = async (event) => {
const AWS = require("aws-sdk");
const SQS = new AWS.SQS({
accessKeyId: "local",
secretAccessKey: "local",
endpoint: "127.0.0.1:9324"
});
try {
const queueParams = {
Entries: [
{
Id: "1",
MessageBody: "this is a message body",
}
],
QueueUrl: 'http://127.0.0.1:9324/queue/myFirstQueue'
}
const result = await SQS.sendMessageBatch(queueParams).promise();
let bodyResponse = JSON.stringify(result, null, 2)
console.log(bodyResponse);
if(result != null){
return {
statusCode: 200,
body: bodyResponse
}
}else{
return {
statusCode: 400,
body: 'Bad request'
}
}
} catch (e) {
console.error(e);
}
};
module.exports.receiveMessage = async (event) => {
console.log(JSON.stringify(event.Records, null, 2));
};