feat: support async route components (#1388)

This commit is contained in:
Marvin Hagemeister
2023-07-12 21:09:56 +02:00
committed by GitHub
parent e2a1bf8643
commit 62a5613a46
20 changed files with 564 additions and 96 deletions
@@ -0,0 +1,15 @@
import { RouteContext } from "../../../../server.ts";
import { delay } from "../../../deps.ts";
export default async function Foo(_req: Request, context: RouteContext) {
await delay(1);
const value = JSON.stringify(context, (_key, value) => {
if (typeof value === "function") return value.constructor.name;
return value;
}, 2);
return new Response(value, {
status: 200,
headers: { "Content-Type": "application/json" },
});
}