This repository was archived by the owner on Nov 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
51 lines (44 loc) · 1.22 KB
/
Copy pathserver.js
File metadata and controls
51 lines (44 loc) · 1.22 KB
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
const express = require("express");
const path = require("path");
const { handleEmailVerification } = require("./services/emailVerification");
const {
handlePasswordUpdation,
handlePasswordPage,
} = require("./services/resetPassword");
const { handleRecoverEmail } = require("./services/emailRecovery");
const app = express();
const port = 3000;
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "pages", "index.html"));
});
app.get("/__/auth/action", (req, res) => {
const { mode } = req.query;
switch (mode) {
case "verifyEmail":
handleEmailVerification(req, res);
break;
case "resetPassword":
handlePasswordPage(req, res);
break;
case "recoverEmail":
handleRecoverEmail(req, res);
break;
default:
res.status(400).send("Invalid mode specified");
}
});
app.post("/__/auth/action", (req, res) => {
const { mode } = req.body;
switch (mode) {
case "resetPassword":
handlePasswordUpdation(req, res);
break;
default:
res.status(400).send("Invalid mode specified");
}
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});