-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
41 lines (31 loc) · 906 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//imports
const express = require('express');
// const mongodb = require('mongodb');
const mongoose = require('mongoose');
const morgan = require('morgan');
const config = require('./utils/config');
const articleRouter = require('./routes/articleRoute');
//app
const app = express();
app.use(express.json());
//logging
app.use(morgan('tiny'));
//routes
app.use('/api/v1/articles', articleRouter);
// app.get('/', function (req, res) {
// res.json({ "hello": "world" });
// });
//config
// const client = mongodb.MongoClient;
// client.connect(config.DB, function (err, db) {
// if (err) {
// console.log('database is not connected')
// }
// else {
// console.log('connected!!')
// }
// });
mongoose.connect(config.DB)
.then(() => console.log("connected to mongDB"))
.catch(err => console.error("error connecting to mongoDB", err))
module.exports = app;