forked from eamon0989/FullStackLaunchSchoolTimeEstimator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
28 lines (20 loc) · 800 Bytes
/
server.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
const config = require('./utils/config');
const express = require('express')
const app = express();
const courseRouter = require('./controllers/courses');
const logger = require('./utils/logger')
const middleware = require('./utils/middleware');
const mongoose = require('mongoose');
logger.info('connecting to', config.MONGODB_URI)
mongoose.connect(config.MONGODB_URI, { useNewUrlParser:true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify:false})
.then(() =>{
logger.info(`Connected to MongoDB`,config.MONGODB_URI);
})
.catch((error) => {
logger.error(`Error connection to MongoDB:`,error.message);
})
app.use(express.static('public'));
app.use(express.json());
app.use('/api/courses',courseRouter);
app.use(middleware.requestLogger);
module.exports = app;