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

[BREAKING] Code refactoring #37

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

frugan-dev
Copy link
Contributor

@frugan-dev frugan-dev commented Feb 24, 2024

DONE

  • dropped support for Laravel <= 8
  • dropped support for PHP <= 8.1 (Laravel ^9 || ^10 already supports PHP 8.2 https://endoflife.date/laravel)
  • updated all composer packages
  • added shared method getResponse()
  • fixed $response returned by Cache::remember() https://stackoverflow.com/a/74783008/3929620
  • used closure in $response->throw()
  • revised esceptions classes, now extend Illuminate\Http\Client\RequestException
  • used Http::withToken() instead of Http::withHeaders()
  • used Http::withQueryParameters() instead of http_build_query()
  • added Http::withOptions() and Http::baseUrl()
  • renamed parameter $type to $name, as it is more consistent with the field used by Strapi
  • renamed $queryData to $queryParams, as it is more consistent with Http::withQueryParameters()
  • removed almost all parameters (e.g. $sortKey, $sortOrder, $populate, etc.) in favor of $queryParams, which allows greater control over the API parameters used
  • now $queryParams also allows you to use pagination by offset values (pagination[start] and pagination[limit]), which previously conflicted with pagination by page values (pagination[page] and pagination[limit]) set directly within the method collection()
  • added optional $cacheTime parameter to override the global value defined in STRAPI_CACHE_TIME per-call
  • removed the collectionCount() method, as the /api/$name/count entrypoint does not seem to exist anymore in Strapi v4 (?), and also the pagination[withCount] parameter exists and it's active by default
  • removed the entriesByField() method as it is superfluous, because it is possible to make the same call with the collection() method (see examples in README)
  • moved option STRAPI_FULL_URLS globally in .env file
  • removed $pluck parameter as it is superfluous to the primary functionality of this package: everyone is free to alter the response as they wish
  • incremented config('strapi.pagination.limit') from 20 to 25 (default Strapi pagination[pageSize])
  • revised the entire README file

TODO

# .env.local
HTTP_CLIENT_VERIFY_SSL=false
// config/http.php
return [
    'client' => [
        'verify_ssl' => (bool) env('HTTP_CLIENT_VERIFY_SSL', true),
    ],
];
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Http;

public function boot(): void
{
    Http::globalOptions([
	'verify' => config('http.client.verify_ssl'),
    ]);
}

Copy link
Contributor

@Stubbs Stubbs left a comment

Choose a reason for hiding this comment

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

Looks good to me. The new queryParams means I don't have to re-implement my changes that introduced filters to the collection method.

@frugan-dev
Copy link
Contributor Author

Hi @dbfx, is there any problem accepting this pull request?

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.

None yet

2 participants