-
Notifications
You must be signed in to change notification settings - Fork 0
staging #10
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
staging #10
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
966c04c
ποΈ (db): integrate Drizzle ORM with Cloudflare D1 and setup CI/CD
daveio 41c3016
π·οΈ (worker-configuration.d.ts): update environment types and formatting
daveio 78f4c61
π¨ (worker-configuration.d.ts): reformat with consistent indentation
daveio 0c1ad33
π sync
daveio 677b44e
π Add AI agent development guide and track context files
daveio 4ee5dc7
β¬οΈ Upgrade @unhead/vue and enhance TypeScript configuration
daveio 65a9ded
π Pin dependencies to specific versions
daveio 1018027
π simplify database documentation and rename migration script
daveio 7f9799d
Merge pull request #9 from tecapps/daveio/database-workflow
daveio 24b3a0f
π· Consolidate CI workflows and update deployment branches
daveio 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
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
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 |
|---|---|---|
|
|
@@ -40,9 +40,3 @@ logs | |
| # Gemini | ||
| .gemini/ | ||
|
|
||
| # AI context | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| GEMINI.md | ||
| WARP.md | ||
| .github/copilot-instructions.md | ||
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
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 |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Agent Guide for Affirm | ||
|
|
||
| This document outlines the development workflow, commands, and patterns for working in this codebase. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| - **Framework**: Nuxt 4 (Vue 3) | ||
| - **Runtime**: Cloudflare Workers (Compatibility Date: 2026-02-01) | ||
| - **Database**: Cloudflare D1 (SQLite) with Drizzle ORM | ||
| - **Package Manager**: Bun | ||
| - **Styling**: Tailwind CSS v4 + DaisyUI | ||
| - **Tooling**: Trunk (lint/format), Vitest (testing), Playwright (e2e) | ||
|
|
||
| ## Essential Commands | ||
|
|
||
| ### Development | ||
|
|
||
| - **Start Dev Server**: `bun run dev` (Runs Nuxt dev server with Cloudflare binding proxies) | ||
| - **Lint & Fix**: `bun run lint:fix` (Runs ESLint and Trunk) | ||
| - **Format**: `bun run format` (Runs Prettier and Trunk) | ||
| - **Type Check**: `bun run lint:types` | ||
|
|
||
| ### Database (Drizzle & D1) | ||
|
|
||
| - **Generate Migrations**: `bun run db:generate` (Run after changing `server/database/schema.ts`) | ||
| - **Migrate Local**: `bun run db:migrate` (Applies migrations to local D1 instance) | ||
| - **Migrate Staging**: `bun run db:migrate:staging` (Applies to `affirm-staging` DB) | ||
| - **Migrate Production**: `bun run db:migrate:prod` (Applies to `affirm` DB) | ||
| - **Drizzle Studio**: | ||
| - Staging: `bun run db:studio:staging` | ||
| - Production: `bun run db:studio:prod` | ||
|
|
||
| ### Testing | ||
|
|
||
| - **Run All Tests**: `bun run test` | ||
| - **Unit Tests**: `bun run test:unit` | ||
| - **Nuxt Tests**: `bun run test:nuxt` | ||
| - **E2E Tests**: `bun run test:e2e` (Playwright) | ||
|
|
||
| ### Deployment | ||
|
|
||
| - **Deploy to Production**: `bun run deploy` | ||
| - **Deploy to Staging**: `bun run deploy:nonprod` (Uploads versions without immediate promotion) | ||
|
|
||
| ## Code Structure | ||
|
|
||
| - **`app/`**: Nuxt 4 application source (pages, components, composables). | ||
| - **`server/`**: Server-side logic (Nitro). | ||
| - **`server/database/`**: Drizzle schema and migrations. | ||
| - **`server/utils/db.ts`**: Database connection utility (`useDB`). | ||
| - **`server/api/`**: API event handlers. | ||
| - **`shared/`**: Shared utilities between client and server. | ||
| - **`.trunk/`**: Configuration for Trunk (linter/formatter manager). | ||
|
|
||
| ## Database Patterns | ||
|
|
||
| ### Schema Definition | ||
|
|
||
| Define tables in `server/database/schema.ts` using `drizzle-orm/sqlite-core`. | ||
|
|
||
| ```typescript | ||
| import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"; | ||
|
|
||
| export const users = sqliteTable("users", { | ||
| id: integer("id").primaryKey({ autoIncrement: true }), | ||
| name: text("name").notNull(), | ||
| }); | ||
| ``` | ||
|
|
||
| ### Accessing Database | ||
|
|
||
| Use the `useDB` utility in server routes. It uses the `DB` binding from the request context. | ||
|
|
||
| ```typescript | ||
| import { useDB } from "../utils/db"; | ||
|
|
||
| export default defineEventHandler(async (event) => { | ||
| const db = useDB(event); | ||
| return await db.query.users.findMany(); | ||
| }); | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| - **`nuxt.config.ts`**: Main Nuxt configuration. | ||
| - **`wrangler.jsonc`**: Cloudflare Workers configuration. Defines `DB` bindings for `prod` and `staging` environments. | ||
| - **`drizzle.config.ts`**: Drizzle Kit configuration. | ||
|
|
||
| ## Gotchas & Guidelines | ||
|
|
||
| 1. **Environment Variables**: Managed via `wrangler.jsonc` bindings for runtime. For local dev, `.dev.vars` is used. | ||
| 2. **Migrations**: Always run `bun run db:generate` after modifying schema. Do not modify SQL files manually. | ||
| 3. **Bindings**: The application relies on Cloudflare bindings (`DB`, `ASSETS`). Ensure `bun run dev` is used to properly proxy these during development. | ||
| 4. **Imports**: Use `~` alias for project root (e.g., `~/server/utils/db`). |
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| AGENTS.md |
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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Prompts | ||
|
|
||
| --- | ||
|
|
||
| ## Database Workflows | ||
|
|
||
| We need to use Drizzle affixed to the Cloudflare Workers `DB` binding instead of connecting separately, so we can benefit from automatic environment mocking and set up a staging environment. | ||
|
|
||
| Currently, we set up an authentication token, configure the account ID, and other related settings in `.env`, but instead, we want to use the Cloudflare Workers binding. We also want to set up a staging database. The staging branch doesn't currently exist, but it will be `staging`. We will also have a staging database at `affirm-staging`. We also need to handle the `MiniFlare` environment, which is mocked locally. | ||
|
|
||
| We need to come up with a system of keeping these environments separate and providing developer tooling to access them while defaulting to the locally mocked `MiniFlare` environment, which should be automatically provided by Wrangler if we use the binding rather than manual configuration. | ||
|
|
||
| Come up with a way of doing this and implement it. | ||
|
|
||
| You can use the Cloudflare Documentation tool for Cloudflare information. Also use the Context7 tool to research Drizzle. | ||
|
|
||
| Also implement a GitHub Action which will take the migrations through from local (no CI), staging on the `staging` branch which does not exist yet, to staging db, and production on the `main` branch. | ||
|
|
||
| Set up scripts in `package.json` to make things smoother. Include a script for Drizzle Studio. | ||
|
|
||
| Document it in `README.md`, including Mermaid diagrams where appropriate, and then implement it. Include step-by-step guides to creating a migration, applying it, following through the lifecycle, and troubleshooting. No need to maintain any agent-facing documentation, just human-facing. | ||
|
|
||
| --- |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deploy-stagingdoes not depend on thelintjob, so it can deploy even when lint/typecheck/build fails (jobs run in parallel by default). Addneeds: lint(and/or gate withif: success()) to prevent deploying broken commits to staging.