backend-cuecue
v0.0.1
Published
Hono + TypeScript SaaS backend for Cloudflare Workers.
Readme
Backend Cuecue
Hono + TypeScript SaaS backend for Cloudflare Workers.
It keeps the reusable foundation:
- Cloudflare D1 user/session/order storage
- Google OAuth login and Google One Tap
- JWT session cookies with D1 session revocation
- Current-user settings
- Stripe Checkout subscriptions
- Stripe subscription webhook
- OpenAPI docs and Scalar UI
- CORS, logging, and shared response helpers
Development
pnpm install
cp .env.example .dev.vars
pnpm devWrangler runs the Worker on http://localhost:8787 by default.
The D1 binding is configured in wrangler.jsonc:
- Binding name:
DB - Database name:
vibesdk-db - Database id:
5efcae1d-ad5a-4559-9169-db1906768a53 - Migrations directory:
migrations
Because the D1 binding is marked as remote, pnpm dev uses the shared remote D1 database.
Use pnpm dev:local when you want Wrangler local storage instead, then apply local migrations with
pnpm db:migrate:local.
Useful D1 commands:
pnpm db:list
pnpm db:info
pnpm db:migrations:list:remote
pnpm db:migrate:remoteUseful routes:
GET /api/healthGET /api/auth/googleGET /api/auth/callback/googlePOST /api/auth/google/one-tapPOST /api/auth/logoutGET /api/auth/meGET /api/auth/profileGET /api/auth/providersGET /api/auth/sessionsDELETE /api/auth/sessions/:sessionIdGET /api/settings/user/mePATCH /api/settings/user/mePOST /api/order-management/checkoutPOST /api/order-management/cancelGET /api/order-managementPOST /api/webhookGET /api/docGET /api/reference
Required Setup
Use the shared vibesdk-db D1 database, create a Google Cloud OAuth Web client, and create a Stripe account.
Google OAuth redirect URI:
${API_URL}/api/auth/callback/googleStripe webhook endpoint:
${API_URL}/api/webhookSubscribe the Stripe webhook to:
checkout.session.completedcustomer.subscription.updatedcustomer.subscription.deleted
Database
This project reuses the users, sessions, and oauth_states tables already present in the vibesdk D1 database.
Apply migrations/0005_backend_cuecue_orders.sql when the shared database does not have orders yet:
pnpm db:migrate:remoteThe order migration creates:
CREATE TABLE IF NOT EXISTS `orders` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
order_no text unique not null,
...
);