import { SessionAuthObject } from '@clerk/backend'; import { GetAuthFnNoRequest, RedirectFun } from '@clerk/backend/internal'; import { APIContext } from 'astro'; /** * These types are copied from astro. * In Astro v3 and v4 both resolve in the save types, but * in v3 `MiddlewareNext` is a generic and in v4 it is not. */ type MiddlewareNext = () => Promise; type MiddlewareHandler = (context: APIContext, next: MiddlewareNext) => Promise | Response | Promise | void; type AstroMiddleware = MiddlewareHandler; type AstroMiddlewareContextParam = APIContext; type AstroMiddlewareNextParam = MiddlewareNext; type AstroMiddlewareReturn = Response | Promise; type SessionAuthObjectWithRedirect = SessionAuthObject & { redirectToSignIn: RedirectFun; }; type AuthFn = GetAuthFnNoRequest; export type { AstroMiddleware as A, SessionAuthObjectWithRedirect as S, AstroMiddlewareContextParam as a, AstroMiddlewareNextParam as b, AstroMiddlewareReturn as c, AuthFn as d };