diff --git a/compute/README.md b/compute/README.md index 2a404c099cd9..8c4d31574f9e 100644 --- a/compute/README.md +++ b/compute/README.md @@ -9,6 +9,7 @@ Composer. | [`nextjs`](./nextjs) | Next.js App Router app using standalone output for Prisma Compute. | | [`tanstack-start`](./tanstack-start) | TanStack Start app using the Nitro Vite plugin output supported by Prisma Compute. | | [`personal-site`](./personal-site) | Astro personal site with no database. | +| [`form-backend`](./form-backend) | Self-hosted form endpoint (Formspree-style) with a dashboard and CSV export, built with Hono. | Each example includes a Composer module and a GitHub Actions deployment workflow. The database-backed examples also include a Prisma 8 contract, @@ -24,3 +25,7 @@ same version as the `@prisma/composer` libraries provides the local fallback — so deploys run the exact Composer version each app depends on. These pins can move to stable releases once Prisma 8 reaches general availability. + +`form-backend` is a full application rather than a framework starter: it is the +one template that ships a UI, an admin dashboard, and a public write endpoint, +so it doubles as a reference for shaping a real app around a Prisma contract. diff --git a/compute/form-backend/.env.example b/compute/form-backend/.env.example new file mode 100644 index 000000000000..a1d4b5d7dd33 --- /dev/null +++ b/compute/form-backend/.env.example @@ -0,0 +1,10 @@ +# Copy this file to `.env` for the plain `bun run dev` path (no Composer). +# `bun run dev:composer` provisions its own local database and does not need +# DATABASE_URL. + +# Connection string for PostgreSQL. Requires PostgreSQL >= 15. +DATABASE_URL="postgresql://user:password@localhost:5432/mydb" + +# Password for the /admin dashboard. With no value set, the dashboard is +# disabled — there is no default password. +ADMIN_PASSWORD="" diff --git a/compute/form-backend/.gitattributes b/compute/form-backend/.gitattributes new file mode 100644 index 000000000000..721c26ef0de6 --- /dev/null +++ b/compute/form-backend/.gitattributes @@ -0,0 +1,2 @@ +src/prisma/contract.json linguist-generated +src/prisma/contract.d.ts linguist-generated diff --git a/compute/form-backend/.github/workflows/prisma-deploy.yml b/compute/form-backend/.github/workflows/prisma-deploy.yml new file mode 100644 index 000000000000..c216ac88e826 --- /dev/null +++ b/compute/form-backend/.github/workflows/prisma-deploy.yml @@ -0,0 +1,42 @@ +name: prisma-deploy + +on: + push: + delete: + +concurrency: + group: prisma-deploy-${{ github.event_name == 'delete' && github.event.ref || github.ref_name }} + cancel-in-progress: false + +permissions: + contents: read + id-token: write + pull-requests: write + +jobs: + deploy: + if: github.event_name == 'push' && github.ref_type == 'branch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - uses: prisma/cloud-deploy-action@v1 + with: + build-command: bun run build + + teardown: + if: github.event_name == 'delete' && github.event.ref_type == 'branch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - uses: prisma/cloud-deploy-action@v1 + with: + mode: destroy + stage: ${{ github.event.ref }} diff --git a/compute/form-backend/.gitignore b/compute/form-backend/.gitignore new file mode 100644 index 000000000000..26fcb5a99ead --- /dev/null +++ b/compute/form-backend/.gitignore @@ -0,0 +1,12 @@ +node_modules/ +dist/ + +.env* +!.env.example + +.prisma/ +.prisma-composer/ +.alchemy/ + +*.log +.DS_Store diff --git a/compute/form-backend/README.md b/compute/form-backend/README.md new file mode 100644 index 000000000000..a8ee30182051 --- /dev/null +++ b/compute/form-backend/README.md @@ -0,0 +1,254 @@ +# Form Backend + +A self-hostable form endpoint. Deploy it once, create a form in the dashboard, +then point any static site's `