Function: createGuards()
ts
function createGuards<T, G>(defaults?): GuardsFor<TypesOf<T>, G>;Defined in: packages/elysia/src/guards.ts:188
Builds the guards with shared defaults (e.g. a custom onForbidden).
Pass the same type argument as createRbac<AppTypes>() (or typeof rbac) to check names at compile time: const { requirePermission } = createGuards<AppTypes>(). With per-guard names, G is the guard of the requests these guards run on: createGuards<AppRbac, 'api'>().
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends RbacTypeConfig | Rbac<RbacTypeConfig> | DefaultRbacTypes |
G extends string | DefaultGuardName<TypesOf<T>> & GuardName<TypesOf<T>> |
Parameters
| Parameter | Type |
|---|---|
defaults? | GuardHandlers<GuardHandlerContext<TypesOf<T>, G>> |
