A starter project for building an API service using Fastify v5, kysely / postgres, turbo, and pnpm with sample tests and OpenAPI endpoint / database generators to help you build quickly
This is a starter project for building an API server using Typescript, Fastify v5 and Kysely with Postgres.
turbo and pnpm.turbo gen to create new API endpoints and database tables.changesets.typescriptpnpm for package managementchangesets for version and changelogscommitlint for commit message lintingturbo for monorepo managementfastify for the API server frameworkhash-runner for caching buildskysely for the database query builderpostgres + pgAdmin for the databasetestcontainers for testing with a sandboxed postgres instancevitest for endpoint testingloglayer for formatted loggingbiome for linting and formattingsyncpack for keeping package versions in syncHey API for generating the backend SDK using the generated OpenAPI schema from the backendpnpm install turbo --globalpnpm installapps/backend/.env.example to apps/backend/.envStart local postgres server:
docker compose up -d
Perform database migrations:
pnpm db:migrate:lastest
In Github settings (to publish packages and changelogs):
.changeset/config.json to your repositoryCode and Automation > Actions > Workflow permissions
Read and write permissionsAllow Github Actions to create and approve pull requestsSecrets and variables > Actions
Repository Secrets > Actions > create NPM_TOKEN > your npm publish tokenturbo watch dev
Make sure docker is running as it uses testcontainers to spin up a
temporary postgres database.
turbo test
turbo build
Generators for the following:
turbo gen
pnpm db:createpnpm db:latestpnpm db:undopnpm syncpack:update
pnpm changesetundefinednote: To publish a package, private: false must be set in the package.jsonundefined
• Packages in scope: @internal/backend, @internal/backend-client, @internal/backend-errors, @internal/tsconfig
• Running dev in 4 packages
• Remote caching disabled
× failed to connect to daemon
╰─▶ server is unavailable: channel closed
Try:
turbo daemon clean
Then try running turbo watch dev again.
If you get:
• Packages in scope: @internal/backend, @internal/backend-client, @internal/backend-errors, @internal/tsconfig
• Running dev in 4 packages
• Remote caching disabled
× discovery failed: bad grpc status code: The operation was cancelled
Wait a few minutes and try again.
Related:
We use cookies
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.