Skip to content

Service Module Patterns

Purpose

lib/services/* contains transport/domain service wrappers over API routes.

Service responsibilities

  • map method to endpoint
  • map params/body to request config
  • map response to stable frontend return type
  • avoid UI logic or component state decisions

Example modules

  • usersService (/users* routes)
  • systemService (/system* routes)
  • sessionService (/me/session* routes)

Conventions

  • Keep methods small and explicit.
  • Prefer named options { handleErrors?: boolean; context?: string }.
  • Keep endpoint-specific typing close to the service.