-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
37 lines (29 loc) · 949 Bytes
/
main.js
File metadata and controls
37 lines (29 loc) · 949 Bytes
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
const secrets = require('./secrets.js');
const client = require('twilio')(secrets.accountSid, secrets.authToken);
const express = require('express');
const bodyParser = require('body-parser');
const logic = require('./logic');
const app = express();
app.enable("trust proxy");
app.get('/', (req, res) => {
res.send('Hello Express app!');
});
app.use(bodyParser.urlencoded({extended: false}));
exports.sendOutgoingSMS =
async function sendOutgoingSMS(message, receiver, sender) {
console.log("Made it to outgoing sms");
return await client.messages
.create({
body: message,
from: sender,
to: receiver
});
};
app.post('/sms', async (req, res) => {
await logic.IncomingRawSMS(req.body.Body, req.body.To, req.body.From);
res.writeHead(200, {'Content-Type': 'text/xml'});
res.end('');
});
app.listen(process.env.PORT || 8080, () => {
console.log('server started');
});