-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (20 loc) · 837 Bytes
/
index.js
File metadata and controls
25 lines (20 loc) · 837 Bytes
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
import express from 'express'
import mongoose from 'mongoose'
import morgan from 'morgan'
import http from 'http'
import { api, auth } from './api/index.js'
const app = express()
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'mongodb connection error:'));
db.once('open', () => console.log('connected to mongodb'));
mongoose.connect('mongodb://localhost/godutch', { useNewUrlParser: true, useFindAndModify: false, useUnifiedTopology: true });
app.set('port', process.env.PORT || 3000)
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
app.use(morgan('combined'))
app.get('/', (req, res) => { res.json({}) })
app.use('/api', api)
app.use('/auth', auth)
http.createServer(app).listen(app.get('port'), () => {
console.log(`Express server listening on port ${app.get('port')}`)
})