create some page templates

This commit is contained in:
Holly Stubbs 2024-04-22 17:02:31 +01:00
parent 25b1644a33
commit 88e92051e3
Signed by: tgpholly
GPG Key ID: B8583C4B7D18119E
5 changed files with 51 additions and 2 deletions

View File

@ -16,6 +16,8 @@ const users = new FunkyArray<string, RemoteUser>();
new Database(Config.database.address, Config.database.port, Config.database.username, Config.database.password, Config.database.name);
// Web stuff
const fastify = Fastify({
logger: false
});
@ -30,6 +32,24 @@ fastify.get("/", async (req, res) => {
return res.view("templates/index.ejs", { });
});
fastify.get("/account", async (req, res) => {
return "TODO";
});
fastify.get("/account/login", async (req, res) => {
return res.view("templates/account/login.ejs", { });
});
fastify.get("/account/register", async (req, res) => {
return res.view("templates/account/register.ejs", { });
});
fastify.setNotFoundHandler(async (req, res) => {
return res.view("templates/404.ejs", { });
});
// Websocket stuff
const websocketServer = new WebSocketServer({
port: Config.ports.ws
}, () => {

3
server/templates/404.ejs Normal file
View File

@ -0,0 +1,3 @@
<%- include("base/header") -%>
<h1 class="text-center" style="font-size:10rem">404!</h1>
<%- include("base/footer") -%>

View File

@ -0,0 +1,22 @@
<%- include("../base/header") -%>
<h1 class="text-center mb-5">Login</h1>
<form>
<div class="row">
<div class="col-4"></div>
<div class="col-4">
<div class="form-group">
<label class="form-label">Username</label>
<input class="form-control" type="text" name="u" maxlength="32" required />
</div>
<div class="form-group mt-3">
<label class="form-label">Password</label>
<input class="form-control" type="password" name="p" required />
</div>
<div class="text-center mt-3">
<input class="btn btn-primary" type="submit" value="Login" />
</div>
</div>
<div class="col-4"></div>
</div>
</form>
<%- include("../base/footer") -%>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -20,7 +20,8 @@
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
</ul>
<a class="nav-link active" aria-current="page" href="/account/login">Login</a>
</div>
</div>
</nav>
<div class="container pt-3">
<div class="container pt-5">

View File

@ -0,0 +1,3 @@
<%- include("base/header") -%>
<h1>Welcome back USER!</h1>
<%- include("base/footer") -%>