node-svc-template

Intro

A fairly straightforward example of a fastify-based node server for building JSON HTTP APIs.

Initial setup

  1. Add a .env file with at least PORT and LOGGER defined
  2. Change name in package.json
  3. Install dependencies with pnpm

Building

Build the container image with Docker. Tag with the name and version in package.json using jql

docker build -t $(jql -r '"name"!' package.json):v$(jql -r '"version"!' package.json) .

Run the image locally

docker run --rm -it --env-file .env -p 8080:8080 $(jql -r '"name"!' package.json):v$(jql -r '"version"!' package.json)

Features

  • Compile & runtime type checking for request and response payloads with JSON Schema and Zod
  • Fast build powered by ESBuild
  • Type checking with TypeScript
  • Linting with ESLint

References