Agent skill

nodejs-express-server

Build production-ready Express.js servers with middleware, authentication, routing, and database integration. Use when creating REST APIs, managing requests/responses, implementing middleware chains, and handling server logic.

Stars 151
Forks 20

Install this agent skill to your Project

npx add-skill https://github.com/aj-geddes/useful-ai-prompts/tree/main/skills/nodejs-express-server

SKILL.md

Node.js Express Server

Table of Contents

  • Overview
  • When to Use
  • Quick Start
  • Reference Guides
  • 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:

javascript
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

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

aj-geddes/useful-ai-prompts

websocket-implementation

Implement real-time bidirectional communication with WebSockets including connection management, message routing, and scaling. Use when building real-time features, chat systems, live notifications, or collaborative applications.

151 20
Explore
aj-geddes/useful-ai-prompts

refactor-legacy-code

Modernize and improve legacy codebases while maintaining functionality. Use when you need to refactor old code, reduce technical debt, modernize deprecated patterns, or improve code maintainability without breaking existing behavior.

151 20
Explore
aj-geddes/useful-ai-prompts

Sentiment Analysis

Classify text sentiment using NLP techniques, lexicon-based analysis, and machine learning for opinion mining, brand monitoring, and customer feedback analysis

151 20
Explore
aj-geddes/useful-ai-prompts

flask-api-development

Develop lightweight Flask APIs with routing, blueprints, database integration, authentication, and request/response handling. Use when building RESTful APIs, microservices, or lightweight web services with Flask.

151 20
Explore
aj-geddes/useful-ai-prompts

ML Model Explanation

Interpret machine learning models using SHAP, LIME, feature importance, partial dependence, and attention visualization for explainability

151 20
Explore
aj-geddes/useful-ai-prompts

Statistical Hypothesis Testing

Conduct statistical tests including t-tests, chi-square, ANOVA, and p-value analysis for statistical significance, hypothesis validation, and A/B testing

151 20
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results