-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
35 lines (31 loc) · 830 Bytes
/
server.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
'use strict';
const Hapi = require('hapi');
const invoicer = require('./index');
// Create a server with a host and port
const server = new Hapi.Server();
server.connection({
host: 'localhost',
port: process.env.PORT || 8082
});
// Add the route
server.route({
method: 'POST',
path:'/invoice/s3',
handler: function (request, reply) {
let payload = request.payload;
console.log("payload", payload);
invoicer.uploadS3(payload.template, payload,
(error, s3Url) => {
if(error) {
return reply({ success: false });
}
return reply({ success: true, url: s3Url });
});
}
});
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});