-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (31 loc) · 797 Bytes
/
index.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
35
36
37
const express = require("express")
const app = express()
const cors = require("cors")
const db = require('./models')
const dotenv = require("dotenv")
const router = require("./routes/index")
dotenv.config()
app.use(cors({
origin: ['http://localhost:3000', 'https://musikin-id.netlify.app'],
credentials: true
}))
app.use(express.json())
// app.use(express.urlencoded())
// db.sequelize.sync()
// .then(() => {
// console.log('Synced db.');
// })
// .catch((error) => {
// console.log('Failed to sync db: ' + error.message);
// })
app.use('/', router)
const appStart = () => {
try {
app.listen(process.env.PORT, () => {
console.log('Server running at', process.env.PORT);
})
} catch (error) {
console.log(`Error: ${error.message}`);
}
}
appStart();