Agent skill

express

Provides comprehensive guidance for Express.js framework including routing, middleware, request handling, error handling, and API development. Use when the user asks about Express, needs to create HTTP servers, set up routes, implement middleware, or build REST APIs.

Stars 254
Forks 41

Install this agent skill to your Project

npx add-skill https://github.com/partme-ai/full-stack-skills/tree/main/skills/nodejs-skills/express

SKILL.md

When to use this skill

Use this skill whenever the user wants to:

  • Build Node.js HTTP servers with Express routing and middleware
  • Configure CORS, body parsing, error handling, and static files
  • Create REST APIs with request validation and response formatting
  • Set up production-ready Express applications with security headers

How to use this skill

Workflow

  1. Create app — instantiate Express and configure middleware
  2. Define routes — set up route handlers for each endpoint
  3. Add error handling — implement error middleware for consistent responses
  4. Deploy — run behind a reverse proxy with HTTPS

Quick Start Example

javascript
const express = require('express');
const cors = require('cors');
const helmet = require('helmet');

const app = express();

// Middleware
app.use(helmet());
app.use(cors());
app.use(express.json());

// Routes
app.get('/api/items', async (req, res, next) => {
  try {
    const items = await Item.findAll();
    res.json({ items });
  } catch (err) {
    next(err);
  }
});

app.post('/api/items', async (req, res, next) => {
  try {
    const { name, price } = req.body;
    const item = await Item.create({ name, price });
    res.status(201).json(item);
  } catch (err) {
    next(err);
  }
});

// 404 handler
app.use((req, res) => {
  res.status(404).json({ error: 'Not found' });
});

// Error middleware (must have 4 params)
app.use((err, req, res, next) => {
  console.error(err.stack);
  res.status(err.status || 500).json({
    error: err.message || 'Internal server error',
  });
});

app.listen(3000, () => console.log('Server running on port 3000'));

Async Error Wrapper

javascript
// Wrap async handlers to catch rejected promises
const asyncHandler = (fn) => (req, res, next) =>
  Promise.resolve(fn(req, res, next)).catch(next);

app.get('/api/users', asyncHandler(async (req, res) => {
  const users = await User.findAll();
  res.json(users);
}));

Router Example

javascript
// routes/items.js
const router = require('express').Router();

router.get('/', asyncHandler(async (req, res) => { /* ... */ }));
router.post('/', asyncHandler(async (req, res) => { /* ... */ }));
router.get('/:id', asyncHandler(async (req, res) => { /* ... */ }));

module.exports = router;

// app.js
app.use('/api/items', require('./routes/items'));

Best Practices

  • Separate routes and middleware into modules; use express.Router() for organization
  • Always wrap async handlers with try/catch or a wrapper to avoid unhandled rejections
  • Use helmet for security headers and configure CORS for production origins
  • Deploy behind a reverse proxy (nginx) with HTTPS in production
  • Use morgan for request logging and structured error responses

Reference

Keywords

express, Node.js, middleware, routing, REST API, error handling, async, helmet, cors

Expand your agent's capabilities with these related and highly-rated skills.

partme-ai/full-stack-skills

ocrmypdf-batch

OCRmyPDF batch processing skill — process multiple PDFs, Docker automation, shell scripting, and CI/CD integration. Use when the user needs to OCR many PDFs, set up automated OCR pipelines, or integrate OCR into workflows.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf-optimize

OCRmyPDF optimization skill — compress PDFs, configure PDF/A output, JBIG2 encoding, and lossless optimization. Use when the user needs to reduce PDF file size, create archival PDF/A files, or optimize OCR output.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf-image

OCRmyPDF image processing skill — deskew, rotate, clean, despeckle, remove border from scanned documents. Use when the user needs to improve scanned PDF quality, fix skewed pages, remove noise, or clean up scanned documents before OCR.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf-api

OCRmyPDF Python API and plugin skill — use OCRmyPDF programmatically from Python, integrate with applications, and extend with plugins (EasyOCR, PaddleOCR, AppleOCR). Use when the user needs to call OCRmyPDF from Python code, build OCR pipelines, or use alternative OCR engines.

254 41
Explore
partme-ai/full-stack-skills

ocrmypdf

OCRmyPDF core skill — add searchable OCR text layer to scanned PDFs, convert images to searchable PDFs, support 100+ languages via Tesseract. Use when the user needs to OCR a PDF, make a scanned PDF searchable, or extract text from scanned documents.

254 41
Explore
partme-ai/full-stack-skills

svelte

Guides Svelte and SvelteKit development including reactive components, stores, transitions, lifecycle hooks, SSR, file-based routing, and deployment. Use when the user needs to build Svelte components, create SvelteKit applications, implement reactivity patterns, or configure Svelte with Vite.

254 41
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results