chore: restructure repository into packages/ folder (#3197)

We're having a growing number of packages in this repository. This PR
moves them into a `packages/` directory like it's commonly done in other
projects.
This commit is contained in:
Marvin Hagemeister
2025-08-06 15:52:45 +02:00
committed by GitHub
parent 27e407a1e3
commit 815b1940e3
184 changed files with 94 additions and 82 deletions
@@ -0,0 +1,33 @@
import { DEV_ERROR_OVERLAY_URL } from "../../../constants.ts";
import { HttpError } from "../../../error.ts";
import type { Middleware } from "../../../middlewares/mod.ts";
import { FreshScripts } from "../../../runtime/server/preact_hooks.tsx";
import { ErrorOverlay } from "./overlay.tsx";
export function devErrorOverlay<T>(): Middleware<T> {
return async (ctx) => {
const { config, url } = ctx;
if (url.pathname === config.basePath + DEV_ERROR_OVERLAY_URL) {
return ctx.render(<ErrorOverlay url={url} />);
}
try {
return await ctx.next();
} catch (err) {
if (ctx.req.headers.get("accept")?.includes("text/html")) {
let init: ResponseInit | undefined;
if (err instanceof HttpError) {
if (err.status < 500) throw err;
init = { status: err.status };
}
// At this point we're pretty sure to have a server error
// deno-lint-ignore no-console
console.error(err);
return ctx.render(<FreshScripts />, init);
}
throw err;
}
};
}