2023-10-20 21:53:49 -05:00
|
|
|
const express = require('express'),
|
2023-11-16 19:29:22 -06:00
|
|
|
path = require('path'),
|
|
|
|
fs = require('fs'),
|
2024-04-20 12:56:37 -05:00
|
|
|
pageUpdater = require('./pageUpdater.js'),
|
|
|
|
WebSocket = require("ws")
|
2023-10-20 21:53:49 -05:00
|
|
|
|
|
|
|
var app = express()
|
|
|
|
|
|
|
|
const PORT = process.env.PORT || 8080
|
|
|
|
|
2023-11-16 15:16:22 -06:00
|
|
|
const staticpath = path.join(__dirname, 'static')
|
2024-05-20 10:20:19 -05:00
|
|
|
const cachePath = path.join(__dirname, 'cached')
|
|
|
|
const assetPath = path.join(__dirname, "assets")
|
|
|
|
const configPath = path.join(__dirname, 'config')
|
2023-11-16 15:16:22 -06:00
|
|
|
|
2024-05-20 10:20:19 -05:00
|
|
|
const configFile = path.join(configPath, "config.json")
|
2024-05-20 10:45:24 -05:00
|
|
|
const announcementFile = path.join(configPath, "announcement.html")
|
2024-05-20 10:20:19 -05:00
|
|
|
|
|
|
|
if (!fs.existsSync(configPath)) {
|
|
|
|
fs.mkdirSync(configPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fs.existsSync(configFile)) {
|
|
|
|
fs.writeFileSync(configFile, fs.readFileSync(path.join(assetPath, "defaults/config.json")))
|
|
|
|
}
|
|
|
|
|
2024-05-20 10:45:24 -05:00
|
|
|
if (!fs.existsSync(announcementFile)) {
|
|
|
|
fs.writeFileSync(announcementFile, ``)
|
|
|
|
}
|
|
|
|
|
2024-05-20 10:20:19 -05:00
|
|
|
var constants = JSON.parse(fs.readFileSync(path.join(__dirname, 'constants.json')))
|
2024-01-25 23:29:28 -06:00
|
|
|
|
2023-11-16 15:16:22 -06:00
|
|
|
app.listen(PORT, () => {
|
|
|
|
console.log("Violet's Purgatory is now listening on port: " + PORT)
|
2023-11-03 13:01:13 -05:00
|
|
|
})
|
|
|
|
|
2024-04-20 06:50:20 -05:00
|
|
|
app.use("/fonts", express.static(path.join(assetPath, "fonts")))
|
2024-03-08 10:49:47 -06:00
|
|
|
app.use("/cached", express.static(cachePath))
|
2024-04-18 21:39:08 -05:00
|
|
|
app.use("/imgs", express.static(path.join(assetPath, "Images")))
|
2024-04-18 23:50:10 -05:00
|
|
|
app.use("/snds", express.static(path.join(assetPath, "Sounds")))
|
2024-03-08 10:49:47 -06:00
|
|
|
|
2024-06-08 18:31:34 -05:00
|
|
|
app.use("/emojis", express.static(path.join(cachePath, "emojis")))
|
|
|
|
|
2024-02-18 08:01:58 -06:00
|
|
|
if (!fs.existsSync(cachePath)) {
|
|
|
|
fs.mkdirSync(cachePath)
|
2024-01-25 23:07:26 -06:00
|
|
|
}
|
|
|
|
|
2024-06-08 19:16:44 -05:00
|
|
|
if (!fs.existsSync(path.join(cachePath, "emojis"))) {
|
|
|
|
fs.mkdirSync(path.join(cachePath, "emojis"))
|
|
|
|
}
|
|
|
|
|
2024-04-13 00:08:16 -05:00
|
|
|
app.get("/discHTML", (req, res) => {
|
|
|
|
res.send(pageUpdater.getActivities())
|
|
|
|
})
|
|
|
|
|
2024-03-18 20:57:48 -05:00
|
|
|
app.use(pageUpdater.middleWare)
|
|
|
|
|
|
|
|
process.on('uncaughtException', (err, origin) => {
|
|
|
|
fs.writeSync(
|
|
|
|
process.stderr.fd,
|
|
|
|
`Caught exception: ${err}\n` +
|
|
|
|
`Exception origin: ${origin}`,
|
|
|
|
);
|
|
|
|
});
|