express

Route Organization (REQUIRED)

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "express" with this command: npx skills add poletron/custom-rules/poletron-custom-rules-express

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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

lancedb

No summary provided by upstream source.

Repository SourceNeeds Review
General

trpc

No summary provided by upstream source.

Repository SourceNeeds Review
General

git-flow

No summary provided by upstream source.

Repository SourceNeeds Review
General

javascript-mastery

No summary provided by upstream source.

Repository SourceNeeds Review