Skip to content

Use UUID's, add Rate Limiting#54

Merged
DavidASix merged 23 commits into
mainfrom
staging
Sep 19, 2025
Merged

Use UUID's, add Rate Limiting#54
DavidASix merged 23 commits into
mainfrom
staging

Conversation

@DavidASix

@DavidASix DavidASix commented Sep 19, 2025

Copy link
Copy Markdown
Owner

This PR:

Copilot AI review requested due to automatic review settings September 19, 2025 03:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Moves all business and review IDs from integers to UUIDs, introduces a database-backed rate limiting middleware, and squashes prior migrations into a single initialization migration.

  • Switches businesses.id, reviews.id, and related foreign keys to UUID, updating Zod schemas and server code accordingly
  • Adds rate_limit_events table, an index for efficient lookups, and a reusable withEventRateLimit middleware
  • Replaces historical migrations with a single 0000_table-initialization migration and updates seed scripts to use a shared businessId

Reviewed Changes

Copilot reviewed 45 out of 46 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/schema/schema.ts Converts IDs to UUIDs, updates metadata schema, and adds the rate_limit_events table and index
src/schema/migrations/0000_table-initialization.sql New consolidated migration creating all tables with UUID IDs and rate limiting support
src/schema/migrations/meta/* Replaces old snapshots/journal with a single snapshot for the consolidated migration
src/middleware/withEventRateLimit.ts Introduces database-backed rate limiting middleware and supporting types
src/lib/server/google/update.ts Updates function signatures and JSDoc to use UUID business IDs
src/lib/server/google/select.ts Updates selectors to accept UUID business IDs
src/lib/ownership.ts Generalizes OwnedTable/id types and ownership checks to support UUIDs
src/app/api/*/schema.ts Updates request/response schemas to use z.string().uuid() for business IDs
src/app/api/google/*/route.ts Adjusts logic around business ID parsing and adds rate limiting to fetch-updated-data
src/app/(product)/google-reviews/add-business/page.tsx Updates local state typing for businessId to string
src/scripts/seed/* Seeds updated to use a shared UUID businessId constant
package.json Adds uuid dependency used for application-side UUID defaults
Comments suppressed due to low confidence (1)

src/middleware/withEventRateLimit.ts:1

  • Include a Retry-After response header for 429 responses so clients can programmatically respect backoff. For example: return NextResponse.json(..., { status: 429, headers: { 'Retry-After': String(Math.round(windowMs / 1000)) } });
/**

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/app/api/(endpoints)/v1/fetch-updated-data/route.ts Outdated
Comment thread src/middleware/withEventRateLimit.ts
Comment thread src/schema/migrations/0000_table-initialization.sql
Comment thread src/schema/migrations/0000_table-initialization.sql
Comment thread src/app/api/google/get-business-details/schema.ts
@DavidASix
DavidASix merged commit c469703 into main Sep 19, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants