Skip to content
Back to skills

Forge Node Api Services

ASecurity

Build Node.js HTTP APIs (Express, Fastify, Hono, NestJS) with validation, errors, logging and graceful shutdown

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentsrustsqlnodeexpressapidatabasesecurity

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add ansh44233/forge --skill forge-node-api-services --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Forge Node Api Services?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Forge Node Api Services
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ansh44233-forge-node-api-services/badge)](https://www.skillsdirectory.com/skills/ansh44233-forge-node-api-services)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: forge-node-api-services
description: Build Node.js HTTP APIs (Express, Fastify, Hono, NestJS) with validation, errors, logging and graceful shutdown
---

<!-- Generated from catalog/skills/node-api-services/SKILL.md by scripts/build-plugin.ts. Edit the catalog, not this file. -->

# Node.js API services

Use when adding or changing endpoints in a Node.js service.

## Request path
1. **Validate** params, query and body with a schema at the edge; return 400 with field-level messages. Never trust `req.body` types.
2. **Authorize** after authenticating: check the caller may act on *this* resource (object-level checks), not just that they are logged in.
3. **Do the work** in a service function that does not know about HTTP, so it can be tested directly.
4. **Respond** with a consistent shape and status code; never leak stack traces or SQL errors to clients.

## Errors
- Use one error-handling middleware (Express needs the 4-argument signature; Fastify uses `setErrorHandler`). Map known domain errors to 4xx, everything else to 500 with a request id.
- In Express 4, errors thrown inside `async` handlers are not caught automatically: wrap handlers or upgrade to Express 5.
- Handle `unhandledRejection` by logging and exiting; a process manager restarts it.

## Operations
- Structured JSON logs (pino) with a request id propagated to downstream calls. Do not log tokens, passwords or full bodies with personal data.
- Timeouts on every outbound call (`AbortSignal.timeout(ms)` with `fetch`). Retries only for idempotent requests, with backoff.
- Graceful shutdown on `SIGTERM`: stop accepting connections, finish in-flight requests, close the database pool, then exit.
- Configuration from environment variables parsed and validated once at startup; fail fast on missing values.

## Security checklist
Rate limits on auth and expensive routes · `helmet` (or equivalent) headers · CORS limited to known origins · body size limits · parameterized queries only · dependency audit in CI.

## Verify
Unit tests for the service function, an HTTP-level test (supertest or `app.inject`) for status codes and validation errors, then the full test suite and typecheck.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.