본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)48k · #5309

nodejs-best-practices

하는 일

이 가이드는 Node.js로 프로그래밍할 때 좋은 결정을 내리는 방법을 가르칩니다. 코드를 그대로 복사하기보다 선택의 원리를 이해하는 데 초점을 맞춥니다. 다양한 상황에 맞는 최선의 도구와 접근 방식을 고르도록 돕습니다.

사용하는 경우

  • ✓어떤 ‘프레임워크’(코드 구성 도구)를 쓸지 결정할 때.
  • ✓프로그램 구조를 어떻게 짤지 고민할 때.
  • ✓보안 대책을 적용하는 경우.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/nodejs-best-practices/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/nodejs-best-practices/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“고성능 API를 위해 Node.js에서 가장 좋은 프레임워크를 어떻게 고를 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 필요를 분석하고 가장 좋은 도구와 프로그래밍 패턴을 제안합니다. 프로젝트를 이해하기 위해 질문하고, 각 선택의 결과를 생각하도록 돕습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Node.js Best Practices

Principles and decision-making for Node.js development in 2025. Learn to THINK, not memorize code patterns.

When to Use

Use this skill when making Node.js architecture decisions, choosing frameworks, designing async patterns, or applying security and deployment best practices.


⚠️ How to Use This Skill

This skill teaches decision-making principles, not fixed code to copy.

  • ASK user for preferences when unclear
  • Choose framework/pattern based on CONTEXT
  • Don't default to same solution every time

1. Framework Selection (2025)

Decision Tree

What are you building?
│
├── Edge/Serverless (Cloudflare, Vercel)
│   └── Hono (zero-dependency, ultra-fast cold starts)
│
├── High Performance API
│   └── Fastify (2-3x faster than Express)
│
├── Enterprise/Team familiarity
│   └── NestJS (structured, DI, decorators)
│
├── Legacy/Stable/Maximum ecosystem
│   └── Express (mature, most middleware)
│
└── Full-stack with frontend
    └── Next.js API Routes or tRPC

Comparison Principles

Factor Hono Fastify Express
Best for Edge, serverless Performance Legacy, learning
Cold start Fastest Fast Moderate
Ecosystem Growing Good Largest
TypeScript Native Excellent Good
Learning curve Low Medium Low

Selection Questions to Ask:

  1. What's the deployment target?
  2. Is cold start time critical?
  3. Does team have existing experience?
  4. Is there legacy code to maintain?

2. Runtime Considerations (2025)

Native TypeScript

Node.js 22+: --experimental-strip-types
├── Run .ts files directly
├── No build step needed for simple projects
└── Consider for: scripts, simple APIs

Module System Decision

ESM (import/export)
├── Modern standard
├── Better tree-shaking
├── Async module loading
└── Use for: new projects

CommonJS (require)
├── Legacy compatibility
├── More npm packages support
└── Use for: existing codebases, some edge cases

Runtime Selection

Runtime Best For
Node.js General purpose, largest ecosystem
Bun Performance, built-in bundler
Deno Security-first, built-in TypeScript

3. Architecture Principles

Layered Structure Concept

Request Flow:
│
├── Controller/Route Layer
│   ├── Handles HTTP specifics
│   ├── Input validation at boundary
│   └── Calls service layer
│
├── Service Layer
│   ├── Business logic
│   ├── Framework-agnostic
│   └── Calls repository layer
│
└── Repository Layer
    ├── Data access only
    ├── Database queries
    └── ORM interactions

Why This Matters:

  • Testability: Mock layers independently
  • Flexibility: Swap database without touching business logic
  • Clarity: Each layer has single responsibility

When to Simplify:

  • Small scripts → Single file OK
  • Prototypes → Less structure acceptable
  • Always ask: "Will this grow?"

4. Error Handling Principles

Centralized Error Handling

Pattern:
├── Create custom error classes
├── Throw from any layer
├── Catch at top level (middleware)
└── Format consistent response

Error Response Philosophy

Client gets:
├── Appropriate HTTP status
├── Error code for programmatic handling
├── User-friendly message
└── NO internal details (security!)

Logs get:
├── Full stack trace
├── Request context
├── User ID (if applicable)
└── Timestamp

Status Code Selection

Situation Status When
Bad input 400 Client sent invalid data
No auth 401 Missing or invalid credentials
No permission 403 Valid auth, but not allowed
Not found 404 Resource doesn't exist
Conflict 409 Duplicate or state conflict
Validation 422 Schema valid but business rules fail
Server error 500 Our fault, log everything

5. Async Patterns Principles

When to Use Each

Pattern Use When
async/await Sequential async operations
Promise.all Parallel independent operations
Promise.allSettled Parallel where some can fail
Promise.race Timeout or first response wins

Event Loop Awareness

I/O-bound (async helps):
├── Database queries
├── HTTP requests
├── File system
└── Network operations

CPU-bound (async doesn't help):
├── Crypto operations
├── Image processing
├── Complex calculations

…
자주 묻는 질문

‘프레임워크’란 무엇인가요?

미리 만들어진 구조를 제공해 프로그램 개발을 체계화하고 빠르게 해 주는 도구와 규칙의 모음입니다.

‘코드를 외우는 대신 생각하라’는 무슨 뜻인가요?

해결책이 왜 작동하는지, 언제 써야 하는지 이해하는 것을 말합니다. 이유를 모른 채 코드 조각을 그대로 붙여넣는 것과는 다릅니다.

이것을 쓰려면 Node.js 프로그래밍을 알아야 하나요?

이 가이드는 Node.js에 이미 익숙하고 프로젝트를 더 나은 방식으로 구성하고 만들고 싶은 사람을 위한 것입니다.

상세 정보

작성자의 원본 설명

Node.js development principles and decision-making. Framework selection, async patterns, security, and architecture. Teaches thinking, not copying.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#5309
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬