-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (24 loc) · 779 Bytes
/
app.js
File metadata and controls
32 lines (24 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import express from "express";
import path from "path";
import { fileURLToPath } from "url";
import categories from "./src/data/categories.js";
import categoryRouter from "./src/routes/categoryRouter.js";
// __dirname replacement in ES modules
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
// Set EJS as templating engine
app.set("view engine", "ejs");
app.set("views", path.join(__dirname, "src/views"));
// Serve static files
app.use(express.static(path.join(__dirname, "public")));
// Root route
app.get("/", (req, res) => {
res.render("index", {
title: "Nameify | Free Business Name Generator",
categories,
});
});
// Use category router
app.use(categoryRouter);
export default app;