-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (38 loc) · 1.29 KB
/
index.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
47
48
const async_send = require('./await-send');
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
app.use(bodyParser.json());
// parse various different custom JSON types as JSON
app.use(bodyParser.json({ type: 'application/*+json' }));
// parse some custom thing into a Buffer
app.use(bodyParser.raw({ type: 'application/vnd.custom-type' }));
// parse an HTML body into a string
app.use(bodyParser.text({ type: 'text/html' }));
// parse an text body into a string
app.use(bodyParser.text({ type: 'text/plain' }));
// create application/x-www-form-urlencoded parser
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/new_email_flutter', async (request, response) => {
const payload = request.body;
console.log(payload);
const payloadJson = payload;
const msg = {
to: payloadJson.toAddress,
from: '[email protected]',
template_id: "d-6fa2fa9c6ff5453b94a2f2a823481a97"
};
try {
mail_sent = await async_send(msg);
response.status(200).send("Success");
} catch (error) {
response.status(500).send("Oops");
console.log(error);
}
});
app.listen(3149, function (err) {
if (err) {
throw err
}
console.log('SendMail Server started on port 3149')
})