Violets-Purgatory/index.js

64 lines
1.7 KiB
JavaScript
Raw Normal View History

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-02-28 09:09:44 -06:00
pageUpdater = require('./pageUpdater.js')
2024-02-29 08:50:37 -06:00
// ytjs = require("youtubei.js")
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-02-28 09:33:41 -06:00
// var mostRecentVideo = undefined
2023-11-16 15:16:22 -06:00
2024-01-25 23:29:28 -06:00
var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json')))
2024-02-28 09:33:41 -06:00
// var thumborInstances = config.thumborInstances
2024-02-28 09:33:41 -06:00
// var thumbCount = 0
2024-02-28 09:33:41 -06:00
// function getThumbor() {
// thumbCount += 1
// return thumborInstances[thumbCount % thumborInstances.length] + "unsafe"
// }
2023-10-20 21:53:49 -05:00
2024-02-22 09:15:08 -06:00
// async function getMostRecentVid() {
// innertube = await ytjs.Innertube.create()
// var video = await (await (await ytjs.Innertube.create()).getChannel('UChcrBJNJLZucy3TPyGyAY2g'))
// video = video.current_tab.content.contents[1].contents[0].content.items[0]
2024-02-13 13:21:53 -06:00
2024-02-22 09:15:08 -06:00
// mostRecentVideo = video.endpoint.payload.videoId
// console.log(mostRecentVideo)
// }
2024-02-13 13:21:53 -06:00
2024-02-22 09:15:08 -06:00
// getMostRecentVid()
2024-02-13 13:21:53 -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-02-18 08:01:58 -06:00
var cachePath = path.join(staticpath, 'cached')
2024-02-29 08:50:37 -06:00
var gamePath = path.join(__dirname, "games")
2024-02-28 09:33:41 -06:00
// var imgPath = path.join(staticpath, 'imgs')
2024-01-25 23:03:05 -06:00
2024-02-29 22:32:40 -06:00
app.use("/games", function (req, res, next) {
2024-02-29 09:02:30 -06:00
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp")
res.setHeader("Cross-Origin-Opener-Policy", "same-origin")
next()
2024-02-29 08:50:37 -06:00
});
app.use("/games", express.static(gamePath))
2024-02-18 08:01:58 -06:00
if (!fs.existsSync(cachePath)) {
fs.mkdirSync(cachePath)
} else {
var files = fs.readdirSync(cachePath)
for (let index = 0; index < files.length; index++) {
const file = files[index];
fs.rmSync(path.join(cachePath, file))
2024-01-25 23:07:26 -06:00
}
}
2024-02-29 08:50:37 -06:00
app.use(pageUpdater.middleWare)