-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.js
60 lines (56 loc) · 1.36 KB
/
handler.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
var fs = require("fs");
const userData = require("./data");
const home = (response) => {
response.writeHeader(200, { "Content-Type": "text/html" });
response.write(`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
body {
margin: 0;
padding: 0;
font-family: sans-serif;
box-sizing: border-box;
background-color: black;
color: white;
text-align: center;
height: 100vh;
}
body h1 {
margin-top: 3rem;
}
.container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 50%;
flex-direction: column;
}
</style>
<title>Dummy users API</title>
</head>
<body>
<h1>Dummy Users API</h1>
<div class="container">
<h3>Hit below URL to get response users</h3>
<a href="${__dirname}/users">Generate Users</a>
</div>
</body>
</html>
`);
response.end();
};
const users = (response) => {
response.writeHead(200, { "Content-Type": "application/json" });
response.write(JSON.stringify(userData.DUMMY_USERS, null, 2));
response.end();
};
module.exports = {
"/": home,
"/home": home,
"/users": users,
};