-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (31 loc) · 914 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
const express = require('express')
const app = express()
const Export = require('./src/services/export')
const chalk = require('chalk')
app.get('/', function (req, res) {
res.json({message: 'ok'})
})
app.post('/export', function (req, res) {
const exportService = new Export()
exportService.initializeBucketFiles().then(() => {
exportService.getBucketFiles().then(() => {
exportService.zipFiles().then(() => {
exportService.uploadZip().then(() => {
res.json({message: 'ok'})
})
})
})
}).catch((err) => {
console.log(chalk.red.inverse(err.message))
res.status(500).json({message: err.message})
})
})
const PORT = process.env.PORT || 3000
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`)
console.log('Press Ctrl+C to quit.')
})
// Default response for any other request
app.use(function (req, res) {
res.status(404);
});