-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (25 loc) · 827 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
const express = require('express')
const cors = require('cors')
const bodyParser = require('body-parser')
const mongoose = require('mongoose')
const path = require('path')
const config = require('./config/config')
const auth = require('./routes/auth.routes')
const plugin = require('./routes/plugin.routes')
const app = express()
const PORT = 5000
app.use(cors())
app.use(bodyParser.json())
app.use(express.static(path.join(__dirname, 'assets')))
app.use('/api/auth', auth);
app.use('/api/plugin', plugin);
mongoose.connect(config.db)
mongoose.connection.on('connected', () => {
console.log('MongoDB is connected')
})
mongoose.connection.on('error', (err) => {
console.log(`MongoDB is not connected. Error: ${err}`)
})
app.listen(PORT, () => {
console.log(`Server has been started on port ${PORT}...`)
})