-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (37 loc) · 1.2 KB
/
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
36
37
38
39
40
41
42
43
44
const express = require('express')
const rootController = require('./controller/root.controller');
const dateService = require('./service/date.service')
const http = require("http");
// Used to keep the server when using heroku, etc.
function startInterval() {
setInterval(function() {
console.log('>> Start check every minute.')
if (process.env.PROFILE === 'prod') {
http.get('') // Set your production server
} else {
http.get('http://localhost:3000/send')
}
}, 60000)
}
const app = express()
app.use(express.json())
app.route("/").get(rootController.get)
app.route("/send").get(rootController.getSend)
app.route("/save").post(rootController.postSave)
const port = process.env.PORT || 3000
app.listen(port, async () => {
const text = `SNKRS-sender service start.
_ _ _ _
| | | | ___| | | ___
| |_| |/ _ \\ | |/ _ \\
| _ | __/ | | (_) |
|_| |_|\\___|_|_|\\___/
`
console.log(text)
const dateTime = await dateService.utc()
console.log(`Server time : ${dateTime}`)
if (process.env.PROFILE == 'dev') {
console.log(`Starting development server at http://127.0.0.1:${port}`)
}
// startInterval()
})