mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-27 22:50:42 -05:00
more stuff
This commit is contained in:
parent
12ee817d96
commit
03548eeb1e
1 changed files with 13 additions and 5 deletions
|
@ -1,10 +1,19 @@
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const app = express();
|
const app = express();
|
||||||
|
const path = require("node:path");
|
||||||
const authorRouter = require("./routes/authorRouter");
|
const authorRouter = require("./routes/authorRouter");
|
||||||
const bookRouter = require("./routes/bookRouter");
|
const bookRouter = require("./routes/bookRouter");
|
||||||
const indexRouter = require("./routes/indexRouter");
|
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("/authors", authorRouter);
|
||||||
app.use("/books", bookRouter);
|
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) => {
|
app.get("/about", (req, res) => {
|
||||||
res.sendFile(
|
res.sendFile(
|
||||||
"/home/smig/repos/github/odin-codeprojects/basic-info-node-backend/src/content/about.html",
|
"/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) => {
|
app.use((req, res, next) => {
|
||||||
throw new Error("OH NO!");
|
throw new Error("OH NO!");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue