feat: add plugin configResolved (#2055)

This commit is contained in:
Marvin Hagemeister
2023-11-21 15:39:17 +01:00
committed by GitHub
parent 0a85a1fe5f
commit daf15aee6f
15 changed files with 134 additions and 1 deletions
@@ -0,0 +1,28 @@
import { defineConfig } from "$fresh/src/server/defines.ts";
const delay = (ms: number) => new Promise((r) => setTimeout(r, ms));
let called = false;
export default defineConfig({
plugins: [
{
name: "a",
async configResolved() {
await delay(1);
called = true;
},
middlewares: [
{
path: "/",
middleware: {
handler: async (_req, ctx) => {
const res = await ctx.next();
res.headers.append("X-Plugin-A", String(called));
return res;
},
},
},
],
},
],
});