feat: public API preliminary work#1912
Open
epipav wants to merge 10 commits into
Open
Conversation
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR lays groundwork for a standalone public API by adding a new api/ Fastify service and extracting shared, framework-agnostic libraries (libs/tinybird-client, libs/types) that the existing Nuxt frontend can reuse.
Changes:
- Add
api/Fastify service with OpenAPI endpoint and initial Vitest coverage. - Extract Tinybird client logic (throttling, bucket cache, errors, types) into
libs/tinybird-clientwith tests. - Extract shared enums (
ActivityTypes,ActivityPlatforms,Granularity) intolibs/typesand update frontend imports to consume them via workspace deps.
Reviewed changes
Copilot reviewed 159 out of 164 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Add api and libs/* to workspace |
| libs/types/tsconfig.json | TypeScript config for shared types |
| libs/types/tsconfig.build.json | Build config for shared types |
| libs/types/src/index.ts | Re-export shared enums |
| libs/types/src/granularity.ts | Add Granularity enum |
| libs/types/src/activity-types.ts | Add ActivityTypes enum |
| libs/types/src/activity-platforms.ts | Add ActivityPlatforms enum |
| libs/types/prettier.config.mjs | Prettier config for types lib |
| libs/types/package.json | Types lib package metadata |
| libs/types/eslint.config.mjs | ESLint config for types lib |
| libs/tinybird-client/vitest.config.ts | Vitest config for tinybird client |
| libs/tinybird-client/tsconfig.json | TypeScript config for tinybird client |
| libs/tinybird-client/tsconfig.build.json | Build config for tinybird client |
| libs/tinybird-client/tests/throttle.test.ts | Throttle/release behavior tests |
| libs/tinybird-client/tests/client.test.ts | Client request/query tests |
| libs/tinybird-client/tests/adaptive-semaphore.test.ts | Semaphore error/backoff tests |
| libs/tinybird-client/src/types.ts | Public types/interfaces for client |
| libs/tinybird-client/src/index.ts | Library public exports |
| libs/tinybird-client/src/errors.ts | Typed Tinybird client errors |
| libs/tinybird-client/src/client.ts | Tinybird client implementation |
| libs/tinybird-client/src/bucket-cache.ts | BucketId caching + stampede control |
| libs/tinybird-client/src/adaptive-semaphore.ts | Adaptive throttling semaphore |
| libs/tinybird-client/prettier.config.mjs | Prettier config for tinybird lib |
| libs/tinybird-client/package.json | Tinybird lib package metadata |
| libs/tinybird-client/eslint.config.mjs | ESLint config for tinybird lib |
| frontend/types/development/requests.types.ts | Import Granularity from shared lib |
| frontend/server/data/types.ts | Import shared activity enums/granularity |
| frontend/server/data/tinybird/tinybird.ts | Replace local TB logic with shared client |
| frontend/server/data/tinybird/tinybird.test.ts | Update tests to mock shared client |
| frontend/server/data/tinybird/tinybird-throttle.test.ts | Remove redundant throttle tests |
| frontend/server/data/tinybird/requests.types.ts | Import shared activity/granularity enums |
| frontend/server/data/tinybird/popularity/stars.test.ts | Update imports to shared enums |
| frontend/server/data/tinybird/popularity/mailing-lists-messages.ts | Update imports to shared enums |
| frontend/server/data/tinybird/popularity/forks.test.ts | Update imports to shared enums |
| frontend/server/data/tinybird/development/pull-requests.ts | Update import to shared enums |
| frontend/server/data/tinybird/development/pull-requests.test.ts | Update imports to shared enums |
| frontend/server/data/tinybird/development/issues-resolution.ts | Update import to shared enums |
| frontend/server/data/tinybird/development/issues-resolution.test.ts | Update imports to shared enums |
| frontend/server/data/tinybird/development/code-review-engagement.ts | Update import to shared enums |
| frontend/server/data/tinybird/development/code-review-engagement.test.ts | Update imports to shared enums |
| frontend/server/data/tinybird/development/active-days.test.ts | Update import to shared enums |
| frontend/server/data/tinybird/contributors/retention.test.ts | Update import to shared enums |
| frontend/server/data/tinybird/contributors/organizations-leaderboard.test.ts | Update imports to shared enums |
| frontend/server/data/tinybird/contributors/contributors-leaderboard.test.ts | Update imports to shared enums |
| frontend/server/data/tinybird/contributors/active-organizations.test.ts | Update import to shared enums |
| frontend/server/data/tinybird/contributors/active-contributors.test.ts | Update import to shared enums |
| frontend/server/data/tinybird/bucket-cache.ts | Delegate bucket lookups to shared client |
| frontend/server/api/project/[slug]/security/vulnerabilities.get.ts | Guard optional Tinybird total |
| frontend/server/api/project/[slug]/popularity/stars.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/popularity/package-downloads.get.ts | Update import to shared Granularity |
| frontend/server/api/project/[slug]/popularity/mailing-lists-messages.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/popularity/forks.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/development/review-efficiency.get.ts | Update import to shared Granularity |
| frontend/server/api/project/[slug]/development/pull-requests.get.ts | Update import to shared Granularity |
| frontend/server/api/project/[slug]/development/patchsets-per-review.get.ts | Update import to shared Granularity |
| frontend/server/api/project/[slug]/development/median-time-to-review.get.ts | Update import to shared Granularity |
| frontend/server/api/project/[slug]/development/median-time-to-close.get.ts | Update import to shared Granularity |
| frontend/server/api/project/[slug]/development/issues-resolution.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/development/commit-activities.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/development/code-review-engagement.get.ts | Update import to shared Granularity |
| frontend/server/api/project/[slug]/development/active-days.get.ts | Update import to shared Granularity |
| frontend/server/api/project/[slug]/contributors/retention.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/contributors/organization-leaderboard.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/contributors/organization-dependency.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/contributors/geographical-distribution.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/contributors/contributor-leaderboard.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/contributors/contributor-dependency.get.ts | Update imports to shared enums |
| frontend/server/api/project/[slug]/contributors/active-organizations.get.ts | Update import to shared Granularity |
| frontend/server/api/project/[slug]/contributors/active-contributors.get.ts | Update import to shared Granularity |
| frontend/server/api/leaderboard/index.ts | Guard optional Tinybird total |
| frontend/server/api/leaderboard/[type].ts | Guard optional Tinybird total |
| frontend/server/api/community/list.ts | Guard optional Tinybird total |
| frontend/server/api/collection/[slug]/projects.ts | Guard optional Tinybird total |
| frontend/server/api/collection/[slug]/project-repos.ts | Guard optional Tinybird total |
| frontend/package.json | Add workspace deps on new libs |
| frontend/app/config/platforms/configs/twitter.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/stackoverflow.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/slack.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/reddit.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/linkedin.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/jira.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/hackernews.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/groupsio.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/gitlab.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/github.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/git.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/gerrit.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/discourse.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/discord.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/devto.platform.ts | Update ActivityPlatforms import |
| frontend/app/config/platforms/configs/confluence.platform.ts | Update ActivityPlatforms import |
| frontend/app/components/uikit/chart/helpers/formatters.ts | Update Granularity import |
| frontend/app/components/uikit/chart/helpers/chart-helpers.ts | Update Granularity import |
| frontend/app/components/shared/types/granularity.ts | Reuse shared Granularity enum |
| frontend/app/components/shared/modules/share/store/share.api.service.ts | Update Granularity import |
| frontend/app/components/shared/modules/copilot/components/copilot-widget-modal.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/popularity/stars/stars.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/popularity/social-mentions/social-mentions.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/popularity/search-queries/search-queries.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/popularity/press-mentions/press-mentions.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/popularity/package-downloads/package-downloads.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/popularity/package-dependency/package-dependency.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/popularity/mailing-list-messages/mailing-list-messages.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/popularity/github-mentions/github-mentions.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/popularity/forks/forks.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/development/review-efficiency/review-efficiency.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/development/pull-requests/pull-requests.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/development/pull-requests/pull-requests.config.ts | Update Granularity import |
| frontend/app/components/modules/widget/config/development/patchsets-per-review/patchsets-per-review.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/development/median-time-to-review/median-time-to-review.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/development/median-time-to-close/median-time-to-close.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/development/issues-resolution/issues-resolution.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/development/issues-resolution/issues-resolution.config.ts | Update Granularity import |
| frontend/app/components/modules/widget/config/development/commit-activities/commit-activities.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/development/code-review-engagement/code-review-engagement.vue | Update Granularity type import |
| frontend/app/components/modules/widget/config/development/active-days/active-days.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/development/active-days/active-days.config.ts | Update Granularity import |
| frontend/app/components/modules/widget/config/contributor/retention/retention.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/contributor/active-organizations/active-organizations.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/contributor/active-organizations/active-organizations.config.ts | Update Granularity import |
| frontend/app/components/modules/widget/config/contributor/active-contributors/active-contributors.vue | Update Granularity import |
| frontend/app/components/modules/widget/config/contributor/active-contributors/active-contributors.config.ts | Update Granularity import |
| frontend/app/components/modules/widget/composables/usePopularityExcludedWidgets.ts | Update Granularity import |
| frontend/app/components/modules/widget/components/contributors/config/granularity-tabs.ts | Update Granularity import |
| frontend/app/components/modules/project/store/project.store.ts | Update Granularity import |
| frontend/.husky/pre-commit | Add repo-root cd + API checks |
| api/vitest.config.ts | Add API Vitest config |
| api/tsconfig.json | Add API TS config |
| api/tsconfig.build.json | Add API build TS config |
| api/tests/app.test.ts | Test OpenAPI JSON endpoint |
| api/src/server.ts | API server bootstrap |
| api/src/clients/tinybird.ts | Tinybird client wiring for API |
| api/src/app.ts | Fastify app + swagger setup |
| api/README.md | API package docs |
| api/prettier.config.mjs | Prettier config for API |
| api/package.json | API package scripts/deps |
| api/eslint.config.mjs | ESLint config for API |
| api/docs/arch/PUBLIC_API_PLAN.md | Public API plan document |
| api/docs/arch/CONTEXT.md | Canonical terminology document |
| api/docs/arch/architecture-review/03-context.md | Architecture review context |
| api/docs/arch/architecture-review/02-decisions.md | Architecture review decisions |
| api/docs/arch/architecture-review/01-overview.md | Architecture review overview |
| api/docs/arch/adr/0019-opentelemetry-instrumentation.md | ADR: OpenTelemetry requestId |
| api/docs/arch/adr/0018-structured-json-logging.md | ADR: pino logging rules |
| api/docs/arch/adr/0017-collections-queries-not-shared.md | ADR: collections query strategy |
| api/docs/arch/adr/0016-vitepress-scalar-api-docs.md | ADR: docs stack |
| api/docs/arch/adr/0015-api-keys-issued-by-lfx-self-serve.md | ADR: key issuance source |
| api/docs/arch/adr/0014-camelcase-json-iso8601-dates.md | ADR: casing/date format |
| api/docs/arch/adr/0013-origin-cache-only-private-cache-control.md | ADR: origin-only caching |
| api/docs/arch/adr/0012-url-port-strategy-hybrid.md | ADR: URL porting strategy |
| api/docs/arch/adr/0011-pagination-cursor-based.md | ADR: cursor pagination |
| api/docs/arch/adr/0010-billing-bundled-with-lfx-membership.md | ADR: billing model |
| api/docs/arch/adr/0009-api-key-required-for-all-requests.md | ADR: auth required |
| api/docs/arch/adr/0008-typebox-code-first-openapi.md | ADR: TypeBox-only schema |
| api/docs/arch/adr/0007-collections-only-permission-check.md | ADR: collections permission |
| api/docs/arch/adr/0006-refresh-and-short-lived-access-tokens.md | ADR: token model |
| api/docs/arch/adr/0005-tiers-control-rate-limits-only.md | ADR: tiers only rate limits |
| api/docs/arch/adr/0004-server-to-server-cors-deny.md | ADR: no CORS in v1 |
| api/docs/arch/adr/0003-tolerant-reader-versioning.md | ADR: additive-only versioning |
| api/docs/arch/adr/0002-api-at-repo-root.md | ADR: api location |
| api/docs/arch/adr/0001-fastify-over-nestjs.md | ADR: Fastify choice |
| api/.gitignore | Ignore API build artifacts |
| .gitignore | Ignore libs/*/dist |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+5
to
+12
| "type": "module", | ||
| "types": "./src/index.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./src/index.ts", | ||
| "import": "./src/index.ts" | ||
| } | ||
| }, |
Comment on lines
+5
to
+12
| "type": "module", | ||
| "types": "./src/index.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./src/index.ts", | ||
| "import": "./src/index.ts" | ||
| } | ||
| }, |
Comment on lines
+3
to
+5
| export { ActivityPlatforms } from './activity-platforms'; | ||
| export { ActivityTypes } from './activity-types'; | ||
| export { Granularity } from './granularity'; |
Comment on lines
43
to
47
| data: res.data, | ||
| page, | ||
| pageSize, | ||
| total: res.rows_before_limit_at_least, | ||
| total: res.rows_before_limit_at_least ?? 0, | ||
| }; |
Comment on lines
27
to
35
| return { | ||
| data: response.data.map((l) => ({ | ||
| ...l, | ||
| isLF: !!l.isLF, | ||
| })), | ||
| page: page, | ||
| pageSize: pageSize, | ||
| total: response.rows_before_limit_at_least, | ||
| total: response.rows_before_limit_at_least ?? 0, | ||
| }; |
Comment on lines
32
to
37
| return { | ||
| data: response.data, | ||
| page: page, | ||
| pageSize: pageSize, | ||
| total: response.rows_before_limit_at_least, | ||
| total: response.rows_before_limit_at_least ?? 0, | ||
| }; |
Comment on lines
52
to
57
| return { | ||
| data: response.data, | ||
| page: page, | ||
| pageSize: pageSize, | ||
| total: response.rows_before_limit_at_least, | ||
| total: response.rows_before_limit_at_least ?? 0, | ||
| }; |
Comment on lines
98
to
103
| return { | ||
| page, | ||
| pageSize, | ||
| total: response.rows_before_limit_at_least, | ||
| total: response.rows_before_limit_at_least ?? 0, | ||
| data, | ||
| }; |
Comment on lines
127
to
132
| return { | ||
| page, | ||
| pageSize, | ||
| total: response.rows_before_limit_at_least, | ||
| total: response.rows_before_limit_at_least ?? 0, | ||
| data, | ||
| }; |
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.
No description provided.