file path handling in route to use absolute path
This commit is contained in:
parent
fa90ce0571
commit
166606fa8d
@ -3,18 +3,19 @@ import https from "https";
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import { app } from "./app";
|
import { app } from "./app";
|
||||||
import { logger } from "./utils/logger";
|
import { logger } from "./utils/logger";
|
||||||
|
import { join } from "path";
|
||||||
//const morgan = require("morgan");
|
//const morgan = require("morgan");
|
||||||
//const bodyParser = require("body-parser");
|
//const bodyParser = require("body-parser");
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync("static/certs/key.pem"),
|
key: fs.readFileSync(join(__dirname, "../static/certs/key.pem")),
|
||||||
cert: fs.readFileSync("static/certs/cert.pem"),
|
cert: fs.readFileSync(join(__dirname, "../static/certs/cert.pem")),
|
||||||
passphrase: "123456"
|
passphrase: "123456"
|
||||||
};
|
};
|
||||||
|
|
||||||
// const server = http.createServer(app).listen(80);
|
// const server = http.createServer(app).listen(80);
|
||||||
http.createServer(app).listen(80, () => logger.info("cache server started on port 80"));
|
http.createServer(app).listen(80, () => logger.info("cache server started on port 80"));
|
||||||
const server = https.createServer(options, app).listen(443, () => logger.info("game server started on port 443"));
|
https.createServer(options, app).listen(443, () => logger.info("game server started on port 443"));
|
||||||
|
|
||||||
// server.keepAliveTimeout = 60 * 1000 + 1000;
|
// server.keepAliveTimeout = 60 * 1000 + 1000;
|
||||||
// server.headersTimeout = 60 * 1000 + 2000;
|
// server.headersTimeout = 60 * 1000 + 2000;
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import config from "@/config.json";
|
import config from "@/config.json";
|
||||||
|
import { join } from "path";
|
||||||
|
|
||||||
const cacheRouter = express.Router();
|
const cacheRouter = express.Router();
|
||||||
|
|
||||||
cacheRouter.get("/B.Cache.Dx11.bin.*", (_req, res) => {
|
cacheRouter.get("/B.Cache.Dx11.bin.*", (_req, res) => {
|
||||||
res.sendFile("static/data/B.Cache.Dx11_33.0.6.bin", { root: "./" });
|
res.sendFile(join(__dirname, "../../static/data/B.Cache.Dx11_33.0.6.bin"));
|
||||||
});
|
});
|
||||||
|
|
||||||
cacheRouter.get("/B.Cache.Windows_en.bin*", (_req, res) => {
|
cacheRouter.get("/B.Cache.Windows_en.bin*", (_req, res) => {
|
||||||
res.sendFile("static/data/B.Cache.Windows_en_33.0.10.bin", { root: "./" });
|
res.sendFile(join(__dirname, "../../static/data/B.Cache.Windows_en_33.0.10.bin"));
|
||||||
});
|
});
|
||||||
|
|
||||||
cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (_req, res) => {
|
cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (_req, res) => {
|
||||||
res.sendFile(`static/data/H.Cache_${config.version}.bin`, { root: "./" });
|
res.sendFile(join(__dirname, `../../static/data/H.Cache_${config.version}.bin`));
|
||||||
});
|
});
|
||||||
|
|
||||||
export { cacheRouter };
|
export { cacheRouter };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user