-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (27 loc) · 990 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
38
const express = require('express')
const mongoose = require('mongoose')
const cors = require('cors')
const bodyParser = require('body-parser')
const logger = require('morgan')
require('dotenv').config()
const PORT = process.env.PORT
const DBPORT = process.env.MONGODB_URI
var app = express()
mongoose.connect(DBPORT, { useNewUrlParser: true })
mongoose.Promise = global.Promise
var db = mongoose.connection
db.on('error', console.error.bind(console, 'MongoDB connection error:'))
if (process.env.DEBUG) app.use(logger('dev'))
app.use(cors())
app.use(bodyParser.json({ limit: '50mb', extended: true }))
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }))
app.use(express.static('public'))
app.use(express.static('public/build/html'))
app.use(express.static('public/build'))
app.set('view engine', 'pug')
app.set('views', './views')
app.use('/', require('./routes'))
app.listen(PORT, err => {
if (err) throw err
console.info('Listening on port ' + PORT + '...')
})