forked from xrr2016/vue-express-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
27 lines (22 loc) · 749 Bytes
/
app.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
const pkg = require('./package')
const config = require('./config/db')
const express = require('express')
const favicon = require('serve-favicon')
const bodyParser = require('body-parser')
const mongoose = require('mongoose')
const index = require('./router/index')
const movie = require('./router/movie')
mongoose.connect(config.mongodb)
mongoose.Promise = global.Promise
const app = express()
const port = process.env.PORT || 3000
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(favicon(__dirname + '/src/assets/favicon.ico'))
app.use(express.static('dist'))
app.use('/',index)
app.use('/api',movie)
app.listen(port, () => {
console.log(`${pkg.name} listening on port ${port}`)
})
module.exports = app