Nestjs Clean Typescript

by mindrally97184105b5daNo license269 starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated 5 weeks ago

Clean NestJS API development with TypeScript following SOLID principles, modular architecture, and comprehensive testing practices.

Instructions onlySoftware Development
AI-generated overview

Guidelines for writing clean NestJS APIs in TypeScript with SOLID principles, modular architecture and testing.

What it does
This skill provides a set of coding guidelines for developing NestJS APIs in TypeScript. It covers general TypeScript principles, naming conventions, function design, data and class rules, NestJS-specific architecture such as modules, MikroORM entities, DTOs and core interceptors, and testing with Jest. It produces guidance rather than code or files.
When to use it
Use it when writing or reviewing NestJS API code in TypeScript and you want consistent conventions for typing, structure and tests. It suits teams standardizing modular NestJS services and unit or end-to-end testing practices.
Requirements
No scripts or tooling are required; it is instructions only. The guidance assumes a NestJS project using TypeScript, MikroORM, class-validator and Jest.

NestJS Clean TypeScript

Guidelines by Alberto Basalo for developing clean NestJS APIs using TypeScript. These rules emphasize strong typing, clean code principles, and architectural best practices.

TypeScript General Principles

  • Always declare the type of each variable and function (parameters and return value)
  • Avoid using any; create necessary types instead
  • Use JSDoc for public classes and methods
  • One export per file

Naming Conventions

  • PascalCase for classes
  • camelCase for variables and functions
  • kebab-case for files and directories
  • UPPERCASE for environment variables
  • Boolean variables use prefixes: isX, hasX, canX

Function Design

  • Write short functions with a single purpose. Less than 20 instructions
  • Use early returns to avoid nesting
  • Apply RO-RO pattern: pass objects for multiple parameters, return objects for results

Data and Classes

  • Prefer immutability for data with readonly and as const
  • Follow SOLID principles
  • Classes should have:
    • Less than 200 instructions
    • Fewer than 10 public methods
    • Fewer than 10 properties

NestJS Specific Guidelines

  • Use modular architecture with one module per domain/route
  • Use MikroORM entities for persistence
  • One service per entity
  • DTOs validated with class-validator
  • Global filters, middlewares, guards, and interceptors in core module

Testing

  • Use Jest framework
  • Follow Arrange-Act-Assert convention
  • Write unit tests for each public function
  • Include end-to-end tests per API module

Source and attribution

Source:mindrally/skillsinnestjs-clean-typescriptat commit9718410

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal

Nestjs Clean Typescript Agent Skill | SourceWeft