Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR: