Skip to content

Type Alias: Guard<N, O, A> ​

ts
type Guard<N, O, A> = <X>(context, ...rest) => Promise<Response | undefined>;

Defined in: packages/astro/src/server.ts:120

A guard typed with the names N it accepts and its options O: (context, ...names, options?). It resolves to undefined when the check passes, and to the Response to return (401, 403 or a redirect) when it does not.

Type Parameters ​

Type ParameterDefault type
N extends string-
O-
A extends AstroContextAstroContext

Type Parameters ​

Type Parameter
X extends readonly (GuardNames | O)[]

Parameters ​

ParameterType
contextA
...restX & RequirementArgs<X, N, O>

Returns ​

Promise<Response | undefined>

Released under the MIT License. Inspired by spatie/laravel-permission.