skipLink.label

Quest 72 - Production Readiness Checker

Quest 72: Production Readiness Checker

hard 30-45 minutes

🎯 Learning Objectives

  • ✅ สร้าง readiness checker ที่ audit หลาย checklist items
  • ✅ เข้าใจ severity weighting — critical items สำคัญกว่า
  • ✅ รู้จัก critical-failure gating — ถ้า critical item ไม่ผ่าน = ไม่ ready
  • ✅ ออกแบบ comprehensive audit ที่ครอบคลุม testing, monitoring, auth, logging

📖 Concept: Production Readiness Audit

ก่อน deploy ใดๆ ลง production คุณต้อง audit ความพร้อม — เหมือน pre-flight checklist ของนักบิน

Production Readiness Checker ทำหน้าที่ตรวจสอบว่า system ของคุณมีครบทุกอย่างที่จำเป็น:

  • Tests? ✅
  • CI/CD? ✅
  • Monitoring? ✅
  • Auth? ✅ (Critical!)
  • Logging? ✅ (Critical!)
  • Health check? ✅ (Critical!)
const result = checkReadiness({
hasTests: true,
hasCI: true,
hasMonitoring: false,
hasRollback: true,
hasLogging: true,
hasAuth: true,
hasRateLimit: false,
hasHealthCheck: true,
documentation: true,
sla: false,
});
// { ready: false, score: 70, checklist: [...] }
// ไม่ ready เพราะ monitoring ไม่ผ่าน

⚙️ How It Works

วงจร Production Readiness Check

1. รับ config — hasTests, hasCI, hasMonitoring, etc.
↓
2. ตรวจสอบแต่ละ item — passed/failed พร้อม severity
↓
3. คำนวณ score = (passed / total) × 100
↓
4. ตรวจสอบ critical items — ถ้าตัวไหน failed = not ready
↓
5. Return: { ready, score, checklist }

Severity Weighting

ไม่ใช่ทุก item สำคัญเท่ากัน — Critical items ต้องผ่านเสมอ:

const checklist = [
{ item: 'hasTests', passed: true, severity: 'medium', message: 'Tests present' },
{ item: 'hasAuth', passed: false, severity: 'critical', message: 'Auth missing!' },
{ item: 'hasLogging', passed: true, severity: 'critical', message: 'Logging present' },
];
// Score = 67% (2/3 passed)
// แต่ ready = false เพราะ hasAuth (critical) failed!

💡 Example: Readiness Check ใน action

const result = checkReadiness({
hasTests: true,
hasCI: true,
hasMonitoring: true,
hasRollback: true,
hasLogging: true,
hasAuth: true,
hasRateLimit: false,
hasHealthCheck: true,
documentation: true,
sla: false,
});
console.log(result);
// {
// ready: false, // ไม่ ready เพราะ score < 70 หรือ critical failed
// score: 80, // 8/10 items passed
// checklist: [
// { item: 'hasTests', passed: true, severity: 'medium', message: '...' },
// { item: 'hasAuth', passed: true, severity: 'critical', message: '...' },
// { item: 'hasRateLimit', passed: false, severity: 'medium', message: '...' },
// // ...
// ]
// }

สังเกต: แม้ score = 80 แต่ถ้า critical item ตัวไหน failed → ready = false


⚠️ Common Mistakes

Mistake 1: นับ passing items โดยไม่ consider severity

“7/10 passed = 70%, ready to deploy!” → Critical items (auth, logging, healthCheck) ต้องผ่านเสมอ — แม้ score สูง

Mistake 2: ไม่มี critical-failure gating

“Score >= 70 = ready” → ต้อง check critical items ก่อน — ถ้าตัวไหน failed = not ready ทันที

Mistake 3: Checklist ไม่ comprehensive

“Just check tests and CI” → Production ต้องมี monitoring, auth, logging, healthCheck, rollback, rateLimit

Mistake 4: ไม่ return checklist details

“Just return ready: true/false” → Checklist ช่วยให้รู้ว่า items ไหนผ่าน/ไม่ผ่าน — สำหรับ debugging


📝 Knowledge Check

📝 Knowledge Check

Q1:Production Readiness Checker ทำอะไร?

Q2:Critical-failure gating หมายถึงอะไร?

Q3:Score คำนวณอย่างไร?


🏋️ Quest: Production Readiness Checker

สร้าง comprehensive readiness audit ที่ check หลาย items พร้อม severity weighting

  1. Download ไฟล์เริ่มต้นของ quest:

    Terminal window
    npx bluebeltdojo download quest-72-prod-readiness
    cd quest-72-prod-readiness
  2. เปิด problem.js ใน editor ของคุณพร้อม AI tool

  3. Implement checkReadiness(config) ตาม instructions ใน problem.js

  4. ตรวจสอบ solution ของคุณ:

    Terminal window
    node test.js
  5. สำคัญ! ทดสอบ edge case: critical item (auth) failed → ready = false แม้ score สูง

  6. แก้ไขจน tests ทุกตัวผ่าน

  7. ส่งคำตอบ:

    Terminal window
    npx bluebeltdojo submit

💡 Tip: ลองนึกถึง scenario ที่มี auth, logging, healthCheck ครบแต่ score ต่ำ — ควร ready ไหม?


คำใบ้

  • อ่าน instructions ใน problem.js อย่างละเอียด
  • Score = (passed / total) × 100
  • Ready = ALL critical items pass AND score >= 70
  • Critical items: auth, healthCheck, logging
  • ถ้าติดขัด ลองอ่าน “Common Mistakes” อีกครั้ง