@yaupon/handler
v0.0.0-dev
Published
🤲 Tiny handler API with own lifecycle and error handling
Downloads
3
Readme
🤲 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
},
}
})