From dbc7509fbd7783735b3832000067b41203d085aa Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Thu, 28 Sep 2023 16:57:48 -0400 Subject: [PATCH] *: stubbing out a page for "what's this about?" Fixes #2 Signed-off-by: Vincent Batts --- app.js | 10 +++---- app.test.js | 14 ++++++++++ {asset => wwwroot/asset}/frontend.js | 0 index.html => wwwroot/index.html | 9 ++++++ wwwroot/what.html | 42 ++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 6 deletions(-) rename {asset => wwwroot/asset}/frontend.js (100%) rename index.html => wwwroot/index.html (87%) create mode 100644 wwwroot/what.html diff --git a/app.js b/app.js index 9513e68..9fb516d 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,6 @@ const express = require("express"); const fs = require("fs"); -const path = require("path"); +const join = require("path").join; const morgan = require("morgan"); const bodyParser = require("body-parser"); const sqlite3 = require("sqlite3").verbose(); @@ -37,12 +37,13 @@ const db = new sqlite3.Database(config.db_path, (err) => { }); var accessLogStream = fs.createWriteStream( - path.join(__dirname, "log", "access.log"), + join(__dirname, "log", "access.log"), { flags: "a" }, ); app.use(bodyParser.json()); app.use(morgan("combined", { stream: accessLogStream })); +app.use(express.static(join(__dirname, './wwwroot'))); var animals; // check and load animals into redis @@ -77,10 +78,7 @@ try { // Serve the HTML file app.get("/", (req, res) => { - res.sendFile(__dirname + "/index.html"); -}); -app.get("/asset/frontend.js", (req, res) => { - res.sendFile(__dirname + "/asset/frontend.js"); + res.sendFile(__dirname + "/wwwroot/index.html"); }); // Route to get a random animal name diff --git a/app.test.js b/app.test.js index 6450016..c333dde 100644 --- a/app.test.js +++ b/app.test.js @@ -9,6 +9,20 @@ describe('GET /', () => { //expect(response.body.message).toBe('Hello, World!'); }); }); +describe('GET /index.html', () => { + it('should respond with 200 status', async () => { + const response = await request(app).get('/index.html'); + expect(response.statusCode).toBe(200); + //expect(response.body.message).toBe('Hello, World!'); + }); +}); +describe('GET /what.html', () => { + it('should respond with 200 status', async () => { + const response = await request(app).get('/what.html'); + expect(response.statusCode).toBe(200); + //expect(response.body.message).toBe('Hello, World!'); + }); +}); describe('GET /asset/frontend.js', () => { it('should respond with 200 status', async () => { diff --git a/asset/frontend.js b/wwwroot/asset/frontend.js similarity index 100% rename from asset/frontend.js rename to wwwroot/asset/frontend.js diff --git a/index.html b/wwwroot/index.html similarity index 87% rename from index.html rename to wwwroot/index.html index 2e985cf..c52cdf0 100644 --- a/index.html +++ b/wwwroot/index.html @@ -20,6 +20,12 @@

+ + @@ -34,6 +40,9 @@ #startOver { text-align: center; } +#whatsThisAllAbout { + text-align: center; +} #footer { bottom: 2px; height: 40px; diff --git a/wwwroot/what.html b/wwwroot/what.html new file mode 100644 index 0000000..e4ae883 --- /dev/null +++ b/wwwroot/what.html @@ -0,0 +1,42 @@ + + + + + + Is this a Critter? + + + +
+

What's this all about?

+
+ + + + + + + +