From 88e92051e3f35e7c6498d5d24487c184cdb4d1bf Mon Sep 17 00:00:00 2001 From: Holly Date: Mon, 22 Apr 2024 17:02:31 +0100 Subject: [PATCH] create some page templates --- server/index.ts | 20 ++++++++++++++++++++ server/templates/404.ejs | 3 +++ server/templates/account/login.ejs | 22 ++++++++++++++++++++++ server/templates/base/header.ejs | 5 +++-- server/templates/home.ejs | 3 +++ 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 server/templates/404.ejs create mode 100644 server/templates/account/login.ejs create mode 100644 server/templates/home.ejs diff --git a/server/index.ts b/server/index.ts index 977bfcf..e54d521 100644 --- a/server/index.ts +++ b/server/index.ts @@ -16,6 +16,8 @@ const users = new FunkyArray(); 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 }, () => { diff --git a/server/templates/404.ejs b/server/templates/404.ejs new file mode 100644 index 0000000..71c5ac2 --- /dev/null +++ b/server/templates/404.ejs @@ -0,0 +1,3 @@ +<%- include("base/header") -%> +

404!

+<%- include("base/footer") -%> \ No newline at end of file diff --git a/server/templates/account/login.ejs b/server/templates/account/login.ejs new file mode 100644 index 0000000..c0daa8e --- /dev/null +++ b/server/templates/account/login.ejs @@ -0,0 +1,22 @@ +<%- include("../base/header") -%> +

Login

+
+
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+<%- include("../base/footer") -%> \ No newline at end of file diff --git a/server/templates/base/header.ejs b/server/templates/base/header.ejs index 3bf676f..25b1afe 100644 --- a/server/templates/base/header.ejs +++ b/server/templates/base/header.ejs @@ -1,5 +1,5 @@ - + @@ -20,7 +20,8 @@ + Login -
\ No newline at end of file +
\ No newline at end of file diff --git a/server/templates/home.ejs b/server/templates/home.ejs new file mode 100644 index 0000000..be3e626 --- /dev/null +++ b/server/templates/home.ejs @@ -0,0 +1,3 @@ +<%- include("base/header") -%> +

Welcome back USER!

+<%- include("base/footer") -%> \ No newline at end of file