-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (21 loc) · 688 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (21 loc) · 688 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
26
27
28
require("dotenv").config();
const express = require("express");
const cors = require("cors");
const dbConnection = require("./dbConnection");
const bookRoute = require("./routes/book.route");
// Connection to port
const PORT = process.env.PORT || 3000;
// Start the express server
const app = express();
// Connection to the MongoDB database
dbConnection();
// Middleware for application
app.use(express.json());
app.use(express.urlencoded({extended: false}))
app.use(cors());
// Routes
app.use("/books", bookRoute);
// Start the server and listen for incoming requests on the specified port
app.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}`);
});