-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (26 loc) · 877 Bytes
/
server.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
require('dotenv').config()
const bodyParser = require('body-parser')
const express = require('express')
const port = process.env.PORT
const cors = require('cors')
const app = express()
//Eneble CORS Policy
app.use( cors({ origin: "http://localhost:3000 " }))
app.use(bodyParser.urlencoded({extended: true}))
app.use(bodyParser.json())
app.use(express.json()) // parse json bodies in the request object
app.use('/uploads', express.static('uploads'))
app.use('/api/user', require('./router/user'))
app.use('/api/song', require('./router/song'))
app.use('/api/artist', require('./router/artist'))
app.use((err, res) => {
console.log(err.stack);
console.log(err.name);
console.log(err.code);
res.status(500).json({
message: "Something went really wrong"
})
})
app.listen(port, ()=>{
console.log(`app listing at http://localhost:${port}`);
})