Skip to content

Toolkit

LightTs is your toolkit for crafting APIs with speed, clarity, and control. Built on standard Node.js libraries, it blends Express’s simplicity with NestJS-inspired structure. Explore the features below to see why it’s the perfect fit for your next project.

CLI Tooling

The lts CLI makes API development a breeze. Initialize projects, generate components, or add features like JWT with simple commands.

  1. Init: lts init my-api
  2. Generate: lts g resource user
  3. Add: lts add jwt

Node.js & Express

Powered by express and standard libraries like jsonwebtoken and joi. Get familiar routing and transparent, editable code with no hidden magic.

Flexible Naming

Choose Angular-style (user.service.ts) or standard (user.ts) naming during lts init for a consistent codebase.

Responses & Errors

Use DataResponse and MessageResponse for clean outputs, plus error classes like BadRequestError for consistent handling.

src/modules/user/user.service.ts
import { DataResponse } from '@/core/responses/data.response';
import { Request, Response } from 'express';
export default {
get: async (req: Request, res: Response) => {
const users = [{ id: 1, name: 'John Doe' }];
return new DataResponse(res, {
data: users,
message: 'Users fetched like a pro!',
statusCode: 200
});
}
};

Feature Integration

Add JWT, validation, CORS, or TypeORM with one command. Explore options in Add Features.

Terminal window
lts add jwt
src/models/user/user.controller.ts
import express from 'express';
import services from './user.service';
import { validateToken } from '@/middleware/auth.middleware';
const router = express.Router();
router.post('/', validateToken(['admin']), services.create);

Database Support

Seamlessly integrate TypeORM for PostgreSQL, MySQL, MariaDB, or MongoDB, with migrations and seeders.

src/database/entities/user.entity.ts
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
email: string;
}

Code Quality

Optional setup for ESLint, Prettier, and Husky during lts init to keep your code clean and consistent.

Modular Structure

Organize code into modules with controllers, services, and validators for scalability.

src/modules/user/user.service.ts
import { DataResponse } from '@/core/responses/data.response';
import { Request, Response } from 'express';
export default {
get: async (req: Request, res: Response) => {
const users = [{ id: req.params.id, name: 'John Doe' }];
return new DataResponse(res, {
data: users,
message: 'Users fetched like a pro!',
statusCode: 200
});
}
}