-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (25 loc) · 846 Bytes
/
index.js
File metadata and controls
28 lines (25 loc) · 846 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
const express = require('express')
const app = express()
const cors = require('cors')
const users = require('./router/users')
const propositions = require('./router/propositions')
const answers = require('./router/answers')
const tags = require('./router/tags')
const admin = require('./router/admin')
const database = require('./database')
const dotenv = require('dotenv')
dotenv.config();
const port = process.env.PORT
const logInfo = (req, res, next) => {
console.log('[INFO]', '(' + new Date().toLocaleString() +')', req.method, req.url, 'from', req.hostname)
next()
}
app.use(cors())
app.use(express.json())
app.use(logInfo)
app.use('/users',users)
app.use('/propositions',propositions)
app.use('/answers',answers)
app.use('/tags',tags)
app.use('/admin',admin)
app.listen(port, () => console.log(`App listening on port ${port}`))