Skip to content

handleryevent handling like it should be!

Add decorator-powered, class-based and fully typed event handlers to your [nodejs, emittery, web... everything] app!

handlery Logo

build statusdocs deploymentGitHub deploymentshandlery on npm


handlery (like emittery but for 'handle') is a super clean and easy way to handle any kind of events with class-based handlers (and decorators!). It works with all kinds of event emitters (emittery, nodejs' EventEmitter...) out of the box! Just look at it:

ts
@register()
class UserHandler extends EventHandler {
  @on('user.add')
  public handleAddUser(user: Events['user.add'], ctx: HandlerContext) {
    ctx.emitter.emit('user.add.response', { ... })
    // ...
  }
}

It requires typescript decorators support (modern, ECMA decorators. Not Decorators.Legacy etc.) And an event emitter like emittery or node's built-in EventEmitter.

Installation ​

It's on npm!

bash
npm install handlery
# or
pnpm add handlery
# or
yarn add handlery