Skip to content

Overview

The LightTs CLI is the core tool for managing LightTs projects, providing an intuitive interface for project initialization, component generation, and feature integration. Inspired by NestJS but focused on generating native Node.js code, the CLI ensures simplicity and flexibility.

  • init: Initialize a new LightTs project with customizable options.
  • generate (or g): Create controllers, services, validators, or resources.
  • add (or a): Add features like JWT, CORS, validation (Joi), or database support.
  • Interactive Prompts: Guides you through project setup with clear questions and options.
  • Flexible Naming: Supports Angular-style (auth.service.ts) or regular (auth.ts) file naming.
  • Feature Integration: Generates customizable, native Node.js code for features.
  • Alias Support: Use either lightts or lts for all commands.

To see all available commands and options, run:

Terminal window
lts --help

Run lts init to set up a new LightTs project with a clean, modular structure. The CLI’s interactive prompts guide you through selecting options like file naming style and feature inclusions, ensuring a tailored setup.

The lts init command creates the following structure, organized for scalability and clarity:

  • Directorysrc/
    • Directorycore/
      • cors.core.ts
      • logger.core.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
      • Directoryresponses/
        • data.response.ts
        • index.ts
        • message.response.ts
    • Directorydatabase/
      • index.ts
      • Directoryentities/
      • Directorymigrations/
      • Directorydummy/
        • index.ts
        • Directoryscripts/
      • Directoryseeders/
        • index.ts
        • Directoryscripts/
    • Directorymiddleware/
      • auth.middleware.ts
      • validator.middleware.ts
    • Directorymodules/
      • Directoryhello/
        • hello.controller.ts
        • hello.schema.ts
        • hello.service.ts
      • Directoryuser/
        • user.controller.ts
        • user.schema.ts
        • user.service.ts
    • Directorytypes/
      • express.d.ts
    • routes.ts
    • config.ts
  • tsconfig.json
  • .env
  • .prettierrc
  • .prettierignore
  • .gitignore
  • eslint.config.js
  • index.ts
  • package.json
  • ReadMe.md

LightTs follows consistent naming conventions to keep your codebase clean:

  • Files & Folders: kebab-case (e.g., user.controller.ts, core/errors/).
  • Functions & Variables: camelCase (e.g., getUsers, userRepo).