REST API with Typed Validation in Node.js

A small resource API with schema-validated requests, uniform error bodies and generated OpenAPI docs.

Owner: Eli HartDeveloper ExperienceContact ownerAdded 6 Aug 2026Updated 8 Sep 2026
  • Runs out of the box: yes
  • Tests: yes
  • CI: yes
  • Docs: yes
  • Used in production: no

Purpose#

The first of three implementations of the same "work orders" API. Requests are parsed with Zod schemas, handlers receive typed data only, and every error leaves the service as one JSON shape with a stable code.

The three implementations share an OpenAPI description and the same acceptance tests, so request validation, pagination and error handling can be compared line by line across languages.

What you will learn#

  1. Validate request bodies, queries and path parameters with one schema per route
  2. Return a single error body shape with stable machine-readable codes
  3. Run the shared acceptance suite against a new implementation

Technologies & features#

Technologies
TypeScriptNode.jsZodPostgreSQL
Features
REST API DesignEnvironment Configuration
Topics
Application Architectureprimary

Lessons learned#

  • Worked

    Deriving the OpenAPI document from the same schemas the handlers use meant the docs could not drift from behavior.

  • Decision

    Cursor pagination was used instead of page numbers because work orders are inserted constantly and page numbers shifted under users.

Try it#

Shell
git clone https://git.example.internal/developer-experience/rest-work-orders-node.git
cd rest-work-orders-node
pnpm install
pnpm dev          # http://localhost:4000
pnpm test:contract # shared acceptance suite

Commands come from the owner’s README. Credentials are never stored here.

Resources#

Contributes to

StatusReference
OwnerEli Hart
TeamDeveloper Experience
Last commit5 Sep 2026
Slugrest-api-nodejs
Report a problem to the owner