From 03548eeb1ea4057d1de8e531d305bd4896812714 Mon Sep 17 00:00:00 2001 From: Mike Smith <89040888+smiggiddy@users.noreply.github.com> Date: Wed, 25 Dec 2024 17:41:02 -0500 Subject: [PATCH] more stuff --- basic-info-node-backend/src/app.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/basic-info-node-backend/src/app.js b/basic-info-node-backend/src/app.js index b236389..aacc5a5 100644 --- a/basic-info-node-backend/src/app.js +++ b/basic-info-node-backend/src/app.js @@ -1,10 +1,19 @@ const express = require("express"); const fs = require("fs"); const app = express(); +const path = require("node:path"); const authorRouter = require("./routes/authorRouter"); const bookRouter = require("./routes/bookRouter"); const indexRouter = require("./routes/indexRouter"); +const links = [ + { href: "/", text: "Home" }, + { href: "/views-test", text: "Views Test" }, +]; + +app.set("views", path.join(__dirname, "views")); +app.set("view engine", "ejs"); + app.use("/authors", authorRouter); app.use("/books", bookRouter); @@ -20,6 +29,10 @@ app.get("/", (req, res) => { }); }); +app.get("/views-test", (req, res) => { + res.render("index", { links: links, message: "deez" }); +}); + app.get("/about", (req, res) => { res.sendFile( "/home/smig/repos/github/odin-codeprojects/basic-info-node-backend/src/content/about.html", @@ -38,11 +51,6 @@ app.get("/contact-me", (req, res) => { ); }); -app.use((req, res, next) => { - console.log("Another middleware"); - res.send("Response from this middleware"); -}); - app.use((req, res, next) => { throw new Error("OH NO!"); });