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.
Key Commands
Section titled “Key Commands”init: Initialize a new LightTs project with customizable options.generate(org): Create controllers, services, validators, or resources.add(ora): Add features like JWT, CORS, validation (Joi), or database support.
CLI Features
Section titled “CLI Features”- 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
lighttsorltsfor all commands.
To see all available commands and options, run:
lts --helpInitialize a Project
Section titled “Initialize a Project”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.
Project Structure
Section titled “Project Structure”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
Naming Conventions
Section titled “Naming Conventions”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).