Type Alias: Guard<N, O, E>
ts
type Guard<N, O, E> = <A>(...args) => MiddlewareHandler<RbacEnv> & MiddlewareHandler<E>;Defined in: packages/hono/src/guards.ts:150
A guard typed with the names N it accepts and its options O: (...names, options?). 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. E is the env the returned middleware adds: RbacEnv<T> for the guards of createGuards<T>(), so a route after a typed guard keeps a typed c.var.rbac. The middleware is still a MiddlewareHandler<RbacEnv> too.
Type Parameters
| Type Parameter | Default type |
|---|---|
N extends string | - |
O | - |
E extends Env | RbacEnv |
Type Parameters
| Type Parameter |
|---|
A extends readonly (GuardNames | O)[] |
Parameters
| Parameter | Type |
|---|---|
...args | A & RequirementArgs<A, N, O> |
Returns
MiddlewareHandler<RbacEnv> & MiddlewareHandler<E>
