Minimal Express.js application demonstrating real-world crash prevention, async safety, and smart logging using Crashless.
Crashless ensures your app never crashes unexpectedly — even if async DB calls explode 💣, APIs fail 🌍, or developers “forget” try-catch 😅.
npm installnpm run dev✅ Shows full stack traces
✅ Logs every crash with metadata
✅ No message masking — useful for debugging
Example output:
⚡ Server running on http://localhost:4000
[Crashless] Error: Database read failed for user ID: 1
npm start✅ Sensitive messages masked
✅ Stack traces hidden
✅ Clean, production-friendly logs
npm testRuns all route tests using Mocha + Supertest
Verifies async, sync, and external API failures are gracefully handled.
| Method | Route | Description |
|---|---|---|
GET |
/ping |
Health check (returns OK) |
GET |
/user/:id |
Simulates DB read failure |
POST |
/user |
Simulates DB write failure |
DELETE |
/user/:id |
Simulates DB delete failure |
GET |
/external |
Simulates failed external API call |
GET |
/crash |
Manual “organic” crash |
npm run devcurl -s http://localhost:4000/user/1
curl -s -X POST http://localhost:4000/user -H "Content-Type: application/json" -d '{"name":"Sunny"}'
curl -s http://localhost:4000/crash
curl -s http://localhost:4000/externalEach response will return a standardized JSON structure like:
{
"success": false,
"message": "Database read failed for user ID: 1",
"code": "SERVER_ERROR"
}node-express-crashless/
├── server.js # Express + Crashless integration
├── db.js # Simulated DB & API failure logic
├── package.json # Scripts & deps
├── .gitignore # Clean repo setup
└── README.md # You’re reading this 😎
Development mode (npm run dev):
⚡ Server running on http://localhost:4000
[Crashless] Error: Database read failed for user ID: 1
{ method: 'GET', path: '/user/1', status: 500, timestamp: '...' }
Production mode (npm start):
⚡ Server running on http://localhost:4000
[Crashless] Error: Masked error (production mode)
{ method: 'GET', path: '/user/1', status: 500 }
👉 Try it instantly on StackBlitz:
https://stackblitz.com/github/sunnyghodeswar/node-express-crashless?file=server.js
Sunny Ghodeswar
Senior Full-Stack Developer — Pune, India 🇮🇳
Building Vegaa ⚡ & Crashless 🧯 for safer, faster backends.