Replies: 2 comments 3 replies
-
Hi @arkoe, We do have an API available but it only returns 10 items at a time so I can see how that isn't ideal for your use case. One concern is that returning all packages in one response could be slow and potentially rate-limited because the app is currently set up to fetch data from providers when a package is requested (the result is cached for a while but doing it for all packages at once would be costly). But, if we slim down the data returned from this route we can get around that issue. I threw this together to test out the response size and time and it's quick 😄 Route::get('packages.json', function () {
return cache()->remember('all-packages-as-json', 1800, function () {
return Package::all()->map(function ($package) {
return [
'name' => $package->display_name,
'abstract' => $package->abstract,
'url' => route('packages.show', [
'namespace' => $package->composer_vendor,
'name' => $package->composer_package,
]),
];
});
});
}); If I don't have time to clean it up (move to dedicated controller and test) and PR it today, feel free to PR yourself 😄 |
Beta Was this translation helpful? Give feedback.
-
Done in #301 |
Beta Was this translation helpful? Give feedback.
-
Would there be any issues with having a json feed for all packages available, so it could be used for stuff like Discord bots to easily find a package? Similar to what Laravel has for their docs: https://laravel.com/docs/9.x/index.json
I wouldn't mind creating a PR for this feature.
Beta Was this translation helpful? Give feedback.
All reactions