Template for Bun + Hono REST/GraphQL APIs with PostgreSQL.
Deployment on GCP with Cloud Run and Cloud SQL.
bun install
bun run devcp .env.example .env
bun run db:start # start postgres container
bun run db:up # run migrations
bun run db:seed # seed test dataOther commands: db:down, db:reset, db:stop
bun testSet these environment variables in Cloud Run:
POSTGRES_URL=postgresql://USER:PASSWORD@localhost:PORT/DATABASE
POSTGRES_PATH=/cloudsql/PROJECT:REGION:INSTANCE/.s.PGSQL.PORT
Requirements:
- Add Cloud SQL instance under "Connections" tab
- Service account needs
Cloud SQL Clientrole
cloud-sql-proxy PROJECT:REGION:INSTANCE --port=PORTPOSTGRES_URL="postgresql://USER:PASSWORD@localhost:PORT/DATABASE"