Skip to content

Variable: OnAfterHandle

ts
const OnAfterHandle: (options?) => MethodDecorator;

Defined in: packages/core/src/decorators/lifecycle.decorators.ts:152

Hook called after request handler

Parameters

ParameterTypeDescription
options?{ before?: boolean; }-
options.before?booleanInsert before other hooks

Returns

MethodDecorator

See

https://elysiajs.com/essential/life-cycle.html#on-after-handle

Example

typescript
@Controller('/users')
export class UserController {
  @OnAfterHandle()
  async modifyResponse(context: Context) {
    if (context.response && typeof context.response === 'object') {
      context.response.timestamp = new Date().toISOString();
    }
  }
}

Released under the MIT License.