A worker template with a local development experience that lets you write real-world back ends with dignity.
- 🔥 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
- Create a repo from the template
- Clone your new repo
- 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
- Change ./src/prisma/schema.prisma
- Create a migration (it will prompt you for a name)
npm run db-migrate-dev
- 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.
- Create a new repo based on the template
- 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
- Add a
MIGRATE_DATABASE_URL
secret in your GitHub repo to point to your Prisma data proxy account - Create a Prisma Proxy, following step #6 from the Prisma Cloudflare docs
- Follow step #7 from the Prisma docs
- Add a
DATABASE_URL
secret to your GitHub repo using the connection string from the Prisma proxy - Create a Cloudflare API token and a GitHub secret called
CLOUDFLARE_API_TOKEN
,