Skip to content

osbytes/template-node-express

Repository files navigation

template-node-express

A minimal production-ready node HTTP server with Express and Typescript.

✅ Typescript
✅ Graceful shutdown
✅ Optional Tracing with OpenTelemetry (configurable via environment variables)
✅ Properly configured request payload size limiting to help prevent Denial of Service attack vectors
AbortSignal propagation to prevent unnecessary work (includes example and test)
✅ Validation with express-validator
✅ Async error forwarding to the default error handler (built into Express 5)
✅ Structured logging with pino
✅ Rich request logging middleware including request id, trace id, context propagation, and more
✅ Testing with jest, supertest, and fetch-mock
helmet & compression

Deploy on Railway

Installation

git clone https://github.com/dillonstreator/template-node-express

cd template-node-express

corepack enable
pnpm install

pnpm dev

Configuration

See all example configuration via environment variables in .env-example

Open Telemetry

Open Telemetry is disabled by default but can be enabled by setting the OTEL_ENABLED environment to true.

By default, the trace exporter is set to standard output. This can be overridden by setting OTEL_EXPORTER_OTLP_ENDPOINT.

Start the jaegertracing/all-in-one container with docker-compose up and set OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 to collect logs in jaeger. Docker compose will expose jaeger at http://localhost:16686

Releasing

This template uses Changesets for versioning and changelogs (not npm publish).

  1. For user-facing changes, run pnpm changeset and commit the file it creates.
  2. After changesets land on main, the Release workflow opens a Version Packages PR.
  3. Merging that PR bumps the version, updates CHANGELOG.md, and creates a GitHub Release.