-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (25 loc) · 711 Bytes
/
Copy pathindex.js
File metadata and controls
29 lines (25 loc) · 711 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
import dotenv from 'dotenv'
dotenv.config()
import express from 'express'
import apiRouter from './server/routes/'
import fileUpload from 'express-fileupload'
const app = express()
const PORT = process.env.PORT || 8000
// some middlewares
app.use(express.urlencoded({extended : false}))
app.use((req, res, next) => {
if(res.status === 500)
res.status(500).send({ status : 500, message : 'Server error!'})
next()
})
app.use(fileUpload({
useTempFiles : true
}))
app.use(apiRouter)
app.listen(PORT, () => {
console.log(`Automart api server has been started on port:${PORT}`)
})
app.get('**', (req, res) => {
res.status(404).send({ status : 404, message : 'Page not found!'})
})
export default app