-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (33 loc) · 771 Bytes
/
index.js
File metadata and controls
40 lines (33 loc) · 771 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
import http from "node:http";
import {
getUsuarios,
importFromFile,
index,
saveToFile,
} from "./controller.js";
const server = http.createServer(async (request, response) => {
const url = request.url;
const method = request.method;
if (method === "GET") {
switch (url) {
case "/":
index(response);
break;
case "/api/usuarios":
getUsuarios(response);
break;
case "/api/usuarios/export":
saveToFile(response);
break;
case "/api/usuarios/import":
importFromFile(response);
break;
default:
response.end("no se encontro ruta");
break;
}
}
});
server.listen(5000, () =>
console.log("Servidor Ejecutandose en http://localhost:5000")
);