-
Notifications
You must be signed in to change notification settings - Fork 448
/
Copy pathserver.js
37 lines (30 loc) · 948 Bytes
/
server.js
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
import express from "express";
import { exec } from "node:child_process";
import * as path from "path";
const app = express();
app.get("/app/*", (req, res) => {
const newPath = req.path.replace("/app/", "/");
res.redirect(301, `https://app.auto-editor.com${newPath}`);
});
app.get("/blog*", (req, res) => {
res.redirect(301, `https://basswood-io.com${req.path}`);
});
app.get("/options", (req, res) => {
res.redirect(301, "https://basswood-io.com/ref/options");
});
app.use(express.static("public", {
index: ["index.html"],
extensions: ["html"],
setHeaders: (res, filep, stat) => {
if (path.extname(filep) === "") {
res.set("Content-Type", "text/html");
}
}
}));
app.use((req, res) => {
let options = {
headers: {"Content-Type": "text/html"}
};
res.status(404).sendFile(path.join(__dirname, "public/404"), options);
});
app.listen(1337, (req, res) => console.log("running on http://localhost:1337"));