Formatting + Added Home Page
This commit is contained in:
+3
-3
@@ -108,12 +108,12 @@ app.get("/", authenticateToken, (request, response) => {
|
||||
response.sendFile(path.join(__dirname, ".\\public\\home.html"));
|
||||
});
|
||||
|
||||
app.post("/balance", authenticateToken, (request, response) => {
|
||||
app.get("/balance", authenticateToken, (request, response) => {
|
||||
/* #swagger.security = [{
|
||||
"bearerAuth": []
|
||||
}] */
|
||||
const username = request.user.username;
|
||||
|
||||
console.log(username);
|
||||
const allUsers = get_data();
|
||||
const me = allUsers.find(u => u.username === username);
|
||||
|
||||
@@ -121,7 +121,7 @@ app.post("/balance", authenticateToken, (request, response) => {
|
||||
return response.status(404).json({ error: "User not found" });
|
||||
}
|
||||
|
||||
response.json({ balance: me.money });
|
||||
response.json({ balance: me.money }).status(200);
|
||||
});
|
||||
|
||||
app.post("/verify", authenticateToken, (request, response) => {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
const logoutButton = document.getElementById("logout");
|
||||
const balance = document.getElementById("balance");
|
||||
try {
|
||||
const balanceRes = await fetch('/balance', {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
});
|
||||
if (balanceRes.ok) {
|
||||
const balanceData = await balanceRes.json();
|
||||
console.log(balanceData);
|
||||
balance.innerHTML = balanceData.balance;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
+6
-6
@@ -4,13 +4,13 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Home</title>
|
||||
<link rel="stylesheet" href="styles_home.css">
|
||||
<script src="frontend_home.js" defer></script> <!-- make sure this is included -->
|
||||
</head>
|
||||
<body>
|
||||
<button class="logout">
|
||||
Logout
|
||||
</button>
|
||||
<button class="balance">
|
||||
Check Balance
|
||||
</button>
|
||||
<button class="logout" id="logout">Logout</button>
|
||||
|
||||
<div class="balance">
|
||||
Balance: $<span id="balance">0</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -46,6 +46,8 @@ button.logout {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
button.balance {
|
||||
.balance {
|
||||
margin-top: 20px;
|
||||
color: #0f0;
|
||||
text-shadow: 0 0 5px #0f0, 0 0 10px #0f0;
|
||||
}
|
||||
Reference in New Issue
Block a user