Skip to content
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

chore(website): type getPackage using the API types #1307

Merged
merged 9 commits into from
Sep 2, 2024
Merged

Conversation

nicosampler
Copy link
Contributor

@nicosampler nicosampler commented Aug 22, 2024

This PR adds types to the getPackage method that brings packages by name or full ref.
All the logic was moved to two new hooks.

Copy link

changeset-bot bot commented Aug 22, 2024

⚠️ No Changeset found

Latest commit: 0184f3c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

nx-cloud bot commented Aug 22, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 0184f3c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@nicosampler nicosampler marked this pull request as ready for review August 29, 2024 14:01
@nicosampler nicosampler requested review from saeta-eth and a team August 29, 2024 14:02
const response = await axios.get<{ total: any; data: ApiDocument[] }>(`packages/${name}`, {
baseURL: externalLinks.API_CANNON,
});
return response.data;
Copy link
Member

@mjlescano mjlescano Aug 30, 2024

Choose a reason for hiding this comment

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

Shouldn't this be response.data.data ?
Not sure about the response object, but the API on GET /packages/:packageName responds with:

{
  status: number,
  total: number,
  data: { ... }
}

Copy link
Contributor Author

@nicosampler nicosampler Aug 30, 2024

Choose a reason for hiding this comment

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

yes, on line 21 we are defining the shape of the date.

then on line 24, we return response.data which will be {total: any; data: ApiDocument}. If we return response.data.data we will be removing the total prop which might be useful in the future.

I just realized that total should be of type number, not any.

Copy link
Member

Choose a reason for hiding this comment

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

Ah perfect, just wanted to make sure that it is being used correctly on the Components

@nicosampler nicosampler changed the title chore(website): try to consume API types from CI chore(website): type getPackage using the API types Aug 30, 2024
@nicosampler nicosampler merged commit 8c6b5b7 into main Sep 2, 2024
8 of 10 checks passed
@nicosampler nicosampler deleted the testApiTypes branch September 2, 2024 14:43
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