-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.ts
More file actions
33 lines (26 loc) · 793 Bytes
/
server.ts
File metadata and controls
33 lines (26 loc) · 793 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
#!/usr/bin/env node
/* eslint-disable no-console */
const express = require("express")
const app = express()
const path = require("path")
const port = process.env.PORT || 8080
process.env.MES_AIDES_ROOT_URL =
process.env.MES_AIDES_ROOT_URL || `http://localhost:${port}`
require("./configure")({ app })
app.use(express.static("dist"))
app.route("/*").get(function (req, res) {
res.sendFile(path.join(__dirname, "../dist/index.html"))
})
app.use(function (err, req, res, next) {
console.error(err)
res.status(parseInt(err.code) || 500).send(err)
next()
})
app.listen(port, () => {
console.log(
`Aides Jeunes server listening on port ${port}, in ${app.get(
"env"
)} mode, expecting to be deployed on ${process.env.MES_AIDES_ROOT_URL}`
)
})
module.exports = app