more stuff

This commit is contained in:
Mike 2024-12-25 17:41:02 -05:00
parent 12ee817d96
commit 03548eeb1e

View file

@ -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!");
});