Skip to content

Type Alias: BeforeHandle ​

ts
type BeforeHandle = (ctx) => Promise<unknown>;

Defined in: packages/elysia/src/guards.ts:88

A guard, used as an Elysia beforeHandle hook: app.get('/x', handler, { beforeHandle: requireRole('admin') }) or app.guard({ beforeHandle: [...] }, (app) => ...). It returns nothing when the check passes, and the response of onUnauthenticated / onForbidden otherwise, which ends the request.

Parameters ​

ParameterType
ctxobject

Returns ​

Promise<unknown>

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