Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 2.68 KB

README.md

File metadata and controls

60 lines (42 loc) · 2.68 KB

A worker template with a local development experience that lets you write real-world back ends with dignity.

Overview

  • 🔥 Benzene GraphQL fast, minimal (4kB) and runtime-agnostic GraphQL support
  • 🔨 esbuild for fast builds, configured in scripts/build.js
  • 🔎 TypeScript support
  • 💾 Prisma database client support with a proxy that lets you talk to a local database
  • 📦 GitHub actions that automate testing, data migrations and deployment for production

Get started

  1. Create a repo from the template
  2. Clone your new repo
  3. Make sure you have Docker installed
. start.sh

To run the unit tests (in a separate terminal)

npm test

To run the integration tests

npm run itest

Database migrations

  1. Change ./src/prisma/schema.prisma
  2. Create a migration (it will prompt you for a name)
npm run db-migrate-dev
  1. Restart the worker and the Prisma proxy in a new terminal
. restart.sh

The Prisma proxy needs to be restarted because it generates a different database clients in the same folder as the worker. This means that if you generated both Prisma clients on the same file system at the same time, either the proxy or the worker won't work, because they both write to node_modules/@prisma/client.

In order to avoid this conflict, the Prisma proxy lives in a Docker container with a separate file system.

Prerequisites for production

  1. Create a new repo based on the template
  2. Get a database connection string from a database service provider, or host your own. It should look something like this postgresql://johndoe:password@host:port/mydb?schema=public
  3. Add a MIGRATE_DATABASE_URL secret in your GitHub repo to point to your Prisma data proxy account
  4. Create a Prisma Proxy, following step #6 from the Prisma Cloudflare docs
  5. Follow step #7 from the Prisma docs
  6. Add a DATABASE_URL secret to your GitHub repo using the connection string from the Prisma proxy
  7. Create a Cloudflare API token and a GitHub secret called CLOUDFLARE_API_TOKEN,