-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
74 lines (65 loc) · 1.12 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const express = require("express");
const app = express();
const port = process.env.PORT || 3000;
app.get("/", (req, res) => {
res.json({ message: "API is Online!" });
});
countries = [
{
id: 1,
name: "Ghana",
},
{
id: 2,
name: "France",
},
{
id: 3,
name: "Scotland",
},
];
names = [
{
name: "Harry Potter",
city: "London",
},
{
name: "Don Quixote",
city: "Madrid",
},
{
name: "Joan of Arc",
city: "Paris",
},
{
name: "Rosa Park",
city: "Alabama",
},
];
todos = [
{
title: "Clean the kitchen",
description:
"Mop the floor, wipe the countertop and don't forget to take out the trash!",
},
{
title: "Call Mom",
description: "It's her birthday!",
},
{
title: "Water flowers",
description: "They need water, or they will die.",
},
];
app.get("/countries", (req, res) => {
res.json({ data: countries });
});
app.get("/names", (req, res) => {
res.json({ data: names });
});
app.get("/todos", (req, res) => {
res.json({ data: todos });
});
app.get;
app.listen(port);
console.log("Listening on port " + port);