0.0.0-dev • Published 1 year ago

@yaupon/handler v0.0.0-dev

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

🤲 Handler

A tiny yet simple library to handle messages, events, and requests. (WIP)

Features

  • Handler Registry, an object that can be used to register handler for a specific kind of message, event or request.
  • Middleware API, a way to intercept and modify the behavior of the handler.
  • Lifecycle API, a way to manage the lifecycle of the handler.
  • Error Handling, a way to handle errors that occur during the handling of the message, event or request.
  • Event-powered, event-emitter-based events to watch for the state of a handler.
  • Type-safe, TypeScript support out of the box.

Usage

const CreateUserHandler = new Handler<CreateUserDTO, void>({
    handle: async (dto) => {
        // create user
    },
    hooks: {
        onError: (error) => {
            // handle error
        },
    }
})
0.0.0-dev

1 year ago