Skip to content

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

ts
type Guard<N, O, R> = <A>(event, ...args) => Promise<R>;

Defined in: packages/sveltekit/src/server/guards.ts:104

A guard typed with the names N it accepts and its options O: (event, ...names, options?). It resolves to the subject (R) when the check passes, and throws (SvelteKit's error() / redirect(), or your handler) when it does not. Every name (each part of a 'a|b' list, each array item) must be one of N; with N = string, any name is. A call without names, or with options that are not the last argument, is a type error.

Type Parameters ​

Type ParameterDefault type
N extends string-
O-
RSubjectRbac

Type Parameters ​

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

Parameters ​

ParameterType
eventRequestEvent
...argsA & RequirementArgs<A, N, O>

Returns ​

Promise<R>

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