nodejs

Implements Node.js backend patterns for TypeScript services with layered architecture and error handling.

4|Updated Mar 28, 2026
One-click install
npx skills add https://github.com/minexo79/coser-card-maker --skill nodejs-minexo79
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nodejs
Source: https://github.com/minexo79/coser-card-maker/tree/main/.kilo/skills/nodejs/skills/nodejs
Command: npx skills add https://github.com/minexo79/coser-card-maker --skill nodejs-minexo79

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building Node.js backend services often leads to tangled code where business logic leaks into controllers, errors go unhandled, and configuration is scattered. This Skill provides proven patterns for structuring TypeScript backend applications with clean separation of concerns, consistent error handling, and testable code. ## Core Features & Use Cases - Layered Architecture: Implements the routes → controllers → services → repositories pattern with dependency injection for maintainable codebases. - Async Error Handling: Provides custom error classes, async handler wrappers, retry logic, timeouts, and Promise.all/allSettled patterns for robust async code. - Testing Strategies: Includes unit testing with mocked repositories, integration testing with supertest, and test data factories. - Use Case: When building a REST API with Express and TypeScript, apply these patterns to structure your UserService with a repository layer, wrap controllers with asyncHandler, and validate environment variables with zod schemas. ## Quick Start Ask the AI to scaffold a Node.js TypeScript service with layered architecture, custom error classes, and unit tests for a new API endpoint.

Frequently Asked Questions about nodejs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Node.js TypeScript backend project?

Use a layered architecture with routes defining endpoints, controllers handling HTTP requests, services containing business logic, and repositories managing data access. Dependencies flow downward from routes to repositories, keeping each layer focused on a single responsibility.

How to handle async errors in Express controllers?

Wrap async route handlers with an asyncHandler function that catches promise rejections and forwards them to Express error middleware. Define custom error classes like NotFoundError and ValidationError extending a base AppError with status codes for consistent error responses.

What is the difference between Promise.all and Promise.allSettled?

Promise.all rejects immediately when any promise fails, making it suitable for operations that must all succeed. Promise.allSettled waits for all promises and returns each result's status, allowing you to handle partial failures when fetching multiple independent resources.

How do I validate environment variables in Node.js?

Use zod to define a schema for process.env with types, defaults, and constraints like minimum string lengths for secrets. Parse process.env at startup so the application fails fast with clear errors when required configuration is missing or invalid.

How do I test a service layer without a real database?

Inject the repository as a constructor dependency and replace it with a mock object using vi.fn() in vitest. Mock repository methods to return test data or reject with errors, then assert the service calls them with correct arguments and handles failures properly.

When should I not put logic in Express controllers?

Controllers should only handle HTTP concerns like parsing requests and formatting responses. Business rules such as email validation, password hashing, and duplicate checks belong in the service layer, while database queries belong in repositories.