ProvenPin Install

Express 5 + Helmet + express-rate-limit hardening: working versions (tested 2026-10-15)

Add security headers with Helmet and per-IP rate limiting with express-rate-limit to an Express 5 API.

passed2 passed · 0 failed2026-10-15 13:06 UTC
Status
passed
Last passed
2026-10-15 13:06 UTC
Tests
2 / 2
Language
TypeScript
Runtime
node v22.23.3
pinned versions8
express@5.3.0helmet@8.3.0express-rate-limit@8.7.1tsx@4.23.15@types/node@24.19.2supertest@7.3.1@types/supertest@7.2.1@types/express@5.0.6
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38738874208

The code

Exactly the files that passed. Your agent can pull them with get_recipe("express-helmet-rate-limit") (install), or see them on GitHub.

package.json
{
  "name": "express-helmet-rate-limit",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "express": "5.3.0",
    "helmet": "8.3.0",
    "express-rate-limit": "8.7.1"
  },
  "devDependencies": {
    "tsx": "4.23.15",
    "@types/node": "24.19.2",
    "supertest": "7.3.1",
    "@types/supertest": "7.2.1",
    "@types/express": "5.0.6"
  }
}
src/app.ts
import express from "express";
import helmet from "helmet";
import { rateLimit } from "express-rate-limit";

export function createApp({ limit = 100, windowMs = 60_000 } = {}) {
  const app = express();
  app.use(helmet());
  app.use("/api", rateLimit({ windowMs, limit, standardHeaders: "draft-8", legacyHeaders: false }));
  app.get("/api/ping", (_req, res) => { res.json({ ok: true }); });
  return app;
}
test/app.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import request from "supertest";
import { createApp } from "../src/app.ts";

test("sets security headers", async () => {
  const res = await request(createApp()).get("/api/ping");
  assert.equal(res.status, 200);
  assert.equal(res.headers["x-content-type-options"], "nosniff");
  assert.ok(res.headers["content-security-policy"]);
  assert.equal(res.headers["x-powered-by"], undefined);
});

test("returns 429 after the limit", async () => {
  const app = createApp({ limit: 2 });
  await request(app).get("/api/ping").expect(200);
  await request(app).get("/api/ping").expect(200);
  const res = await request(app).get("/api/ping");
  assert.equal(res.status, 429);
  assert.ok(res.headers["ratelimit"] || res.headers["ratelimit-policy"]);
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.