Skip to content

Endpoints update and shared types#80

Merged
gaspergrom merged 6 commits intomainfrom
improvement/project-list-endpoint
Mar 10, 2025
Merged

Endpoints update and shared types#80
gaspergrom merged 6 commits intomainfrom
improvement/project-list-endpoint

Conversation

@gaspergrom
Copy link
Copy Markdown
Collaborator

@gaspergrom gaspergrom commented Mar 10, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Updated the main menu navigation so that selecting the link now takes you directly to the Collections page for improved access.
  • Refactor

    • Standardized sorting and display settings across collections and projects for a more consistent browsing experience.
    • Enhanced data handling, ensuring smoother pagination and filtering across content listings.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
@gaspergrom gaspergrom requested a review from borfast March 10, 2025 09:38
@gaspergrom gaspergrom self-assigned this Mar 10, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 10, 2025

Walkthrough

This pull request applies widespread refactoring across both frontend components and server API endpoints. It standardizes sort option values (e.g., from uppercase to lowercase), renames properties (e.g., changing from “projectsCount” to “projectCount” and “contributorsCount” to “contributorCount”), and updates type imports to use a new alias (~~/types/...). API handlers have been updated to return explicitly typed promises with adjusted sorting and pagination logic. Additional configuration improvements include enhanced path resolution in ESLint and tsconfig, the removal of an unused dependency, and the introduction of a new collection type definition.

Changes

File(s) Change Summary
frontend/app/components/modules/collection/components/details/filters.vue Lowercased sort option values (e.g., "name_ASC""name_asc", "contributorsCount_DESC""contributorCount_desc") in the sortOptions array.
frontend/app/components/modules/collection/components/details/header.vue
frontend/app/components/modules/collection/components/list/collection-list-item.vue
Changed property access from projectsCount to projectCount and updated the Collection type import path from a relative path to ~~/types/collection.
frontend/app/components/modules/collection/views/collection-details.vue
frontend/app/components/modules/collection/views/collection-list.vue
Updated initial sort value and pagination index (page from 1 to 0) and revised type imports for Collection, Project, and Pagination.
frontend/app/components/modules/project/components/list/project-list-item.vue
frontend/app/components/modules/project/components/shared/header.vue
frontend/app/components/modules/project/components/shared/header/repository-switch.vue
frontend/app/components/modules/project/store/project.store.ts
frontend/app/pages/project/[slug].vue
Renamed project property names from contributorsCount to contributorCount and organizationsCount to organizationCount, and updated Project and ProjectRepository type import paths to ~~/types/project.
frontend/app/components/shared/layout/navbar.vue Changed the navigation link target from { name: LfxRoutes.EXPLORE } to { name: LfxRoutes.COLLECTIONS }.
frontend/app/components/shared/layout/search/search-modal.vue
frontend/app/components/shared/layout/search/search-result.vue
Updated search-related type imports from "~/components/shared/types/search" to "~~/types/search".
frontend/app/pages/collection/[slug].vue Updated the Collection type import path to ~~/types/collection.
frontend/server/api/collection/[slug].ts
frontend/server/api/collection/index.ts
Replaced the in-file Collection interface with an imported type, updated event handler signatures to return explicit promise types, modified sorting parameters (splitting into orderByField and orderByDirection), and adjusted the fetch typing.
frontend/server/api/project/[slug]/index.ts
frontend/server/api/project/index.ts
Removed in-file project-related interfaces in favor of the imported Project type, updated event handler return types and fetch parameters, and adjusted property names in the API responses.
frontend/server/api/search.ts Narrowed the SearchResponse type by changing the type property to a union of specific literals and updated arrays to use specific search types; introduced a constant for the result limit.
frontend/eslint.config.mjs
frontend/tsconfig.json
Enhanced module path resolution by adding new alias mappings (e.g., "~~/*" and "@/*") for consistent TypeScript imports.
frontend/package.json Removed the "dayjs": "^1.11.13" dependency.
frontend/types/collection.ts
frontend/types/project.ts
frontend/types/search.ts
Added new type definitions for collections (including CollectionFeaturedProject and Collection), renamed properties in the Project interface, and updated SearchProject to allow logo to be string or null.

Possibly related PRs

  • Collections adjustments #61: Involves similar property renaming and removal of type properties, directly relating to the modifications of collection and project interfaces.
  • Collection endpoints #70: Addresses sorting value updates in collection components, which aligns with the updated sort options in this PR.

Suggested reviewers

  • emlimlf

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ffc337 and 23affe1.

📒 Files selected for processing (1)
  • frontend/app/components/modules/project/store/project.store.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/app/components/modules/project/store/project.store.ts

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a 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 (6)
frontend/types/collection.ts (1)

7-15: Consider using boolean instead of number for isLf property.

The Collection interface looks well-structured, but isLf is defined as a number rather than a boolean, which is unusual for what appears to be a flag property. Unless there are multiple states beyond true/false or it specifically needs to match an API response type, consider using a boolean for better type safety.

export interface Collection {
    id: string;
    name: string;
    slug: string;
    description: string;
-    isLf: number;
+    isLf: boolean;
    projectCount: number;
    featuredProjects: CollectionFeaturedProject[];
}
frontend/server/api/collection/[slug].ts (1)

4-43: Documentation needs updating

The API documentation still references the old property names (e.g., projectsCount instead of projectCount). Consider updating the documentation to reflect the new property names.

 *     description: string;
 *     isLf: number;
-*     projectsCount: number;
+*     projectCount: number;
 *     featuredProjects: {
 *       name: string;
 *       slug: string;
frontend/server/api/collection/index.ts (1)

35-41: Consider removing debug logging in production.

While helpful during development, consider removing or conditionally enabling this console.log statement before deploying to production.

-    console.log({
-        count,
-        page,
-        pageSize,
-        orderByField,
-        orderByDirection,
-    })
+    // Only log in development environment
+    if (process.env.NODE_ENV === 'development') {
+        console.log({
+            count,
+            page,
+            pageSize,
+            orderByField,
+            orderByDirection,
+        })
+    }
frontend/server/api/project/[slug]/index.ts (1)

4-31: Documentation needs updating to reflect property name changes

The API documentation still references contributorsCount and organizationsCount, but according to the project changes these have been renamed to contributorCount and organizationCount.

- * - contributorsCount (number): The count of contributors involved in the project.
- * - organizationsCount (number): The count of organizations associated with the project.
+ * - contributorCount (number): The count of contributors involved in the project.
+ * - organizationCount (number): The count of organizations associated with the project.
frontend/server/api/project/index.ts (1)

4-31: Documentation needs updating to match implementation changes

Similar to the previous file, the API documentation references contributorsCount and organizationsCount (lines 29-30), but these properties have been renamed in the actual implementation.

- * - contributorsCount (number): The count of contributors involved in the project.
- * - organizationsCount (number): The count of organizations associated with the project.
+ * - contributorCount (number): The count of contributors involved in the project.
+ * - organizationCount (number): The count of organizations associated with the project.
frontend/server/api/search.ts (1)

12-35: Update API documentation to match code changes.

The API documentation still refers to the arrays as Array<SearchResponse> and the type as string, which is inconsistent with the code changes. Consider updating the documentation to reflect the new specific types.

- * - projects (Array<SearchResponse>): A list of search results of type "project".
- * - repositories (Array<SearchResponse>): A list of search results of type "repository".
- * - collections (Array<SearchResponse>): A list of search results of type "collection".
+ * - projects (Array<SearchProject>): A list of search results of type "project".
+ * - repositories (Array<SearchRepository>): A list of search results of type "repository".
+ * - collections (Array<SearchCollection>): A list of search results of type "collection".

Also update the type description:

- * - type (string): The type identifier for the search result (e.g., "project", "repository", "collection").
+ * - type ('project' | 'repository' | 'collection'): The type identifier for the search result.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 332b473 and 3450e4a.

⛔ Files ignored due to path filters (1)
  • frontend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (27)
  • frontend/app/components/modules/collection/components/details/filters.vue (1 hunks)
  • frontend/app/components/modules/collection/components/details/header.vue (2 hunks)
  • frontend/app/components/modules/collection/components/list/collection-list-item.vue (2 hunks)
  • frontend/app/components/modules/collection/types/Collection.ts (0 hunks)
  • frontend/app/components/modules/collection/views/collection-details.vue (3 hunks)
  • frontend/app/components/modules/collection/views/collection-list.vue (3 hunks)
  • frontend/app/components/modules/project/components/list/project-list-item.vue (3 hunks)
  • frontend/app/components/modules/project/components/shared/header.vue (1 hunks)
  • frontend/app/components/modules/project/components/shared/header/repository-switch.vue (1 hunks)
  • frontend/app/components/modules/project/store/project.store.ts (1 hunks)
  • frontend/app/components/shared/layout/navbar.vue (1 hunks)
  • frontend/app/components/shared/layout/search/search-modal.vue (1 hunks)
  • frontend/app/components/shared/layout/search/search-result.vue (1 hunks)
  • frontend/app/pages/collection/[slug].vue (1 hunks)
  • frontend/app/pages/project/[slug].vue (1 hunks)
  • frontend/eslint.config.mjs (3 hunks)
  • frontend/package.json (0 hunks)
  • frontend/server/api/collection/[slug].ts (2 hunks)
  • frontend/server/api/collection/index.ts (2 hunks)
  • frontend/server/api/project/[slug]/index.ts (2 hunks)
  • frontend/server/api/project/index.ts (2 hunks)
  • frontend/server/api/search.ts (2 hunks)
  • frontend/server/data/tinybird/active-contributors-data-source.test.ts (1 hunks)
  • frontend/tsconfig.json (1 hunks)
  • frontend/types/collection.ts (1 hunks)
  • frontend/types/project.ts (1 hunks)
  • frontend/types/search.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • frontend/package.json
  • frontend/app/components/modules/collection/types/Collection.ts
🔇 Additional comments (58)
frontend/app/components/modules/project/components/shared/header/repository-switch.vue (1)

76-76: Import path update for ProjectRepository looks good

The change to import ProjectRepository from a centralized type definition at the root level is a good architectural decision, making the type more accessible throughout the codebase.

frontend/types/search.ts (1)

9-9: Improved type safety by allowing null for logo

Adding null as a possible value for the logo property accurately represents that projects may not always have logos, improving type safety by forcing explicit null handling.

frontend/app/components/shared/layout/navbar.vue (1)

7-7: Navigation destination updated from Explore to Collections

The navbar logo now navigates to the Collections route instead of Explore, which aligns with the updated routing and information architecture in the application.

frontend/tsconfig.json (1)

20-22: Enhanced path mappings for better module resolution

The additions to the path mappings are beneficial:

  • Keeping ~/* for app directory access
  • Adding @/* as an alternative (common in Vue ecosystems)
  • Adding ~~/* for root level access, supporting the centralized types structure

These changes improve the developer experience and support the type reorganization throughout the codebase.

frontend/types/collection.ts (1)

1-5: Well-defined interface for featured projects.

The CollectionFeaturedProject interface has clear, appropriately typed properties for representing projects within collections.

frontend/types/project.ts (1)

14-15: Good standardization of property naming conventions.

The renaming from plural form (contributorsCount, organizationsCount) to singular form (contributorCount, organizationCount) improves consistency across the codebase and aligns with modern naming conventions for count properties.

frontend/server/data/tinybird/active-contributors-data-source.test.ts (1)

5-5: Improved import organization.

Moving the DateTime import to group with other imports at the top of the file follows best practices for import organization.

frontend/app/pages/collection/[slug].vue (1)

12-12: Correct import path update for restructured type definition.

The updated import path for Collection correctly reflects the type's new location in the centralized types directory, maintaining consistency with the broader type reorganization effort.

frontend/app/components/modules/collection/components/details/filters.vue (1)

89-89: Consistent naming improvements

You've standardized the sort option values by changing them to lowercase and updated the count property names from plural to singular form (e.g., contributorsCount to contributorCount). This makes the naming conventions more consistent throughout the application.

Also applies to: 93-93, 97-97, 101-101

frontend/app/pages/project/[slug].vue (1)

19-19: Good refactoring of type imports

Moving the Project type from a module-specific location to a shared types directory improves code organization and reusability.

frontend/server/api/collection/[slug].ts (1)

2-2: Great API endpoint improvements

These changes enhance the API endpoint in several ways:

  1. Adding an explicit return type Promise<Collection | Error> improves type safety
  2. Utilizing the shared Collection type instead of a local interface reduces duplication
  3. Consistent type usage throughout the function

This makes the code more maintainable and easier to understand.

Also applies to: 44-44, 47-47

frontend/app/components/modules/project/components/shared/header.vue (1)

130-130: Good refactoring of type imports

Centralizing the Project type in a shared location helps maintain consistency across the codebase and reduces duplication.

frontend/app/components/shared/layout/search/search-modal.vue (1)

57-59: Type import path standardization looks good.

The updated import path centralizes type definitions at the project root level, which improves consistency across the codebase and makes type management more maintainable.

frontend/app/components/modules/project/store/project.store.ts (1)

4-4: Type import path standardization looks good.

Centralizing the Project and ProjectRepository types at the root level is consistent with the project-wide refactoring effort and will make type management more maintainable.

frontend/app/components/modules/project/components/list/project-list-item.vue (2)

32-32: Property name standardization looks good.

Changing from plural to singular form for count properties (contributorsCountcontributorCount and organizationsCountorganizationCount) improves naming consistency.

Also applies to: 47-47


71-71: Type import path standardization looks good.

Centralizing the Project type at the root level is consistent with the project-wide refactoring effort.

frontend/server/api/collection/index.ts (5)

2-3: Type import path standardization looks good.

Importing Pagination and Collection types from centralized locations is consistent with the project-wide refactoring effort.


25-25: Improved type safety with explicit return type.

Adding an explicit return type Promise<Pagination<Collection> | Error> enhances type safety and makes the API contract clearer for consumers.


27-28: Improved sort parameter handling.

Breaking down the sort parameter into field and direction components makes the code more maintainable. Using lowercase 'asc' is more consistent with JavaScript conventions.


44-44: Updated parameter passing looks good.

Passing separate orderByField and orderByDirection parameters to the fetchFromTinybird function instead of a combined sort parameter is more explicit and flexible.

Also applies to: 48-50


52-59: Improved response construction with explicit typing.

Creating an explicitly typed data variable makes the code more readable and type-safe.

frontend/app/components/modules/collection/components/details/header.vue (2)

78-78: Property name standardized to singular form

The property projectsCount has been changed to projectCount, which aligns with the PR objective to standardize naming conventions across the codebase. This change improves consistency.


111-111: Type import path updated to use the shared types location

The import path for the Collection type has been updated from a module-specific path to a centralized types location. This change is part of the broader effort to standardize type imports throughout the project.

frontend/app/components/modules/collection/components/list/collection-list-item.vue (2)

24-24: Property name standardized to singular form

The property projectsCount has been changed to projectCount, which aligns with the PR objective to standardize naming conventions across the codebase. This change is consistent with the same update made in the header component.


74-74: Type import path updated to use the shared types location

The import path for the Collection type has been updated from a module-specific path to a centralized types location. This change is part of the broader effort to standardize type imports throughout the project.

frontend/app/components/shared/layout/search/search-result.vue (1)

154-154: Type import path updated to use the shared types location

The import path for the search-related types has been updated from a module-specific path to a centralized types location. This change is part of the broader effort to standardize type imports throughout the project.

frontend/eslint.config.mjs (4)

2-3: Import statement formatting improved

The import statements have been reformatted to remove unnecessary spaces, improving code consistency.


14-16: Chained method indentation adjusted

The indentation of the chained methods has been adjusted for better readability while maintaining the same functionality.


40-42: Added root path alias mapping

The alias mapping now includes ['~~', '.'] alongside the existing ['~', './app'], which supports the new import path pattern seen in the other files for accessing shared type definitions.


44-50: Added TypeScript path configurations

TypeScript path configurations have been added to explicitly define mappings for ~/*, @/*, and ~~/*. This enhancement improves module resolution and supports the type import changes made across the codebase.

frontend/server/api/project/[slug]/index.ts (3)

2-2: Type import looks good!

The import of the Project type from a centralized location is a good practice for maintaining type consistency across the codebase.


32-32: Return type enhancement improves type safety

Adding explicit return type Promise<Project | Error> improves type safety and makes the API contract clearer.


35-35: Type parameter update is consistent

The update to use Project[] as the type parameter for fetchFromTinybird aligns with the other type changes.

frontend/server/api/project/index.ts (7)

2-3: Type imports look good!

The imports of Pagination and Project types from centralized locations follow good practices for type management.


11-11: Sort order standardization

Changing the default sort order from "name_ASC" to "name_asc" is consistent with the standardization mentioned in the PR summary.


35-35: Return type enhancement improves type safety

Adding an explicit return type Promise<Pagination<Project | Error>> improves type safety and makes the API contract clearer.


37-38: Improved sorting implementation

Splitting the sort string into orderByField and orderByDirection is a good approach that makes the sorting logic more explicit and maintainable.


44-44: New collectionSlug parameter

Adding the collectionSlug parameter allows filtering projects by collection, enhancing the API's functionality.


48-56: Updated parameters for fetchFromTinybird

The changes to include collectionSlug, orderByField, and orderByDirection parameters align with the API changes and provide more flexibility for querying projects.


58-65: Improved response structure

The explicit construction of a Pagination<Project> object with properly defined fields improves type safety and makes the response structure more consistent.

frontend/app/components/modules/collection/views/collection-details.vue (7)

54-57: Updated imports improve code organization

The changes to import types from centralized locations (~~/types/) rather than component-specific paths is a good practice for maintaining type consistency across the codebase.


70-72: Route initialization for collection slug

Good addition to retrieve the collection slug from route parameters, which provides better context for API requests.


75-75: Sort value standardization

Changing the sort initial value from uppercase to lowercase ("name_asc") is consistent with the standardization mentioned in the PR summary.


78-78: Pagination starts from 0

Changing the initial page value from 1 to 0 is a good practice as it aligns with common zero-based indexing conventions used in many APIs and programming constructs.


84-84: Consistent pagination reset value

Updating the page reset value to 0 maintains consistency with the initial page value change.


95-95: Added collectionSlug parameter

Adding the collectionSlug to the API request parameters ensures proper filtering of projects by collection.


99-99: Updated page check in transform function

Changing the page check from 1 to 0 in the transform function aligns with the updated pagination approach.

frontend/app/components/modules/collection/views/collection-list.vue (3)

94-95: Updated type imports improve code organization

Importing types from centralized locations (~~/types/) rather than component-specific paths promotes better type consistency and maintainability.


114-114: Sort value standardization

Changing the sort initial value to lowercase ("name_asc") is consistent with the standardization across the codebase.


167-180: Updated sort option values

The changes to sort option values in the sortOptions array (lowercase "name_asc", "projectCount_desc", and commented "softwareValueCount_desc") maintain consistency with the naming convention updates.

frontend/server/api/search.ts (8)

2-2: Good type imports update.

The explicit import of specific types (SearchCollection, SearchProject, SearchRepository) improves type safety and makes the code's intent clearer.


5-5: Improved type safety with union type.

Replacing the generic string type with a specific union type ('project' | 'repository' | 'collection') is a good practice that provides better type checking and documentation.


40-43: Appropriate type refinement for search results.

Using the specific types for each collection array (SearchProject[], SearchRepository[], SearchCollection[]) instead of the generic SearchResponse[] is a good improvement that aligns with the imported types.


44-44: Good practice using a named constant.

Defining the limit as a constant improves code readability and maintainability compared to using magic numbers.


48-48: Consistent use of the limit constant.

Using the newly defined constant in the API call is consistent with the refactoring.


55-59: Type-specific mapping for projects.

The explicit mapping to SearchProject properties ensures type safety when processing search results.


61-64: Type-specific mapping for repositories.

The fallback to empty string for projectSlug ensures the value is never null, which may be required by the SearchRepository type.


66-69: Type-specific mapping for collections.

The fallback to empty string for name ensures the value is never null, which may be required by the SearchCollection type.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/server/api/collection/index.ts (1)

35-41: Be cautious with console logs in production code.

Consider using a proper logging framework or removing this console.log statement before deploying to production.

-    console.log({
-        count,
-        page,
-        pageSize,
-        orderByField,
-        orderByDirection,
-    })
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3450e4a and bc79ac4.

📒 Files selected for processing (4)
  • frontend/server/api/collection/[slug].ts (3 hunks)
  • frontend/server/api/collection/index.ts (2 hunks)
  • frontend/server/api/project/[slug]/index.ts (3 hunks)
  • frontend/server/api/project/index.ts (2 hunks)
🔇 Additional comments (21)
frontend/server/api/collection/[slug].ts (4)

2-2: Good type import adoption.

The code now imports the Collection type from a shared types file instead of using a local interface. This promotes consistency and reuse across the codebase.


24-24: Property name standardization.

The documentation is correctly updated from projectsCount to projectCount, which aligns with the naming convention standardization mentioned in the PR summary.


44-44: Improved type safety with explicit return type.

Adding an explicit return type Promise<Collection | Error> enhances type safety and provides better documentation for API consumers.


47-47: Type parameter alignment.

The type parameter for fetchFromTinybird has been properly updated to use the shared Collection type.

frontend/server/api/collection/index.ts (5)

2-3: Good type imports.

Importing shared types from dedicated type files improves code organization and type consistency across the codebase.


25-25: Enhanced type safety with explicit return type.

Adding an explicit return type Promise<Pagination<Collection> | Error> improves type checking and API documentation.


27-28: Standardized sort parameter format.

The sort parameter now uses lowercase 'name_asc' format and is properly split into field and direction parts, which is more consistent with standard API conventions.


48-50: Improved parameter naming.

Splitting the sort parameter into distinct field and direction parameters improves clarity and flexibility of the API.


52-59: Type-safe response structure.

Creating and returning a properly typed Pagination<Collection> object enhances type safety and ensures consistent response structure.

frontend/server/api/project/[slug]/index.ts (4)

2-2: Good type import.

Using the shared Project type instead of a local interface promotes code reuse and consistency.


18-19: Property naming standardization.

The documentation correctly reflects the property name changes from contributorsCount to contributorCount and organizationsCount to organizationCount.


32-32: Explicit return type added.

The explicit return type Promise<Project | Error> improves type safety and API documentation.


35-35: Type parameter updated.

The type parameter for fetchFromTinybird has been correctly updated to use the shared Project type.

frontend/server/api/project/index.ts (8)

2-3: Good type imports.

Importing shared types from dedicated type files improves code organization and promotes type consistency.


11-11: Updated documentation for sort parameter.

The documentation correctly reflects the standardized lowercase sort format.


16-16: New filter parameter added.

Adding the collectionSlug parameter enhances the API's filtering capabilities.


30-31: Property naming standardization in documentation.

Documentation correctly updated with the new property names contributorCount and organizationCount.


38-39: Improved sort parameter handling.

Standardizing the sort format to lowercase and splitting it into field and direction components improves consistency and flexibility.


45-45: Added filter parameter.

The collectionSlug parameter is properly implemented to allow filtering projects by collection.


53-56: Updated API parameters.

The API parameters have been correctly updated to include the new filter parameter and split sort parameters.


59-66: Type-safe response structure.

The return value is now properly structured and typed as Pagination<Project>, which enhances type safety.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a 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)
frontend/server/api/project/index.ts (1)

22-22: Update documentation to match type changes

The documentation still references ProjectResponse which no longer exists in the code. Update the documentation to reflect that the data array contains Project objects instead.

- * - data (Array<ProjectResponse>): The list of projects in the current page.
+ * - data (Array<Project>): The list of projects in the current page.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc79ac4 and d7a6912.

📒 Files selected for processing (1)
  • frontend/server/api/project/index.ts (2 hunks)
🔇 Additional comments (8)
frontend/server/api/project/index.ts (8)

2-3: Improved type imports enhance code clarity

The addition of explicit type imports for Pagination and Project improves type safety and code clarity. Using shared types across the codebase helps maintain consistency.


11-11: Documentation updated to match code changes

The documentation has been properly updated to reflect the lowercase naming convention for sorting (name_asc) and to document the new collectionSlug parameter.

Also applies to: 16-16


30-31: Naming convention standardization

The property names have been updated from plural (contributorsCount, organizationsCount) to singular (contributorCount, organizationCount), aligning with the standardization mentioned in the PR summary.


36-36: Return type correction implemented

The return type has been corrected to Promise<Pagination<Project> | Error> as suggested in a previous review comment. This properly reflects that the function returns either a paginated list of projects or an error, not a pagination of mixed projects and errors.


38-39: Improved sorting implementation

Breaking down the sort parameter into separate field and direction components is a good practice that makes the sorting logic more maintainable and flexible.


45-45: New collection filtering capability

The addition of the collectionSlug parameter enables filtering projects by collection, enhancing the API's functionality.


49-49: Updated API call parameters

The API call has been properly updated to use the Project type and pass the new parameters (collectionSlug, orderByField, orderByDirection) to the backend.

Also applies to: 53-56


59-66: Improved response structure

The response now uses a properly typed Pagination<Project> structure, which enhances type safety and makes the API contract clearer.

Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
@gaspergrom gaspergrom merged commit 6a108ae into main Mar 10, 2025
1 of 2 checks passed
@gaspergrom gaspergrom deleted the improvement/project-list-endpoint branch March 10, 2025 10:51
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.

3 participants