feat: implement loading of ability videos #205

Merged
Sainan merged 2 commits from ability-videos into main 2024-05-29 16:44:54 -07:00
Showing only changes of commit afee26aad3 - Show all commits

View File

@ -1,5 +1,6 @@
import express from "express";
import buildConfig from "@/static/data/buildConfig.json";
import fs from "fs";
const cacheRouter = express.Router();
@ -15,4 +16,18 @@ cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (_req, res)
res.sendFile(`static/data/H.Cache_${buildConfig.version}.bin`, { root: "./" });
});
cacheRouter.get(/\.bk2!/, async (req, res) => {
const dir = req.path.substr(0, req.path.lastIndexOf("/"));
const file = req.path.substr(dir.length + 1);
// Return file if we have it
if (fs.existsSync(`static/data${dir}/${file}`)) {
res.send(fs.readFileSync(`static/data${dir}/${file}`, null));
return;
}
// 404 if we don't
res.status(404).end();
});
export { cacheRouter };