You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serves the 10 contributors widgets for a collection under /v1-alpha/collections/{slug}/contributors/* (IN-1411, epic IN-1146). Each one reuses its project route handler and passes collectionSlug to the pipe in place of project.
widgetRoutes in src/lib/widget-scope.ts registers one handler under both /projects/{slug}/<path> and /collections/{slug}/<path>. The development and popularity groups adopt it next.
The collection variant resolves the slug through the shared collections query first, so an unknown or private collection answers 404 before any Tinybird call. The Tinybird client resolves the collection's bucket from the slug, so the project bucket lookup is skipped.
repos is not offered for a collection, matching what the Nuxt app sends.
Collection variants are tagged Collections. Their descriptions are rewritten from the project text so they read correctly for a collection, and they gain a sentence about the 404.
The project routes' behaviour and OpenAPI output are unchanged.
Notes
Pipe support for collectionSlug is taken from the Nuxt app, which already calls the same pipes for these widgets in collection scope. All 10 contributors pipes qualify, so none is left out.
activityFilterParams in the Tinybird client now takes the scope target, so collection calls skip the project-only params.
Tests
tests/project-routes.test.ts: a collection-scope variant of the shared route suite covering 404, collectionSlug forwarding, the cache header, 503 mapping, 400s and the OpenAPI listing.
tests/widget-scope.test.ts: description rewriting and schema copying.
Medium Risk
Introduces a new public API surface and collection visibility/404 semantics before upstream calls; logic is shared with project routes so regressions could affect both scopes.
Overview
Adds collection-scoped mirrors of all ten v1-alpha contributors widgets at /v1-alpha/collections/{slug}/contributors/*, reusing the same handlers as the project routes.
A new widgetRoutes helper registers each widget twice: project scope still resolves a Tinybird bucket via withBucket and passes project + bucketId; collection scope checks collectionExists (unknown/private → 404 before Tinybird), strips repos from query/OpenAPI, and forwards collectionSlug through activityFilterParams / pipe queries (bucket via the client’s collection lookup). OpenAPI for collections is tagged Collections, with descriptions rewritten from project copy.
Contributor route files are refactored from inline scope.get to this shared pattern; project behavior and schemas are intended to stay unchanged. Tests add collection parity in project-routes.test.ts, plus widget-scope and collectionExists coverage.
Reviewed by Cursor Bugbot for commit c331d9f. Bugbot is set up for automated code reviews on this repo. Configure here.
This comment only restates what widgetRoutes does. CLAUDE.md:178-180 requires comments to explain a constraint or tradeoff and to avoid narration, so please remove it.
Remove collection-route narration comment
api/tests/project-routes.test.ts:427
This comment narrates the collection-route setup immediately below it without explaining a constraint. CLAUDE.md:178-180 explicitly asks contributors to skip narration comments, so please remove it.
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
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.
Summary
Serves the 10 contributors widgets for a collection under
/v1-alpha/collections/{slug}/contributors/*(IN-1411, epic IN-1146). Each one reuses its project route handler and passescollectionSlugto the pipe in place ofproject.widgetRoutesinsrc/lib/widget-scope.tsregisters one handler under both/projects/{slug}/<path>and/collections/{slug}/<path>. The development and popularity groups adopt it next.reposis not offered for a collection, matching what the Nuxt app sends.Notes
collectionSlugis taken from the Nuxt app, which already calls the same pipes for these widgets in collection scope. All 10 contributors pipes qualify, so none is left out.activityFilterParamsin the Tinybird client now takes the scope target, so collection calls skip the project-only params.Tests
tests/project-routes.test.ts: a collection-scope variant of the shared route suite covering 404,collectionSlugforwarding, the cache header, 503 mapping, 400s and the OpenAPI listing.tests/widget-scope.test.ts: description rewriting and schema copying.tests/collections-db.test.ts:collectionExists.main