nodejs-express-server

Production-ready Express.js servers with routing, middleware, authentication, and database integration. Covers core Express patterns including middleware chains, RESTful routing with CRUD operations, and error handling middleware Supports authentication via JWT, database integration with PostgreSQL and Sequelize, and environment-based configuration Includes best practices for input validation, async/await patterns, rate limiting, and HTTPS in production Reference guides provided for basic setup, middleware implementation, database connections, and logging strategies

INSTALLATION
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill nodejs-express-server
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

Node.js Express Server

Table of Contents

  • [Overview](#overview)
  • [When to Use](#when-to-use)
  • [Quick Start](#quick-start)
  • [Reference Guides](#reference-guides)
  • [Best Practices](#best-practices)

Overview

Create robust Express.js applications with proper routing, middleware chains, authentication mechanisms, and database integration following industry best practices.

When to Use

  • Building REST APIs with Node.js
  • Implementing server-side request handling
  • Creating middleware chains for cross-cutting concerns
  • Managing authentication and authorization
  • Connecting to databases from Node.js
  • Implementing error handling and logging

Quick Start

Minimal working example:

const express = require("express");

const app = express();

const PORT = process.env.PORT || 3000;

// Middleware

app.use(express.json());

app.use(express.urlencoded({ extended: true }));

// Routes

app.get("/health", (req, res) => {

  res.json({ status: "OK", timestamp: new Date().toISOString() });

});

// Error handling

app.use((err, req, res, next) => {

  console.error(err.stack);

  res.status(err.status || 500).json({

    error: err.message,

    requestId: req.id,

  });

});

app.listen(PORT, () => {

  console.log(`Server running on port ${PORT}`);

});

Reference Guides

Detailed implementations in the references/ directory:

Guide

Contents

Basic Express Setup

Basic Express Setup

Middleware Chain Implementation

Middleware Chain Implementation

Database Integration (PostgreSQL with Sequelize)

Database Integration (PostgreSQL with Sequelize)

Authentication with JWT

Authentication with JWT

RESTful Routes with CRUD Operations

RESTful Routes with CRUD Operations

Error Handling Middleware

Error Handling Middleware

Environment Configuration

Environment Configuration

Best Practices

✅ DO

  • Use middleware for cross-cutting concerns
  • Implement proper error handling
  • Validate input data before processing
  • Use async/await for async operations
  • Implement authentication on protected routes
  • Use environment variables for configuration
  • Add logging and monitoring
  • Use HTTPS in production
  • Implement rate limiting
  • Keep route handlers focused and small

❌ DON'T

  • Handle errors silently
  • Store sensitive data in code
  • Use synchronous operations in routes
  • Forget to validate user input
  • Implement authentication in route handlers
  • Use callback hell (use promises/async-await)
  • Expose stack traces in production
  • Trust client-side validation only
BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card