forked from AdithyakrishnaV/BookAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (30 loc) · 956 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
39
40
41
42
43
44
45
46
47
require("dotenv").config();
//Framework
const { json } = require("express");
const express = require("express");
const mongoose = require("mongoose");
// Microservices routes
const Books = require("./API/Book");
const Authors = require("./API/Author");
const Publications = require("./API/Publication");
// Initialization
const booky = express();
//Configuration
booky.use(express.json());
//Establish database connection
mongoose.connect(
process.env.MONGO_URL,
{
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true
}
).then(() => console.log("Connection established..!!"));
// Initializing Microservices
booky.use("/book", Books);
booky.use("/author", Authors);
booky.use("/publication", Publications);
booky.listen(3000, () => console.log("Hey server booting..."));
//HTTP client -> helper who helps you to make http request
//Monolitic approach