https://github.com/dillonstreator/template-node-fastify
A minimal production-ready node HTTP server with fastify and typescript
https://github.com/dillonstreator/template-node-fastify
fastify graceful-shutdown nodejs railway-template starter starter-template typescript
Last synced: 4 months ago
JSON representation
A minimal production-ready node HTTP server with fastify and typescript
- Host: GitHub
- URL: https://github.com/dillonstreator/template-node-fastify
- Owner: dillonstreator
- Created: 2024-02-02T14:17:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-10T23:09:55.000Z (7 months ago)
- Last Synced: 2025-05-22T02:11:40.343Z (5 months ago)
- Topics: fastify, graceful-shutdown, nodejs, railway-template, starter, starter-template, typescript
- Language: TypeScript
- Homepage: https://railway.app/template/xeb3TM?referralCode=ToZEjF
- Size: 859 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `template-node-fastify`
A minimal production-ready node HTTP server with [`Fastify`](https://fastify.dev/) 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 \
✅ Auto-generated Swagger/OpenAPI documentation \
✅ `AbortSignal` propagation to prevent unnecessary work (includes example and test) \
✅ Structured logging with [`pino`](https://github.com/pinojs/pino) \
✅ Rich request logging middleware including request id, trace id, context propagation, and more \
✅ [`zod`](https://github.com/turkerdev/fastify-type-provider-zod) for request validation, JSON schema inference, and OpenAPI/Swagger generation \
✅ Testing with [`tap`](https://www.npmjs.com/package/tap) and [`undici`](https://www.npmjs.com/package/undici) \
✅ [`helmet`](https://github.com/fastify/fastify-helmet) & [`compression`](https://github.com/fastify/fastify-compress)[](https://railway.app/template/xeb3TM?referralCode=ToZEjF)
## Installation
```sh
git clone https://github.com/dillonstreator/template-node-fastifycd template-node-fastify
yarn install
yarn dev
```## Configuration
See all example configuration via environment variables in [`.env-example`](./.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