-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
70 lines (64 loc) · 3 KB
/
Copy pathserver.js
File metadata and controls
70 lines (64 loc) · 3 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const express = require('express');
const mongoose = require('mongoose');
const ejs = require('ejs');
const colors = require('colors');
const dotenv = require('dotenv');
const fs = require('fs');
const path = require('path');
dotenv.config();
const app = express();
// frontend files
app.use(express.static('public'));
// 404 page
app.get("/404", (req, res) => {
fs.readFile(path.join(__dirname, "./public/404/404.html"), (err, data) => {
if (err) return console.error(err);
res.set('Content-Type', 'text/html')
res.status(404);
res.send(data);
});
});
// mongoose.connect(process.env.DB_URI, { dbName: "clt", useNewUrlParser: true, useUnifiedTopology: true });
// const db = mongoose.connection;
// db.on('error', (error) => console.error(error));
// db.once('open', () => console.log('Connected to Database'));
const redirectMap = new Map([
["/medium", "https://chrizftw.medium.com"],
["/twitch", "https://twitch.tv/chrizxzftw"],
["/bio", "https://dsc.bio/chriz"],
["/reddit", "https://reddit.com/user/chrizxzftw"],
["/github", "https://github.com/chrizxz"],
["/youtube", "https://www.youtube.com/channel/UCCSomYE1NzcG2AnOtrR5V3g?sub_confirmation=1"],
["/roblox", "https://www.roblox.com/users/729731435/profile"],
["/playlist", "https://open.spotify.com/playlist/2jY8XKNHjYmR3UhOHW4Zb6?si=a4595c5b92664f3f"],
["/pl", "https://open.spotify.com/playlist/2jY8XKNHjYmR3UhOHW4Zb6?si=a4595c5b92664f3f"],
["/playlist2", "https://open.spotify.com/playlist/4Ob6cNM3147iFcIMDDtYnp?si=23890ac10d6744fc"],
["/pl2", "https://open.spotify.com/playlist/4Ob6cNM3147iFcIMDDtYnp?si=23890ac10d6744fc"],
["/playlist3", "https://open.spotify.com/playlist/6aqs0yCZr7MIBRmfP4wMF4?si=bb62661a876f44a4"],
["/pl3", "https://open.spotify.com/playlist/6aqs0yCZr7MIBRmfP4wMF4?si=bb62661a876f44a4"],
["/steam", "https://steamcommunity.com/id/chrizftw/"],
["/minecraft", "https://namemc.com/chrizxz"],
["/spotify", "https://open.spotify.com/user/3lzvwkeppejdqmri51h330vza"],
["/twitter", "https://twitter.com/ChrizxzFTW"],
["/venox", "https://discord.com/invite/gAeMxAv9kp"],
["/chrizical", "https://www.urbandictionary.com/define.php?term=chrizical"],
["/wordler/invite", "https://discord.com/api/oauth2/authorize?client_id=1077433194166620180&permissions=278099396672&scope=applications.commands%20bot"],
["/wordler/tos", "https://gist.github.com/Chrizxz/f35117d847dcea193f3795b5c7199656"],
["/wordler/privacy", "https://gist.github.com/Chrizxz/84ae54cab3d291aab890cc556dd088a0"],
["/donate", "https://ko-fi.com/chrizxzftw"],
["/pay", "https://ko-fi.com/chrizxzftw"],
]);
app.get('/*', (req, res) => {
const rmPath = req.path;
const location = redirectMap.get(rmPath);
if (location) {
res.redirect(301, location);
} else {
res.status(404).sendFile(path.join(__dirname, 'public', '404/404.html'));
}
});
// start the server
const port = process.env.PORT || 6969;
app.listen(port, () => {
console.log(`Server started on `.blue + `Port: ${port}`.cyan.underline);
});