feat(server): add isPartial to context types (#1977)

This commit is contained in:
Reed von Redwitz
2023-10-26 22:26:36 +02:00
committed by GitHub
parent 7ad4610e3a
commit 63ac1e6362
13 changed files with 333 additions and 121 deletions
@@ -0,0 +1,18 @@
import { MiddlewareHandlerContext } from "$fresh/server.ts";
export type IsPartialInContextState = {
setFromMiddleware: boolean;
notSetFromMiddleware: boolean;
};
export async function handler(
_req: Request,
ctx: MiddlewareHandlerContext<IsPartialInContextState>,
) {
if (ctx.isPartial) {
ctx.state.setFromMiddleware = true;
} else {
ctx.state.notSetFromMiddleware = true;
}
return await ctx.next();
}