forked from OpenWF/SpaceNinjaServer
feat: implement loading of ability videos (#205)
This commit is contained in:
parent
cfcdaae668
commit
02e4562daa
@ -1,5 +1,6 @@
|
||||
import express from "express";
|
||||
import buildConfig from "@/static/data/buildConfig.json";
|
||||
import fs from "fs/promises";
|
||||
|
||||
const cacheRouter = express.Router();
|
||||
|
||||
@ -15,4 +16,20 @@ 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) => {
|
||||
try {
|
||||
const dir = req.path.substr(0, req.path.lastIndexOf("/"));
|
||||
const file = req.path.substr(dir.length + 1);
|
||||
const filePath = `static/data${dir}/${file}`;
|
||||
|
||||
// Return file if we have it
|
||||
await fs.access(filePath);
|
||||
const data = await fs.readFile(filePath, null);
|
||||
res.send(data);
|
||||
} catch (err) {
|
||||
// 404 if we don't
|
||||
res.status(404).end();
|
||||
}
|
||||
});
|
||||
|
||||
export { cacheRouter };
|
||||
|
Loading…
x
Reference in New Issue
Block a user