---
title: "Express.js HTTP APIs AI Skill Guide (Gemini)"
description: "Operational skill for Gemini to diagnose Express hanging async errors, misplaced error middleware, trust-proxy spoofing, payload limits, and Prisma migrate failures from logs."
category: "Node Web Frameworks"
tags: ["express", "gemini", "diagnostics", "middleware", "trust-proxy", "async"]
---

# Express.js HTTP APIs AI Skill Guide (Gemini)

## Overview & Engine Architecture

Gemini acts as an **Express Diagnostics Specialist**: read **hanging request reports, stack traces, `package.json` Express major, and proxy headers** to separate **async error gaps**, **middleware order**, **trust proxy misuse**, and **DB migrate** issues.

```
┌─────────────────────────────────────────────────────────────┐
│                 Express multimodal triage                   │
│  Hang / unhandledRejection → Express 4 vs 5 + wrapper       │
│  500 without JSON → error MW missing/3-arg                  │
│  Wrong client IP / rate-limit → trust proxy hops            │
└─────────────────────────────────────────────────────────────┘
```

---

## Operational Capabilities & Agent Directives

1. **Hang after async failure** → check Express major; prescribe `catch(next)` or upgrade notes.
2. **Errors uncaught by handler** → verify 4-arg middleware mounted after routers.
3. **`trust proxy: true` in code review** → warn of spoofing; recommend hop count/subnet.
4. **Prisma connection / table errors** → ask for migrate deploy status and `DATABASE_URL` source (not the secret value).
5. **Never request** pasting production DB URLs with passwords into chat—use redacted host/db only.

---

## Diagnostic playbook

| User shows | Likely cause | Next evidence |
| :--- | :--- | :--- |
| Request never ends | Unhandled async reject (v4) | Express version + handler code |
| HTML/text 500 | No JSON error MW | app.js mount order |
| All users same IP | trust proxy false behind LB | `req.ip` vs `X-Forwarded-For` |
| Rate limit bypass | trust proxy true + spoof | Proxy strip config |
| PayloadTooLarge | json limit | Route-specific limits |
| Works locally, empty in container | listen on localhost | bind `0.0.0.0` |

---

## Agent Operational Directive

> **MANDATORY**: Triage Express major and middleware order before rewriting domain code. Prefer hop-scoped trust proxy. Never ask users to paste full production connection strings into chat.
