Add generate:client script

This commit is contained in:
Madeline
2022-09-26 20:33:57 +10:00
parent 6365e27c3c
commit e700ab1e65
6 changed files with 149 additions and 4 deletions
+9
View File
@@ -7,6 +7,8 @@ import { Config } from "@fosscord/util";
const ASSET_FOLDER_PATH = path.join(__dirname, "..", "..", "..", "assets");
let hasWarnedAboutCache = false;
export default function TestClient(app: Application) {
const agent = new ProxyAgent();
const assetCache = new Map<string, { response: FetchResponse; buffer: Buffer; }>();
@@ -44,8 +46,15 @@ export default function TestClient(app: Application) {
app.use("/assets", express.static(path.join(ASSET_FOLDER_PATH, "public")));
app.use("/assets", express.static(path.join(ASSET_FOLDER_PATH, "cache")));
app.get("/assets/:file", async (req: Request, res: Response) => {
if (!hasWarnedAboutCache) {
hasWarnedAboutCache = true;
if (req.params.file.includes(".js"))
console.warn(`[TestClient] Cache miss for file ${req.params.file}! Use 'npm run generate:client' to cache and patch.`);
}
delete req.headers.host;
var response: FetchResponse;
var buffer: Buffer;
+1 -1
View File
@@ -9,7 +9,7 @@ import {
} from "@fosscord/util";
export async function Close(this: WebSocket, code: number, reason: string) {
console.log("[WebSocket] closed", code, reason);
console.log("[WebSocket] closed", code, reason.toString());
if (this.heartbeatTimeout) clearTimeout(this.heartbeatTimeout);
if (this.readyTimeout) clearTimeout(this.readyTimeout);
this.deflate?.close();