-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (30 loc) · 718 Bytes
/
index.js
File metadata and controls
42 lines (30 loc) · 718 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const express = require("express");
const app = express();
//to parse the request body
app.use(express.json());
//Books Api Routes: GET, POST, PUT, DELETE
let books = [
{
id: 1,
name: "Harry Potter",
author: "J.K. Rowling"
},
{
id: 2,
name: "The Alchemist",
},
{
id: 3,
name: "The Da Vinci Code",
}
];
app.get("/", (req, res) => {
res.status(200).json({ message: "Hello change this to list of books!" });
})
app.get("/ping", (req, res) => {
res.status(200).json({ message: "Pong" });
})
// Add other requests GET, POST, PUT, DELETE
app.listen(8000, () => {
console.log(`App is live on: http://localhost:8000`);
});