-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (30 loc) · 825 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
const express = require("express"); // include all necessary modules
const app = express();
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const chai = require("chai")
const blRouter = require("./routes/BlogRoutes.js")
chai.should(); // use the chai assertion library for BDD and TDD
var PORT = 3001;
// mount middleware
app.use(express.json());
app.use("/api/blogs", blRouter) ;
app.use(express.urlencoded({extended: true}));
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
mongoose.connect(
process.env.MONGODB_URI || "mongodb://localhost/CRUD",
{
useNewUrlParser: true,
useUnifiedTopology: true,
},
(err) => {
if (err) {
console.log(err);
} else {
console.log("Connected to MongoDB");
}
}
);
module.exports = app;