-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·41 lines (29 loc) · 915 Bytes
/
app.js
File metadata and controls
executable file
·41 lines (29 loc) · 915 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
33
34
35
36
37
38
39
40
41
'use strict';
// Dependencies
const express = require("express");
const path = require("node:path");
const about = require("./src/about");
const post = require("./src/post");
const site = require("./src/site");
const app = express();
const port = 23979;
module.exports = app;
// Configuring the view engine
app.set("view engine", "ejs");
app.set("views", path.join(__dirname, "src/views"));
// Making static content available
app.use(express.static(path.join(__dirname, "src/public")));
app.get("/", site.index);
// Post list endpoint
app.get("/posts", post.list);
// Post list endpoint
app.get("/post/:id", post.display_post);
// Post about endpoint
app.get("/about", about.index);
// Matching all other endpoints and redirecting to home
app.use((req, res) => {
res.redirect('/');
});
app.listen(port, () => {
console.log(`🚀 dashou-dot-dev started and listening on port ${port} !`);
});