express
Installation
SKILL.md
Critical Patterns
Route Organization (REQUIRED)
// ✅ ALWAYS: Separate routes by resource
// routes/users.js
const router = express.Router();
router.get('/', usersController.list);
router.get('/:id', usersController.getById);
router.post('/', validate(createUserSchema), usersController.create);
router.put('/:id', validate(updateUserSchema), usersController.update);
router.delete('/:id', usersController.delete);
module.exports = router;
Error Handling (REQUIRED)
// ✅ ALWAYS: Centralized error handler
app.use((err, req, res, next) => {
console.error(err.stack);
const status = err.status || 500;
const message = err.message || 'Internal Server Error';
res.status(status).json({
error: { message, status }
});
});
// ✅ Async wrapper for async route handlers
const asyncHandler = (fn) => (req, res, next) =>
Promise.resolve(fn(req, res, next)).catch(next);
Decision Tree
Need validation? → Use Joi or Zod middleware
Need auth? → Use Passport.js or JWT middleware
Need logging? → Use Morgan middleware
Need CORS? → Use cors middleware
Need rate limiting? → Use express-rate-limit
Commands
npm init -y
npm install express
npm install -D nodemon
npm run dev
Related skills
More from poletron/custom-rules
cpp
>
104lancedb
>
17clean-code
Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments
10vulnerability-scanner
Advanced vulnerability analysis principles. OWASP 2025, Supply Chain Security, attack surface mapping, risk prioritization.
8trpc
>
8web-performance-optimization
Optimize website and web application performance including loading speed, Core Web Vitals, bundle size, caching strategies, and runtime performance
7