# Debug Mode πŸ› ## λͺ©μ°¨ - [πŸ“‘ λͺ©μ°¨](#λͺ©μ°¨) - [Debug Modeλž€?](#debug-modeλž€) - [μ£Όμš” κΈ°λŠ₯](#μ£Όμš”-κΈ°λŠ₯) - [μ™œ ν•„μš”ν•œκ°€?](#μ™œ-ν•„μš”ν•œκ°€) - [ν™œμ„±ν™”/λΉ„ν™œμ„±ν™”](#ν™œμ„±ν™”λΉ„ν™œμ„±ν™”) - [κΈ°λ³Έ μƒνƒœ (λΉ„ν™œμ„±ν™”λ¨)](#κΈ°λ³Έ-μƒνƒœ-λΉ„ν™œμ„±ν™”λ¨) - [ν™œμ„±ν™” 방법](#ν™œμ„±ν™”-방법) - [λ‹€λ₯Έ 둜그 μ œμ–΄](#λ‹€λ₯Έ-둜그-μ œμ–΄) - [좜λ ₯ ν˜•μ‹](#좜λ ₯-ν˜•μ‹) - [성곡 μΌ€μ΄μŠ€](#성곡-μΌ€μ΄μŠ€) - [μ—λŸ¬ μΌ€μ΄μŠ€](#μ—λŸ¬-μΌ€μ΄μŠ€) - [좜λ ₯ μš”μ†Œ μ„€λͺ…](#좜λ ₯-μš”μ†Œ-μ„€λͺ…) - [Context 좔적](#context-좔적) - [Input vs Context](#input-vs-context) - [예제: Context 흐름 좔적](#예제-context-흐름-좔적) - [μ‹€μ „ μ‚¬μš© μ˜ˆμ‹œ](#μ‹€μ „-μ‚¬μš©-μ˜ˆμ‹œ) - [μ˜ˆμ‹œ 1: μ£Όλ¬Έ 생성 디버깅](#μ˜ˆμ‹œ-1-μ£Όλ¬Έ-생성-디버깅) - [μ˜ˆμ‹œ 2: μ„±λŠ₯ 병λͺ© μ°ΎκΈ°](#μ˜ˆμ‹œ-2-μ„±λŠ₯-병λͺ©-μ°ΎκΈ°) - [둜그 μ œμ–΄](#둜그-μ œμ–΄) - [ν™˜κ²½ λ³€μˆ˜](#ν™˜κ²½-λ³€μˆ˜) - [μ‹œλ‚˜λ¦¬μ˜€λ³„ μ„€μ •](#μ‹œλ‚˜λ¦¬μ˜€λ³„-μ„€μ •) - [μ„±λŠ₯ 고렀사항](#μ„±λŠ₯-고렀사항) - [Context μŠ€λƒ…μƒ· μ˜€λ²„ν—€λ“œ](#context-μŠ€λƒ…μƒ·-μ˜€λ²„ν—€λ“œ) - [Context 크기 μ œν•œ](#context-크기-μ œν•œ) - [ν”„λ‘œλ•μ…˜ ꢌμž₯사항](#ν”„λ‘œλ•μ…˜-ꢌμž₯사항) - [Best Practices](#best-practices) - [1. Context 섀계](#1-context-섀계) - [2. 의미 μžˆλŠ” κ²°κ³Ό μ €μž₯](#2-의미-μžˆλŠ”-κ²°κ³Ό-μ €μž₯) - [3. μ—λŸ¬ λ©”μ‹œμ§€ λͺ…ν™•ν•˜κ²Œ](#3-μ—λŸ¬-λ©”μ‹œμ§€-λͺ…ν™•ν•˜κ²Œ) - [4. Step μ‹€ν–‰ μ‹œκ°„ μ΅œμ ν™”](#4-step-μ‹€ν–‰-μ‹œκ°„-μ΅œμ ν™”) - [5. 개발 vs ν”„λ‘œλ•μ…˜](#5-개발-vs-ν”„λ‘œλ•μ…˜) - [λ‹€μŒ 단계](#λ‹€μŒ-단계) --- Numflow의 Debug ModeλŠ” Feature-First Auto-Orchestration의 μ‹€ν–‰ 흐름을 μ‹œκ°μ μœΌλ‘œ 좔적할 수 μžˆλŠ” κ°•λ ₯ν•œ 디버깅 λ„κ΅¬μž…λ‹ˆλ‹€. > **μ°Έκ³ **: Debug ModeλŠ” Feature-First νŒ¨ν„΄μ—μ„œλ§Œ μž‘λ™ν•©λ‹ˆλ‹€. 일반 λΌμš°νŠΈμ—μ„œλŠ” λ™μž‘ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. --- ## Debug Modeλž€? Debug ModeλŠ” Feature의 각 Step μ‹€ν–‰ 흐름을 **트리 ν˜•μ‹**으둜 ν‘œμ‹œν•˜κ³ , **Context λ³€ν™”**λ₯Ό μΆ”μ ν•˜μ—¬ 디버깅을 μ‰½κ²Œ λ§Œλ“œλŠ” κΈ°λŠ₯μž…λ‹ˆλ‹€. **기본적으둜 λΉ„ν™œμ„±ν™”**λ˜μ–΄ 있으며, ν•„μš”ν•  λ•Œ ν™˜κ²½ λ³€μˆ˜λ‘œ ν™œμ„±ν™”ν•  수 μžˆμŠ΅λ‹ˆλ‹€. ### μ£Όμš” κΈ°λŠ₯ 1. **Step별 상세 정보** - Step μ‹€ν–‰ μ „ Input (context μƒνƒœ) - Step μ‹€ν–‰ ν›„ Context λ³€ν™” - μ‹€ν–‰ μ‹œκ°„ (ms) - 성곡/μ‹€νŒ¨ ν‘œμ‹œ (βœ“/βœ—) 2. **트리 ν˜•μ‹ 좜λ ₯** - 보기 쒋은 트리 ꡬ쑰 (β”œβ”€, └─) - Step λ²ˆν˜Έμ™€ 이름 ν‘œμ‹œ - 각 Step의 Input/Output 정보 3. **Summary 톡계** - 전체 μ‹€ν–‰ μ‹œκ°„ - 성곡/μ‹€νŒ¨ Step 수 - μ΅œμ’… μƒνƒœ (Success/Failed) --- ## μ™œ ν•„μš”ν•œκ°€? Feature-First νŒ¨ν„΄μ—μ„œλŠ” μ—¬λŸ¬ Step이 순차적으둜 μ‹€ν–‰λ˜λ©΄μ„œ Contextλ₯Ό κ³΅μœ ν•©λ‹ˆλ‹€. Debug Modeκ°€ μ—†λ‹€λ©΄: ```javascript // ❌ Debug Mode μ—†μ΄λŠ”... // - μ–΄λŠ Stepμ—μ„œ μ—λŸ¬κ°€ λ°œμƒν–ˆλŠ”μ§€ μ•ŒκΈ° 어렀움 // - 각 Step이 Contextλ₯Ό μ–΄λ–»κ²Œ λ³€κ²½ν•˜λŠ”μ§€ 보이지 μ•ŠμŒ // - μ„±λŠ₯ 병λͺ©μ„ μ°ΎκΈ° 어렀움 // - λ³΅μž‘ν•œ λΉ„μ¦ˆλ‹ˆμŠ€ 둜직 디버깅이 어렀움 features/create-order/steps/ 100-validate-order.js // μ–΄λ””μ„œ λ©ˆμ·„μ§€? 200-check-inventory.js // Contextκ°€ μ œλŒ€λ‘œ μ „λ‹¬λλ‚˜? 300-reserve-stock.js // 이 Step이 λ„ˆλ¬΄ 느린데? 400-process-payment.js // μ—λŸ¬κ°€ μ—¬κΈ°μ„œ λ‚œ 건가? ``` **Debug Modeλ₯Ό μ‚¬μš©ν•˜λ©΄:** ```bash # βœ… Debug Mode둜 ν•œλˆˆμ— νŒŒμ•…! [Feature] POST /api/orders [Step 100] validate-order (2ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{...}} └─ Context: {"validation":{"isValid":true}} [Step 200] check-inventory (15ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{...}} └─ Context: {"inventory":{"available":true}} [Step 300] reserve-stock (150ms) βœ“ ← μ—¬κΈ°κ°€ λŠλ¦¬λ„€! └─ Context: {"reservation":{"id":"123"}} [Step 400] process-payment (8ms) βœ— ← μ—λŸ¬ λ°œμƒ! └─ Error: Payment gateway timeout [Summary] Total: 175ms Steps: 3/4 passed Status: βœ— Failed ``` --- ## ν™œμ„±ν™”/λΉ„ν™œμ„±ν™” ### κΈ°λ³Έ μƒνƒœ (λΉ„ν™œμ„±ν™”λ¨) Debug ModeλŠ” **기본적으둜 λΉ„ν™œμ„±ν™”**λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. 별도 μ„€μ • 없이 Featureλ₯Ό μ‹€ν–‰ν•˜λ©΄ λ‘œκ·Έκ°€ 좜λ ₯λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. ```javascript // features/create-order/index.js const numflow = require('numflow') module.exports = numflow.feature({ method: 'POST', path: '/api/orders', steps: './steps' }) // μ„œλ²„ μ‹€ν–‰ μ‹œ Debug Mode 둜그 μ—†μŒ // node server.js ``` ### ν™œμ„±ν™” 방법 개발 ν™˜κ²½μ΄λ‚˜ 디버깅이 ν•„μš”ν•  λ•Œ ν™œμ„±ν™”ν•  수 μžˆμŠ΅λ‹ˆλ‹€. ```bash # 방법 1: ν™˜κ²½ λ³€μˆ˜λ‘œ ν™œμ„±ν™” FEATURE_DEBUG=true node server.js # 방법 2: .env νŒŒμΌμ— μΆ”κ°€ echo "FEATURE_DEBUG=true" >> .env node server.js # 방법 3: package.json 슀크립트 { "scripts": { "dev": "FEATURE_DEBUG=true node server.js", // 개발 μ‹œ Debug Mode ν™œμ„±ν™” "start": "node server.js" // ν”„λ‘œλ•μ…˜ (λΉ„ν™œμ„±ν™”) } } ``` ### λ‹€λ₯Έ 둜그 μ œμ–΄ ```bash # λͺ¨λ“  Feature 둜그 λΉ„ν™œμ„±ν™” (ν…ŒμŠ€νŠΈμš©) DISABLE_FEATURE_LOGS=true node server.js # ν…ŒμŠ€νŠΈ λͺ¨λ“œ (λͺ¨λ“  둜그 μžλ™ λΉ„ν™œμ„±ν™”) NODE_ENV=test npm test ``` --- ## 좜λ ₯ ν˜•μ‹ ### 성곡 μΌ€μ΄μŠ€ ```bash [Feature] POST /api/orders [Step 100] validate-order (2ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{"items":[{"id":1,"qty":2}]}} └─ Context: {"validation":{"isValid":true,"itemCount":1}} [Step 200] check-inventory (15ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{"items":[{"id":1,"qty":2}]}} └─ Context: {"inventory":{"available":true,"stock":50}} [Step 300] create-order (8ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{"items":[{"id":1,"qty":2}]}} └─ Context: {"order":{"orderId":"12345","status":"created"}} [Summary] Total: 25ms Steps: 3/3 passed Status: βœ“ Success ``` ### μ—λŸ¬ μΌ€μ΄μŠ€ ```bash [Feature] POST /api/orders [Step 100] validate-order (2ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{"items":[]}} └─ Context: {"validation":{"isValid":false}} [Step 200] check-inventory (1ms) βœ— β”œβ”€ Input: {"userId":1,"orderData":{"items":[]}} └─ Error: No items in order [Summary] Total: 3ms Steps: 1/2 passed Status: βœ— Failed Error: No items in order ``` ### 좜λ ₯ μš”μ†Œ μ„€λͺ… | μš”μ†Œ | μ„€λͺ… | |------|------| | `[Feature]` | Feature 헀더 (HTTP λ©”μ„œλ“œ + 경둜) | | `[Step 100]` | Step 번호 (파일λͺ…μ—μ„œ μΆ”μΆœ) | | `validate-order` | Step 이름 (파일λͺ…μ—μ„œ μΆ”μΆœ, ν™•μž₯자 제거) | | `(2ms)` | Step μ‹€ν–‰ μ‹œκ°„ (λ°€λ¦¬μ΄ˆ) | | `βœ“` / `βœ—` | 성곡/μ‹€νŒ¨ μ•„μ΄μ½˜ | | `β”œβ”€ Input` | Step μ‹€ν–‰ μ „ context μƒνƒœ (results μ œμ™Έ) | | `└─ Context` | Step μ‹€ν–‰ ν›„ ctx λ³€ν™” | | `└─ Error` | μ—λŸ¬ λ°œμƒ μ‹œ μ—λŸ¬ λ©”μ‹œμ§€ | | `[Summary]` | 전체 μ‹€ν–‰ 톡계 | --- ## Context 좔적 Debug Mode의 핡심 κΈ°λŠ₯은 **Context λ³€ν™” 좔적**μž…λ‹ˆλ‹€. ### Input vs Context **Input (μ‹€ν–‰ μ „)** - Step μ‹€ν–‰ μ „μ˜ context μƒνƒœ - `ctx`λŠ” μ œμ™Έ - 이전 Stepλ“€μ—μ„œ μ „λ‹¬λœ 데이터 ```javascript // Input μ˜ˆμ‹œ { userId: 1, orderData: { items: [...] } } ``` **Context (μ‹€ν–‰ ν›„ λ³€ν™”)** - Step μ‹€ν–‰ ν›„ `ctx`에 μΆ”κ°€λœ λ°μ΄ν„°λ§Œ ν‘œμ‹œ - μƒˆλ‘œ μΆ”κ°€λœ ν‚€λ§Œ ν‘œμ‹œ ```javascript // Context μ˜ˆμ‹œ (μƒˆλ‘œ μΆ”κ°€λœ 데이터) { validation: { isValid: true, itemCount: 1 } } ``` ### 예제: Context 흐름 좔적 ```javascript // features/create-order/steps/100-validate-order.js module.exports = async function(context) { const { orderData } = context // 검증 둜직 const isValid = orderData.items && orderData.items.length > 0 // ctx에 μΆ”κ°€ (Debug Modeμ—μ„œ ν‘œμ‹œλ¨) ctx.validation = { isValid, itemCount: orderData.items?.length || 0 } if (!isValid) { throw new Error('Invalid order') } } ``` ```javascript // features/create-order/steps/200-check-inventory.js module.exports = async function(context) { // 이전 Step κ²°κ³Ό μ‚¬μš© const { validation } = ctx if (!validation.isValid) { throw new Error('Cannot check inventory for invalid order') } // 재고 확인 둜직 const stock = await db.getStock(context.orderData.items) // μƒˆλ‘œμš΄ κ²°κ³Ό μΆ”κ°€ ctx.inventory = { available: stock.available, stock: stock.quantity } } ``` **Debug 좜λ ₯:** ```bash [Step 100] validate-order (2ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{"items":[...]}} └─ Context: {"validation":{"isValid":true,"itemCount":1}} ← μƒˆλ‘œ 좔가됨 [Step 200] check-inventory (15ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{...},"results":{"validation":{...}}} └─ Context: {"inventory":{"available":true,"stock":50}} ← μƒˆλ‘œ 좔가됨 ``` --- ## μ‹€μ „ μ‚¬μš© μ˜ˆμ‹œ ### μ˜ˆμ‹œ 1: μ£Όλ¬Έ 생성 디버깅 ```javascript // features/create-order/index.js const numflow = require('numflow') module.exports = numflow.feature({ method: 'POST', path: '/api/orders', steps: './steps', contextInitializer: (ctx, req, res) => { ctx.userId = req.user?.id ctx.orderData = req.body }, onError: async (error, context, req, res) => { console.error('Order creation failed:', error) res.status(500).json({ error: error.message }) } }) ``` ```javascript // features/create-order/steps/100-validate-order.js module.exports = async function(context) { const { orderData } = context if (!orderData.items || orderData.items.length === 0) { throw new Error('Order must have at least one item') } ctx.validation = { isValid: true, itemCount: orderData.items.length, totalAmount: orderData.items.reduce((sum, item) => sum + (item.price * item.quantity), 0 ) } } ``` ```javascript // features/create-order/steps/200-check-inventory.js module.exports = async function(context) { const { orderData, results } = context const { validation } = results // 재고 확인 둜직 const outOfStock = [] for (const item of orderData.items) { const stock = await inventoryService.getStock(item.id) if (stock < item.quantity) { outOfStock.push({ itemId: item.id, requested: item.quantity, available: stock }) } } if (outOfStock.length > 0) { throw new Error(`Items out of stock: ${JSON.stringify(outOfStock)}`) } ctx.inventory = { checked: true, timestamp: new Date().toISOString() } } ``` **Debug 좜λ ₯ (성곡 μΌ€μ΄μŠ€):** ```bash [Feature] POST /api/orders [Step 100] validate-order (3ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{"items":[{"id":1,"price":100,"quantity":2}]}} └─ Context: {"validation":{"isValid":true,"itemCount":1,"totalAmount":200}} [Step 200] check-inventory (45ms) βœ“ β”œβ”€ Input: {"userId":1,"orderData":{...}} └─ Context: {"inventory":{"checked":true,"timestamp":"2025-10-16..."}} [Summary] Total: 48ms Steps: 2/2 passed Status: βœ“ Success ``` **Debug 좜λ ₯ (재고 λΆ€μ‘±):** ```bash [Feature] POST /api/orders [Step 100] validate-order (2ms) βœ“ └─ Context: {"validation":{"isValid":true,"itemCount":1,"totalAmount":200}} [Step 200] check-inventory (35ms) βœ— └─ Error: Items out of stock: [{"itemId":1,"requested":2,"available":0}] [Summary] Total: 37ms Steps: 1/2 passed Status: βœ— Failed Error: Items out of stock: [{"itemId":1,"requested":2,"available":0}] ``` ### μ˜ˆμ‹œ 2: μ„±λŠ₯ 병λͺ© μ°ΎκΈ° Debug ModeλŠ” 각 Step의 μ‹€ν–‰ μ‹œκ°„μ„ μΈ‘μ •ν•˜λ―€λ‘œ, 느린 Step을 μ‰½κ²Œ 찾을 수 μžˆμŠ΅λ‹ˆλ‹€. ```bash [Feature] POST /api/orders [Step 100] validate-order (2ms) βœ“ [Step 200] check-inventory (850ms) βœ“ ← μ—¬κΈ°κ°€ 느림! [Step 300] create-order (5ms) βœ“ [Step 400] send-notification (1200ms) βœ“ ← 여기도 느림! [Summary] Total: 2057ms Steps: 4/4 passed Status: βœ“ Success ``` **ν•΄κ²°μ±…:** - Step 200: 재고 확인 쿼리 μ΅œμ ν™” (인덱슀 μΆ”κ°€) - Step 400: μ•Œλ¦Όμ„ async-tasks둜 이동 --- ## 둜그 μ œμ–΄ ### ν™˜κ²½ λ³€μˆ˜ | ν™˜κ²½ λ³€μˆ˜ | κΈ°λ³Έκ°’ | μ„€λͺ… | |----------|--------|------| | `FEATURE_DEBUG` | `false` (λΉ„ν™œμ„±ν™”) | `true`둜 μ„€μ • μ‹œ Debug Mode ν™œμ„±ν™” | | `DISABLE_FEATURE_LOGS` | `false` (ν™œμ„±ν™”) | `true`둜 μ„€μ • μ‹œ λͺ¨λ“  Feature 둜그 λΉ„ν™œμ„±ν™” | | `NODE_ENV` | - | `test`일 λ•Œ λͺ¨λ“  둜그 μžλ™ λΉ„ν™œμ„±ν™” | ### μ‹œλ‚˜λ¦¬μ˜€λ³„ μ„€μ • **개발 ν™˜κ²½ (상세 둜그)** ```bash # Debug Mode ν™œμ„±ν™” FEATURE_DEBUG=true node server.js ``` **ν”„λ‘œλ•μ…˜ ν™˜κ²½ (둜그 μ΅œμ†Œν™”)** ```bash # Debug Mode λΉ„ν™œμ„±ν™” (κΈ°λ³Έκ°’) node server.js ``` **ν…ŒμŠ€νŠΈ ν™˜κ²½ (둜그 μ—†μŒ)** ```bash # λͺ¨λ“  둜그 μžλ™ λΉ„ν™œμ„±ν™” NODE_ENV=test npm test ``` **νŠΉμ • 상황 (Feature 둜그만 끄기)** ```bash # Feature λ‘œκ·ΈλŠ” 끄고 μ•± 둜그만 보기 DISABLE_FEATURE_LOGS=true node server.js ``` --- ## μ„±λŠ₯ 고렀사항 ### Context μŠ€λƒ…μƒ· μ˜€λ²„ν—€λ“œ Debug ModeλŠ” 각 Step μ‹€ν–‰ 전후에 Contextλ₯Ό 볡사(μŠ€λƒ…μƒ·)ν•©λ‹ˆλ‹€. 이둜 μΈν•œ μ„±λŠ₯ 영ν–₯은 **λ¬΄μ‹œν•  수 μžˆλŠ” μˆ˜μ€€**μž…λ‹ˆλ‹€. **μ„±λŠ₯ μΈ‘μ • (10 Steps Feature):** - Debug Mode OFF: 42,104 req/s - Debug Mode ON: ~41,000 req/s (μ•½ 2.6% μ˜€λ²„ν—€λ“œ) ### Context 크기 μ œν•œ Debug ModeλŠ” Contextλ₯Ό JSON.stringify둜 λ³€ν™˜ν•˜μ—¬ ν‘œμ‹œν•©λ‹ˆλ‹€. 기본적으둜 60자둜 μ œν•œλ©λ‹ˆλ‹€. ```javascript // Contextκ°€ 크면 μžλ™μœΌλ‘œ 잘림 { validation: { isValid: true, itemCount: 1, items: [...] } } // 좜λ ₯ μ˜ˆμ‹œ └─ Context: {"validation":{"isValid":true,"itemCount":1,"items":[... ``` ### ν”„λ‘œλ•μ…˜ ꢌμž₯사항 1. **ν”„λ‘œλ•μ…˜μ—μ„œλŠ” λΉ„ν™œμ„±ν™” μœ μ§€ (κΈ°λ³Έκ°’)** ```bash # Debug ModeλŠ” 기본적으둜 λΉ„ν™œμ„±ν™”λ˜μ–΄ μžˆμœΌλ―€λ‘œ # 별도 μ„€μ • 없이 μ‹€ν–‰ν•˜λ©΄ λ©λ‹ˆλ‹€ npm start ``` 2. **λ―Όκ°ν•œ 데이터 주의** - Context에 λΉ„λ°€λ²ˆν˜Έ, API ν‚€ 등이 ν¬ν•¨λ˜μ§€ μ•Šλ„λ‘ 주의 - ν•„μš”μ‹œ onErrorμ—μ„œ λ―Όκ°ν•œ 데이터 필터링 3. **둜그 μˆ˜μ§‘κΈ° μ‚¬μš©** - Debug 둜그λ₯Ό 파일둜 μ €μž₯: `node server.js > debug.log 2>&1` - κ΅¬μ‘°ν™”λœ λ‘œκΉ…: Winston, Pino λ“± μ‚¬μš© --- ## Best Practices ### 1. Context 섀계 ```javascript // βœ… 쒋은 예: λΆˆλ³€μ„± μœ μ§€ module.exports = async function(context) { // μƒˆλ‘œμš΄ λ°μ΄ν„°λŠ” resultsμ—λ§Œ μΆ”κ°€ ctx.validation = { isValid: true } } // ❌ λ‚˜μœ 예: κΈ°μ‘΄ 데이터 μˆ˜μ • module.exports = async function(context) { // κΈ°μ‘΄ orderData μˆ˜μ • (좔적 어렀움) context.orderData.status = 'validated' } ``` ### 2. 의미 μžˆλŠ” κ²°κ³Ό μ €μž₯ ```javascript // βœ… 쒋은 예: μƒμ„Έν•œ 정보 ctx.payment = { transactionId: '12345', amount: 100, method: 'credit_card', timestamp: new Date().toISOString() } // ❌ λ‚˜μœ 예: 뢈λͺ…ν™•ν•œ 정보 ctx.payment = true ``` ### 3. μ—λŸ¬ λ©”μ‹œμ§€ λͺ…ν™•ν•˜κ²Œ ```javascript // βœ… 쒋은 예: ꡬ체적인 μ—λŸ¬ throw new Error(`Insufficient inventory for item ${itemId}: requested ${qty}, available ${stock}`) // ❌ λ‚˜μœ 예: λͺ¨ν˜Έν•œ μ—λŸ¬ throw new Error('Inventory error') ``` ### 4. Step μ‹€ν–‰ μ‹œκ°„ μ΅œμ ν™” ```javascript // Debug Mode둜 느린 Step 확인 ν›„ μ΅œμ ν™” // Before (느림) [Step 200] check-inventory (850ms) βœ“ // After (빠름) [Step 200] check-inventory (12ms) βœ“ // μ΅œμ ν™” 방법: // - DB 쿼리 μ΅œμ ν™” (인덱슀 μΆ”κ°€) // - 병렬 처리 (Promise.all) // - 캐싱 (Redis) ``` ### 5. 개발 vs ν”„λ‘œλ•μ…˜ ```javascript // package.json { "scripts": { "dev": "FEATURE_DEBUG=true node server.js", // 개발 (Debug Mode ν™œμ„±ν™”) "start": "node server.js", // ν”„λ‘œλ•μ…˜ (λΉ„ν™œμ„±ν™”, κΈ°λ³Έκ°’) "test": "NODE_ENV=test jest" // ν…ŒμŠ€νŠΈ (둜그 μ—†μŒ) } } ``` --- ## λ‹€μŒ 단계 - **[Feature-First Auto-Orchestration](./feature-first.md)** - Feature-First νŒ¨ν„΄ 전체 κ°€μ΄λ“œ - **[μ—λŸ¬ 처리](./error-handling.md)** - onError ν•Έλ“€λŸ¬ ν™œμš© - **[ν”„λ‘œμ νŠΈ ꡬ쑰](./project-structure.md)** - Feature 폴더 ꡬ쑰 섀계 --- **λ§ˆμ§€λ§‰ μ—…λ°μ΄νŠΈ**: 2025-10-16 (Debug Mode λ¬Έμ„œ μž‘μ„±)