-
Notifications
You must be signed in to change notification settings - Fork 0
Setup backend for org-managed short links #396
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
Conversation
Need to implement delete still
WalkthroughAdds organization-scoped link support: new org API routes (create/get/delete) with authorization, concurrency checks, transactional deletes and audit logging; new fetchOrgRecords helper and Org types; host-based subdomain→org slug resolution in the edge handler; CloudFront alias and Route53 wildcard updates; edge package dependency added. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant API as API Route
participant Auth as Authorization
participant Dynamo as DynamoDB
participant Log as Audit Log
rect rgb(220,240,255)
Note over Client,Log: POST /orgs/:orgId/redir (Create/Modify Org Link)
end
Client->>API: POST /orgs/:orgId/redir with slug, redirect
API->>Auth: Verify org authorization
Auth-->>API: Authorized / Not Authorized
alt Authorized
API->>Dynamo: PutItem with conditional expression (slug conflict check)
alt Condition succeeds
Dynamo-->>API: Success
API->>Log: Write audit entry (CREATE/MODIFY)
API-->>Client: 201 Created + Location
else ConditionalCheckFailed
Dynamo-->>API: ConditionalCheckFailedException
API-->>Client: 409 Conflict
end
else Not Authorized
API-->>Client: 403 Forbidden
end
sequenceDiagram
participant Client as Client
participant API as API Route
participant Auth as Authorization
participant Dynamo as DynamoDB
participant Log as Audit Log
rect rgb(240,220,255)
Note over Client,Log: DELETE /orgs/:orgId/redir/:slug (Delete Org Link)
end
Client->>API: DELETE /orgs/:orgId/redir/:slug
API->>Auth: Verify org authorization
Auth-->>API: Authorized / Not Authorized
alt Authorized
API->>Dynamo: TransactWriteItems (delete owner record + related group records)
Dynamo-->>API: Transaction result or ConditionalCheckFailed
API->>Log: Write audit entry (DELETE)
API-->>Client: 204 No Content
else Not Authorized
API-->>Client: 403 Forbidden
end
sequenceDiagram
participant Request as Incoming Request
participant Handler as Edge Handler
participant DomainMap as Domain Mapper
participant Dynamo as DynamoDB
rect rgb(220,240,255)
Note over Request,Dynamo: Host-based Slug Resolution in Edge Handler
end
Request->>Handler: HTTP request (path, Host header)
Handler->>DomainMap: Normalize host, map subdomain → org code
alt Recognized subdomain
DomainMap-->>Handler: Org code
Handler->>Handler: Transform path into org-scoped slug (OWNER#<org>)
else Unrecognized
DomainMap-->>Handler: No mapping
Handler->>Handler: Use path as slug
end
Handler->>Dynamo: Query AccessIndex with computed slug
Dynamo-->>Handler: Return link record(s)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45–60 minutes Key areas requiring extra attention:
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
💰 Infracost reportMonthly estimate increased by $1 📈
*Usage costs were estimated using infracost-usage.yml, see docs for other options. Estimate details |
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.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (5)
src/api/functions/linkry.ts(2 hunks)src/api/routes/linkry.ts(4 hunks)src/common/types/linkry.ts(1 hunks)src/linkryEdgeFunction/index.ts(4 hunks)src/linkryEdgeFunction/package.json(1 hunks)
🧰 Additional context used
🪛 ESLint
src/api/functions/linkry.ts
[error] 8-8: Unexpected use of file extension "js" for "common/types/linkry.js"
(import/extensions)
src/common/types/linkry.ts
[error] 30-30: Insert ;
(prettier/prettier)
src/api/routes/linkry.ts
[error] 22-22: Unexpected use of file extension "js" for "../../common/config.js"
(import/extensions)
[error] 24-24: Unexpected use of file extension "js" for "api/plugins/rateLimiter.js"
(import/extensions)
[error] 30-30: Unexpected use of file extension "js" for "common/types/linkry.js"
(import/extensions)
[error] 40-40: Unexpected use of file extension "js" for "api/functions/linkry.js"
(import/extensions)
[error] 41-41: Unexpected use of file extension "js" for "api/plugins/auth.js"
(import/extensions)
[error] 45-45: Unexpected use of file extension "js" for "api/functions/auditLog.js"
(import/extensions)
[error] 46-46: Unexpected use of file extension "js" for "common/modules.js"
(import/extensions)
[error] 48-48: Unexpected use of file extension "js" for "api/components/index.js"
(import/extensions)
[error] 50-50: Unexpected use of file extension "js" for "api/functions/authorization.js"
(import/extensions)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/live/linkry.test.ts (1)
14-19: Consider adding tests for org-specific behavior.While this health check validates basic connectivity to the infra.go endpoint, it doesn't verify any org-scoped functionality mentioned in the PR objectives (e.g., subdomain→org slug resolution, org-specific link records). Consider adding tests that verify:
- Subdomain-based org routing
- Creating/retrieving org-scoped links
- Authorization for org-specific operations
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (3)
tests/live/linkry.test.ts(2 hunks)tests/live/tickets.test.ts(1 hunks)tests/live/utils.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build Application
- GitHub Check: Run Unit Tests
🔇 Additional comments (3)
tests/live/utils.ts (1)
75-75: LGTM!The addition of "infra.go" to the Service type union is consistent with the existing pattern and properly enables testing of the new infra endpoint.
tests/live/linkry.test.ts (1)
5-5: LGTM!The constant declaration properly utilizes the new "infra.go" service type to create a base endpoint for org-scoped testing.
tests/live/tickets.test.ts (1)
33-54: Update the TODO comment with clear next step for writing the live test.The API migration from email-based to UIN-based lookup is already complete and thoroughly tested at the unit level. Comprehensive unit tests exist in
tests/unit/tickets.test.ts(10+ test cases covering happy and sad paths for the POST/api/v1/tickets/getPurchasesByUserendpoint).The TODO just needs a live test written calling the new endpoint with UIN instead of the old email-based GET endpoint. Update the comment to:
// TODO: write live test for POST /api/v1/tickets/getPurchasesByUser endpoint // Should send { uin: "123456789", productId: "..." } and verify response contains merch and tickets arraysLikely an incorrect or invalid review comment.
Summary by CodeRabbit
New Features
Tests
Breaking Changes