Routing
Understand how Logic Bee routes events to the correct hooks.
Overview
Logic Bee uses an event-driven routing system. Instead of traditional URL-based routing, events are dispatched to hooks based on their registered event name and collection.
How It Works
- A request arrives at the Logic Bee server
- The event router matches the request to registered hooks
- Pre-handlers run (authentication, validation, etc.)
- The matched hook executes
- Post-handlers run (logging, cleanup, etc.)
- The response is returned
Route Registration
Routes are implicitly defined by the @LogicHook decorator:
@LogicHook({
event: 'create-order',
collection: 'orders',
})
export class CreateOrderHook { ... }
This hook will automatically respond to POST /api/create-order.
Route Middleware
- Pre-handlers — Run before the hook (e.g., JWT validation)
- Post-handlers — Run after the hook (e.g., audit logging)
More examples coming soon.