-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (28 loc) · 997 Bytes
/
app.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
const express = require('express');
const app = express();
require('dotenv').config();
var AWS = require('aws-sdk');
app.get('/', (req, res) => {
console.log("Message = " + req.query.message);
console.log("Number = " + req.query.number);
console.log("Subject = " + req.query.subject);
var params = {
Message: req.query.message,
PhoneNumber: '+' + req.query.number,
MessageAttributes: {
'AWS.SNS.SMS.SenderID': {
'DataType': 'String',
'StringValue': req.query.subject
}
}
};
var publishTextPromise = new AWS.SNS({ apiVersion: '2010-03-31' }).publish(params).promise();
publishTextPromise.then(
function (data) {
res.end(JSON.stringify({ MessageID: data }));
}).catch(
function (err) {
res.end(JSON.stringify({ Error: err }));
});
});
app.listen(3000, () => console.log('SMS Service Listening on PORT 3000'))