Manifund Dev Guide
Prerequisites
- Install Bun:
curl -fsSL https://bun.sh/install | bash - Install dependencies:
bun install
Development against prod or dev db
(Easier to get started, but you'll be working against real data, so be careful)
# Get environment variables
bunx vercel link
bunx vercel env pull
# Run against remote
bun run dev # Production database
bun run dev:dev # Development databaseDevelopment against local db
(Somewhat trickier to set up)
- Install docker: Orbstack.dev or Docker desktop
Typical Workflow
- Start local supabase:
bun run supabase:local - Update .env.development.local with local supabase details:
bun run setup-local-env - Import data (Optional):
bun run sync-data-from-prod. This requires additional keys. - Run server using local supabase:
bun run dev:local
If you intend on making database changes:
- Make your schema changes
- Option A: Via Supabase Studio (http://localhost:54323)
- Option B: Write SQL migrations manually
- Generate a migration
- From Studio changes:
npx supabase db diff --schema public --file your_migration_name - Manual:
npx supabase migration new your_migration_namethen edit the file
- From Studio changes:
- Apply migration locally:
npx supabase migration up
- Update local typescript types
bun run gen-types:local
- Test your changes
- Apply migrations to remote supabase projects when ready
# Link to target environment
npx supabase link --project-ref PROJECT_ID # fkousziwzbnkdkldjper for prod, oucjhqqretizqonyfyqu for dev
# Check what migrations will be applied
npx supabase migration list --linked
# Dry run to see what would happen and confirm its safety
npx supabase migration up --linked --dry-run
# Apply migrations
npx supabase migration up --linked
Google OAuth
If you want Google Oauth to work locally, you should provide these values to your .env.development.local
SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID=your-client-id
SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=your-secret
Setup for this requires:
- Creating a google cloud project and (enabling oauth)[https://console.cloud.google.com/apis/credentials]
- Creating Oauth2.0 credentials with
http://127.0.0.1:54321/auth/v1/callbackas an authorized reidrect URI
Typescript type Generation
bunx supabase login
bun run gen-types # From prod
bun run gen-types:dev # From devTesting Stripe Webhooks
stripe listen --forward-to localhost:3000/api/stripe-endpoints