# Nodejs Backend

> Node.js backend patterns for scalable APIs, microservices, and enterprise applications. Use when this capability is needed.

- Skill: `tomevault-io/nodejs-backend-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/nodejs-backend-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/nodejs-backend-2/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/nodejs-backend-2

---

# Node.js (Backend Patterns) Skill

Enterprise Node.js backends using Express/Fastify, TypeScript, and architectural patterns.

## Core Principles
- **TypeScript everywhere**. Fastify > Express (perf).
- **Clean Architecture**: Controllers → Services → Repositories → Entities.
- **12-Factor App**: Config from env, logging, health checks.

## Modular Behaviors
- **Project Setup**: `npm init -y && npm i -D typescript @types/node tsx`. `npm i fastify`.
- **API Structure**: `/src/routes`, `/src/services`, `/src/repositories`, `/src/entities`.
- **Dependency Injection**: `awilix` or `tsyringe`. Singletons for DB/connections.
- **Validation**: Zod schemas. `z.object({ name: z.string().min(1) })`.
- **Auth**: JWT with `jsonwebtoken`. Refresh tokens. Role-based with guards.
- **Database**: Prisma or Drizzle ORM. Connection pooling. Transactions for business logic.
- **Error Handling**: Global handler. HTTP status + structured error payload.
- **Testing**: `vitest` + `msw`. 80% coverage. Integration tests against test DB.
- **Monitoring**: `pino` logger. Prometheus metrics. Health endpoints `/health`, `/ready`.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/ultraxn) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-15 -->

