Skip to content

Overview

LightTs includes built-in response and error handling classes as part of every project initialized with lts init. These core tools, built with native Node.js and Express, standardize API responses and errors, keeping your code clean and aligned with LightTs’s simplicity, like other utilities such as CORS and logging.

These classes are included in src/core/ when you create a LightTs project, using kebab-case for file names:

  • Directorysrc/
    • Directorycore/
      • Directoryresponses/
        • data.response.ts
        • message.response.ts
        • index.ts
      • Directoryerrors/
        • bad-request.error.ts
        • conflict.error.ts
        • forbidden.error.ts
        • handler.error.ts
        • index.ts
        • not-found.error.ts
        • server-error.error.ts
        • unauthorized.error.ts

Response Classes

Use HttpResponse, DataResponse, and MessageResponse for consistent API success responses.

Error Classes

Use HttpError and specific error classes like ConflictError for robust error handling.