/fastify-typescript-starter

Node.js starter using Fastify & TypeScript

Primary LanguageTypeScriptMIT LicenseMIT

Node.js starter using Fastify & TypeScript

ci badge Sync Vulnerabilities Status

Create a new server:

pnpx degit yonathan06/fastify-typescript-starter my-server

or npx.

See degit docs for detailed explaination

Included in the boilerplate

  • TypeScript (using esbuild for fast compilation)
  • Env vars
  • Tests (using Tap)
  • Fastify
  • File based routing (using fastify-now)
  • CI with github actions
  • Docker image
  • Linting

BYODB - Bring your own database - no database connection included

Set Up

  • Install the dependencies.
pnpm install

or npm/yarn

  • Start the server in development mode.
pnpm dev

or npm/yarn

File Based Routing

Using fastify-now for file based routing

Env vars

Loaded from .env file, with schema validation

Backend API Development

There are a number of handy commands you can run to help with development.

Command Action
pnpm run dev Run the server in dev mode, automatically restarts on file change
pnpm build Compile TypeScript to JavaScript
pnpm start Start JavaScript from 'build' directory
pnpm test Run unit tests (run pnpm build before)
pnpm test:watch Run backend tests in watch mode, running on changed test files
pnpm lint Run eslint
pnpm lint:fix Run eslint in fix mode

CI

Run tests on push/PR to master Check .github/workflows/CI.yml

Docker

Build docker image AFTER executing npm run build The docker image copies the build directory, so it has to be present

Recommended Vscode Extensions

Prettier ESLint