-
Notifications
You must be signed in to change notification settings - Fork 1
fix missing client id #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
88cc92a
chore: readme
aidankmcalister 4562092
fix: updated wrangler.jsonc
aidankmcalister d165d3f
fix: updated again
aidankmcalister 9d8ab5a
fix: updated public env vars
aidankmcalister 66620cd
fix: api route added for getting auth url
aidankmcalister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,11 @@ | ||
# Claim DB Worker | ||
# Claim DB | ||
|
||
A Cloudflare Worker for claiming Prisma databases. This worker handles OAuth authentication with Prisma and transfers database projects to authenticated users. | ||
A Next.js app for claiming and managing Prisma databases, deployed on Cloudflare Workers via OpenNext. | ||
|
||
## Features | ||
|
||
- ✅ OAuth authentication with Prisma | ||
- ✅ Database project claiming | ||
- ✅ Rate limiting (100 requests per minute) | ||
- ✅ PostHog analytics tracking | ||
- ✅ Cloudflare Analytics Engine integration | ||
- ✅ Error handling and user feedback | ||
- ✅ Responsive UI with Tailwind CSS | ||
|
||
## Quick Start | ||
|
||
### Development | ||
|
||
1. **Install dependencies:** | ||
```bash | ||
npm install | ||
``` | ||
|
||
2. **Set up environment variables:** | ||
Create a `.env.local` file: | ||
```env | ||
CLIENT_ID=your_prisma_client_id | ||
CLIENT_SECRET=your_prisma_client_secret | ||
INTEGRATION_TOKEN=your_prisma_integration_token | ||
POSTHOG_API_KEY=your_posthog_api_key | ||
POSTHOG_API_HOST=https://app.posthog.com | ||
``` | ||
|
||
3. **Start development server:** | ||
```bash | ||
npm run dev | ||
``` | ||
|
||
4. **Test the flow:** | ||
Visit `http://localhost:3000/?projectID=test123` | ||
|
||
### Production Deployment | ||
|
||
1. **Set up Cloudflare secrets:** | ||
```bash | ||
wrangler secret put CLIENT_ID | ||
wrangler secret put CLIENT_SECRET | ||
wrangler secret put INTEGRATION_TOKEN | ||
wrangler secret put POSTHOG_API_KEY | ||
wrangler secret put POSTHOG_API_HOST | ||
``` | ||
|
||
2. **Build and deploy:** | ||
```bash | ||
npm run deploy | ||
``` | ||
|
||
## API Endpoints | ||
|
||
- **`/api/claim`** - Generates OAuth URLs and tracks page views | ||
- **`/api/auth/callback`** - Handles OAuth callback and project transfer | ||
- **`/api/test`** - Rate limit testing endpoint | ||
- **`/api/success-test`** - Test endpoint for success page | ||
|
||
## Pages | ||
|
||
- **`/`** - Homepage (redirects to claim flow if projectID provided) | ||
- **`/claim`** - Claim page with OAuth button | ||
- **`/success`** - Success page after claiming | ||
- **`/error`** - Error page for various error states | ||
|
||
## Flow | ||
|
||
1. User visits `/?projectID=123` | ||
2. Homepage redirects to `/api/claim?projectID=123` | ||
3. API generates OAuth URL and redirects to `/claim?projectID=123&authUrl=...` | ||
4. User clicks OAuth, redirects to `/api/auth/callback` | ||
5. API exchanges code for token and transfers project | ||
6. API redirects to `/success?projectID=123` | ||
|
||
## Configuration | ||
|
||
The project uses Cloudflare Worker bindings: | ||
- Rate limiting via `CLAIM_DB_RATE_LIMITER` binding | ||
- Analytics via `CREATE_DB_DATASET` binding | ||
- Environment variables as secrets | ||
|
||
See `wrangler.jsonc` for the complete configuration. | ||
|
||
## Development vs Production | ||
|
||
- **Development**: Uses `process.env` with graceful fallbacks for rate limiting and analytics | ||
- **Production**: Uses Cloudflare Worker bindings via `globalThis` | ||
|
||
The `lib/env.ts` utility handles this automatically. | ||
|
||
## Testing | ||
|
||
- **Local testing**: `npm run dev` then visit with projectID | ||
- **Rate limit testing**: Visit `/api/test` | ||
- **Success page testing**: Visit `/api/success-test` | ||
- Claim Prisma databases with one click | ||
- Monaco-based Prisma schema editor | ||
- Deployed globally on Cloudflare's edge network | ||
- Prisma Studio embed | ||
- Built with Next.js and React | ||
aidankmcalister marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.