-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
70 lines (52 loc) · 1.57 KB
/
server.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
import express from "express";
import userRoute from "./modules/user/routes/routeIndex.js";
import authRoute from "./modules/auth/routes/routesIndex.js";
import logs from "./middleware/logs.js";
import { authenticate } from "./middleware/jwt.js";
import cors from "cors";
const server = express();
const PORT = process.env.PORT || 8000;
server.use(express.json());
server.use(express.urlencoded({ extended: true }));
server.use(cors());
server.options("/api/*", cors());
server.use(logs);
server.use(authenticate);
server.use("/api", userRoute);
server.use("/api", authRoute);
server.listen(PORT, () => {
console.log(`localhost running on port ${PORT}`);
});
// const { v4 : uuid} = require("uuid")
// console.log(uuid())
// const saltRounds = 10;
// const salt = bcrypt.genSaltSync(saltRounds);
// const hash = bcrypt.hashSync("test", salt);
// console.log(salt);
// console.log(hash);
// const foo = bcrypt.compareSync("test", hash); // true
// console.log(foo);
// server.get("/api/get-all-users", (req, res) => {
// const username = "test";
// return res.json({ username });
// });
// server.get("/api/user/:id", (req, res) => {
// const id = req.params.id;
// const username = req.body.username;
// const email = req.body.email;
// const user = {
// id,
// username,
// email,
// };
// return res.json({ user });
// });
// server.post("/api/user", (req, res) => {
// const username = req.body.username;
// const email = req.body.email;
// const user_payload = {
// username,
// email,
// };
// return res.json({ user_payload });
// });