Skip to main content

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

  1. A request arrives at the Logic Bee server
  2. The event router matches the request to registered hooks
  3. Pre-handlers run (authentication, validation, etc.)
  4. The matched hook executes
  5. Post-handlers run (logging, cleanup, etc.)
  6. 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.