-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (22 loc) · 670 Bytes
/
index.js
File metadata and controls
28 lines (22 loc) · 670 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 bodyParser = require('body-parser')
const routes = require('./routes/api')
require("express-validator")
require('dotenv').config()
const app = express()
const port = process.env.PORT || 5000;
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*")
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
next()
})
app.use(bodyParser.json())
//TODO add middle wear to refresh access token
app.use('/api', routes);
app.use((err, req, res, next) => {
console.log(err);
next()
})
app.listen(port, () => {
console.log(`Server running on port ${port}`)
})