* fix(boards): add permissions to board summary schema to fix manage page crash The getAllBoards query fetches userPermissions and groupPermissions from the DB, but boardSummarySchema (the output validator) did not include them. tRPC stripped the fields, causing a TypeError when getBoardPermissionsAsync called .some() on undefined. * fix(backup): cast Buffer to Uint8Array for NextResponse body Node 24 narrowed the BodyInit type, making Buffer incompatible. Wrapping in Uint8Array satisfies the type constraint. * fix(lint): remove forbidden non-null assertions across backup and board code Replace non-null assertions with safe guards, optional chaining, and for-of iteration so oxlint passes in CI. Also remove unused Collapse import.
31 lines
885 B
TypeScript
31 lines
885 B
TypeScript
import fs from "fs";
|
|
import path from "path";
|
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
const wasmCandidates = [
|
|
path.join(process.cwd(), "public/sql-wasm.wasm"),
|
|
path.join(process.cwd(), "apps/nextjs/public/sql-wasm.wasm"),
|
|
path.resolve(process.cwd(), "../../node_modules/sql.js/dist/sql-wasm.wasm"),
|
|
path.join(process.cwd(), "node_modules/sql.js/dist/sql-wasm.wasm"),
|
|
];
|
|
|
|
let cachedWasm: Buffer | null = null;
|
|
|
|
export async function GET() {
|
|
if (!cachedWasm) {
|
|
const found = wasmCandidates.find((p) => fs.existsSync(p));
|
|
if (!found) {
|
|
return NextResponse.json({ error: "WASM binary not found" }, { status: 500 });
|
|
}
|
|
cachedWasm = fs.readFileSync(found);
|
|
}
|
|
|
|
return new NextResponse(new Uint8Array(cachedWasm), {
|
|
headers: {
|
|
"Content-Type": "application/wasm",
|
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
},
|
|
});
|
|
}
|