Skip to content

Starter code for node, typescript, fastify, jest, postgresql server

License

Notifications You must be signed in to change notification settings

dmoose/fastify-ts-starter

Repository files navigation

fastify with typescript

Node.js CI

Integrations covered here:

  • local development setup
  • prettier and lint with editor integration
  • integration with a database
  • debugging (launch configurations for vscode for app and jest tests)
  • deployment
  • error logging

Tools:

convict

Used to create a schema for configuration and verify it at run time

copyfiles

Used to copy non typescript file into the dist dirctory during build

ts-node-dev

Restarts on file changes but re-uses compiled files as it can

json-schema-to-typescript

Used to convert the json schemas used by fastify for request/response typing into typescript typings.

Majestic

Jest interactive test runner. Should install globally

Dbmate

Golang tool for database migrations (updates the schema dump in db directory)

Dbmate Commands

dbmate           # print help
dbmate new       # generate a new migration file
dbmate up        # create the database (if it does not already exist) and run any pending migrations
dbmate create    # create the database
dbmate drop      # drop the database
dbmate migrate   # run any pending migrations
dbmate rollback  # roll back the most recent migration
dbmate down      # alias for rollback
dbmate status    # show the status of all migrations (supports --exit-code and --quiet)
dbmate dump      # write the database schema.sql file
dbmate wait      # wait for the database server to become available

Actions

npm run db:dev:start     # bring up a docker image for postgres development server (see services README)
npm run db:dev:stop      # bring down the docker image for postgres development server (see services README)
npm run db:dev:clean     # starts a fresh dev postgres docker image and creates an empty database in it (follow with dbmate up to get full schema)
npm run db:test:clean    # starts a fresh test postgres docker image and creates an empty database and then uses schema.sql to create

https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-migrate prisma db setup

npx prisma migrate save --experimental
npx prisma migrate up --experimental
npx prisma generate

About

Starter code for node, typescript, fastify, jest, postgresql server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published