diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index f426c044..7659700a 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -17,4 +17,4 @@ jobs: - name: Install Dependencies run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - name: Running static analysis - run: vendor/bin/phpstan analyse --memory-limit=2G + run: vendor/bin/phpstan analyse --level=1 --memory-limit=2G diff --git a/Dockerfile b/Dockerfile index 28ecb93b..606c209f 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,6 @@ FROM php:8.2-fpm # Arguments defined in docker-compose.yml -ARG user -ARG uid RUN pecl install xdebug \ && docker-php-ext-enable xdebug @@ -38,8 +36,6 @@ RUN useradd -G www-data,root -u 1000 -d /home/dev dev RUN mkdir -p /home/dev/.composer && \ chown -R dev:dev /home/dev -USER $user - RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/php.ini RUN echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/php.ini RUN echo "xdebug.idekey=PHPSTORM" >> /usr/local/etc/php/conf.d/php.ini diff --git a/Makefile b/Makefile index a76c8efa..a1ac24fa 100755 --- a/Makefile +++ b/Makefile @@ -23,13 +23,13 @@ docker_push_image: @docker push fokosun/cookbookshq-api:v1 db_seed: ## seed the database - @php artisan db:seed + @docker-compose exec app php artisan db:seed db_migrate: ## run db migrations - @php artisan migrate + @docker-compose exec app php artisan migrate db_schemefy: ## Display the db schema in table format - @php artisan schema:show + @docker-compose exec app php artisan schema:show setup: composer generate_key jwt_key db_connection @@ -53,16 +53,16 @@ db_connection: ## Generate DB Connection details and set in .env @docker-compose exec app php artisan db:connection login: ## Creates a new user/token or generate new token for given user - @php artisan auth:token + @docker-compose exec app php artisan auth:token test_unit: ## Run unit testsuite - @php vendor/bin/phpunit --testsuite=Unit + @docker-compose exec app php vendor/bin/phpunit --testsuite=Unit test_feature: ## Run Feature tests - @php vendor/bin/phpunit --testsuite=Feature + @docker-compose exec app php vendor/bin/phpunit --testsuite=Feature test: ## Run the entire test suites - @php vendor/bin/phpunit tests/ + @docker-compose exec app php vendor/bin/phpunit tests/ shell_app: ## ssh into the app container @docker-compose exec app /bin/bash @@ -73,30 +73,27 @@ shell_db: ## ssh into the database container clear: clear_cache clear_views clear_routes dump_autoload clear_cache: - @php artisan cache:clear + @docker-compose exec app php artisan cache:clear clear_views: - @php artisan view:clear + @docker-compose exec app php artisan view:clear clear_routes: - @php artisan route:clear + @docker-compose exec app php artisan route:clear dump_autoload: ## Composer dumpautoload - @composer dumpautoload + @docker-compose exec app composer dumpautoload up: ## Restarts and provisions the containers in the background @docker-compose up -d -docker_prune: prune_images prune_volumes prune_containers +docker_prune: prune_volumes prune_images prune_images: ## Remove dangling images and free up space - @docker image prune - -prune_containers: ## Remove the containers - @docker container prune + @docker image rm api-app mariadb nginx redis prune_volumes: ## Removes dangling volumes - @docker volume prune + @docker volume rm api_mysqldata api_cache static_analysis: - @php ./vendor/bin/phpstan analyse --memory-limit=2G + @docker-compose exec app php ./vendor/bin/phpstan analyse --memory-limit=2G diff --git a/app/Dtos/Contracts/isReadOnly.php b/app/Dtos/Contracts/isReadOnly.php new file mode 100644 index 00000000..caa4e300 --- /dev/null +++ b/app/Dtos/Contracts/isReadOnly.php @@ -0,0 +1,8 @@ +$property ?? null; + } + + public function toArray(): array + { + return [ + 'name' => $this->name, + 'meta' => $this->meta, + 'status' => $this->status, + 'notificationMessage' => $this->notificationMessage, + 'shortSummary' => $this->shortSummary + ]; + } +} diff --git a/app/Dtos/TikTokUserDto.php b/app/Dtos/TikTokUserDto.php index d7988585..102c3597 100644 --- a/app/Dtos/TikTokUserDto.php +++ b/app/Dtos/TikTokUserDto.php @@ -4,7 +4,9 @@ namespace App\Dtos { - readonly class TikTokUserDto + use App\Dtos\Contracts\isReadOnly; + + readonly class TikTokUserDto implements isReadOnly { public int $user_id; public string $open_id; diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index 4f934ef9..09c7763d 100755 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -16,7 +16,6 @@ class CommentController extends Controller { public function addComment(Request $request) { - /** @phpstan-ignore-next-line */ if ($user = JWTAuth::parseToken()->user()) { $payload = $request->only([ 'resource-type', 'resource-id', 'comment' @@ -49,7 +48,6 @@ public function addComment(Request $request) public function destroyComment(Request $request) { - /** @phpstan-ignore-next-line */ if ($user = JWTAuth::parseToken()->user()) { $payload = $request->only(['comment-id']); $comment = Comment::findOrFail($request->only(['comment-id']))->first(); diff --git a/app/Http/Controllers/HealthCheckController.php b/app/Http/Controllers/HealthCheckController.php new file mode 100644 index 00000000..94770a0d --- /dev/null +++ b/app/Http/Controllers/HealthCheckController.php @@ -0,0 +1,77 @@ +healthChecker = $healthChecker; + } + + /** + * CookbooksHQ Health status checks + * + * @return \Illuminate\Http\JsonResponse + */ + public function check(): JsonResponse + { + $this->registerChecks(); + + return $this->successResponse( + array_map(function ($check) { + return $this->newHealthStatusDto($check->run(), $check->getName())->toArray(); + }, $this->healthChecker->registeredChecks()->toArray()) + ); + } + + /** + * @return void + */ + private function registerChecks(): void + { + $this->healthChecker->checks( + [ + EnvironmentCheck::new()->expectEnvironment(getenv('APP_ENV')), + UsedDiskSpaceCheck::new() + ->warnWhenUsedSpaceIsAbovePercentage(70) + ->failWhenUsedSpaceIsAbovePercentage(90), + CpuLoadCheck::new() + ->failWhenLoadIsHigherInTheLast5Minutes(2.0) + ->failWhenLoadIsHigherInTheLast15Minutes(1.5), + DatabaseCheck::new() + ->connectionName(getenv('DB_CONNECTION')) + ] + ); + } + + /** + * @param Result $healthStatusResult + * @param string $checkName + * @return HealthChecksDto + */ + private function newHealthStatusDto(Result $healthStatusResult, string $checkName): HealthChecksDto + { + return new HealthChecksDto( + $checkName, + $healthStatusResult->meta, + $healthStatusResult->status->value, + $healthStatusResult->notificationMessage, + $healthStatusResult->shortSummary + ); + } +} diff --git a/app/Http/Controllers/RecipeController.php b/app/Http/Controllers/RecipeController.php index f5c6af6f..b306f249 100755 --- a/app/Http/Controllers/RecipeController.php +++ b/app/Http/Controllers/RecipeController.php @@ -67,7 +67,6 @@ public function addClap(Request $request): JsonResponse ); return ($recipe = $this->service->addClap($request->get('recipe_id'))) ? - /** @phpstan-ignore-next-line */ $this->successResponse(['updated' => true, 'claps' => $recipe->claps]) : $this->errorResponse(['error' => 'There was an error processing this request. Please try again.']); } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index f35df16d..6e82317f 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -80,7 +80,6 @@ public function update($username, UserUpdateRequest $request) public function followUser(Request $request) { - /** @phpstan-ignore-next-line */ if ($user = JWTAuth::parseToken()->user()) { if ($toFollow = $request->get('toFollow')) { $userToFollow = $this->service->findWhere($toFollow)->first(); @@ -146,7 +145,6 @@ private function getWhoToFollowData(User $user) public function addFeedback(Request $request) { - /** @phpstan-ignore-next-line */ if ($user = JWTAuth::parseToken()->user()) { $hasRespondedAlready = UserFeedback::where(['user_id' => $user->getKey(), 'type' => 'feedback']); @@ -172,7 +170,6 @@ public function addFeedback(Request $request) public function listVideos(HttpRequestRunner $requestRunner) { - /** @phpstan-ignore-next-line */ if ($user = JWTAuth::parseToken()->user()) { $tikTokUser = $user->getTikTokUser(); $errors = [ diff --git a/app/Http/Middleware/JWTAuthGuard.php b/app/Http/Middleware/JWTAuthGuard.php index d65b8692..f2e02b60 100755 --- a/app/Http/Middleware/JWTAuthGuard.php +++ b/app/Http/Middleware/JWTAuthGuard.php @@ -17,10 +17,8 @@ class JWTAuthGuard public function handle(Request $request, Closure $next) { try { - /** @phpstan-ignore-next-line */ if (JWTAuth::parseToken()->authenticate()) { - /** @phpstan-ignore-next-line */ $request->merge(["user_id" => JWTAuth::parseToken()->user()->getKey()]); return $next($request); diff --git a/app/Interfaces/serviceInterface.php b/app/Interfaces/serviceInterface.php index 8ccefab6..b3301658 100755 --- a/app/Interfaces/serviceInterface.php +++ b/app/Interfaces/serviceInterface.php @@ -8,13 +8,33 @@ interface serviceInterface { + /** + * @return mixed + */ public function index(); - public function show($option); + /** + * @param string|int $option + * @return mixed + */ + public function show(string|int $option); + /** + * @param Request $request + * @return mixed + */ public function store(Request $request); + /** + * @param Request $request + * @param string $option + * @return mixed + */ public function update(Request $request, string $option); - public function findWhere($q); + /** + * @param string|int $q + * @return mixed + */ + public function findWhere(string|int $q); } diff --git a/app/Services/CookbookService.php b/app/Services/CookbookService.php index cfd62cb8..8799258e 100755 --- a/app/Services/CookbookService.php +++ b/app/Services/CookbookService.php @@ -71,15 +71,12 @@ public function store(Request $request): bool } } - /** @phpstan-ignore-next-line */ $cookbook->slug = DbHelper::generateUniqueSlug($request->name, 'cookbooks', 'slug'); if ($cookbook->save()) { - /** @phpstan-ignore-next-line */ $cookbook->users()->attach($cookbook->user_id); foreach ($categories as $category) { - /** @phpstan-ignore-next-line */ $cookbook->categories()->attach($category); } diff --git a/app/Services/SearchService.php b/app/Services/SearchService.php index 34f01928..8b0d0549 100755 --- a/app/Services/SearchService.php +++ b/app/Services/SearchService.php @@ -66,7 +66,6 @@ public function getAllCookbooksByTag(array $tags): Collection } } - /** @phpstan-ignore-next-line */ $result->metaData = [ 'contains' => $contains, 'missing' => $missing @@ -166,7 +165,6 @@ public function getAllCookbooksByCategoryName($category_names) } } - /** @phpstan-ignore-next-line */ $result->metaData = [ 'contains' => $contains, 'missing' => $missing @@ -244,7 +242,6 @@ public function getAllRecipesByIngredientName($ingredients) */ public function getAllCookbooksByMe($cookbookName = "") { - /** @phpstan-ignore-next-line */ if ($user = JWTAuth::parseToken()->user()) { $me = $user->getKey(); @@ -269,7 +266,6 @@ public function getAllCookbooksByMe($cookbookName = "") */ public function getAllRecipesByMe($recipeName = "") { - /** @phpstan-ignore-next-line */ if ($user = JWTAuth::parseToken()->user()) { $me = $user->getKey(); @@ -285,7 +281,6 @@ public function getAllRecipesByMe($recipeName = "") public function getFollowing() { - /** @phpstan-ignore-next-line */ if ($me = JWTAuth::parseToken()->user()) { $recipes = []; $following = Following::where(['follower_id' => $me->getKey()])->pluck('following')->toArray(); diff --git a/app/Services/TikTok/AccessToken.php b/app/Services/TikTok/AccessToken.php index 7f382d71..c2bbf745 100644 --- a/app/Services/TikTok/AccessToken.php +++ b/app/Services/TikTok/AccessToken.php @@ -7,9 +7,7 @@ class AccessToken extends Request { -// private $endpoint = 'access-token'; - - public function handle() + public function handle(): void { $firstRequest = $this->httpClient->post('https://open.tiktokapis.com/v2/oauth/token/', [ 'headers' => [ @@ -27,7 +25,9 @@ public function handle() $decoded = json_decode($firstRequest->getBody()->getContents(), true); if ($decoded["error"]) { - throw new InvalidArgumentException(json_encode($decoded)); + if ($exception = json_encode($decoded)) { + throw new InvalidArgumentException($exception); + } } Config::set('tiktok', ['access_token' => $decoded['access_token']]); diff --git a/app/Services/TikTok/HttpRequestRunner.php b/app/Services/TikTok/HttpRequestRunner.php index 15b934b6..337d8cb4 100644 --- a/app/Services/TikTok/HttpRequestRunner.php +++ b/app/Services/TikTok/HttpRequestRunner.php @@ -2,11 +2,19 @@ namespace App\Services\TikTok; +use Exception; use Illuminate\Support\Facades\Config; class HttpRequestRunner { - public function __invoke(array $config, bool $async = false, Request...$requests) + /** + * @param array $config + * @param bool $async + * @param Request ...$requests + * @return $this + * @throws Exception + */ + public function __invoke(array $config, bool $async = false, Request...$requests): self { $this->validateConfig($config); @@ -22,23 +30,28 @@ public function __invoke(array $config, bool $async = false, Request...$requests } //todo - public function handleSync() {} + public function handleSync(): void {} - public function getContents() + public function getContents(): array { return Config::get('tiktok'); } - private function setCode(string $code) + private function setCode(string $code): void { Config::set('tiktok', ['code' => $code]); } - private function validateConfig(array $options = []) + /** + * @param array $options + * @return void + * @throws Exception + */ + private function validateConfig(array $options = []): void { foreach ($options as $i => $j) { if (is_numeric($i)) { - throw new \Exception('Invalid type. Must be a key/value pair.'); + throw new Exception('Invalid type. Must be a key/value pair.'); } } diff --git a/app/Services/TikTok/Request.php b/app/Services/TikTok/Request.php index 2ad916b7..6d9013f9 100644 --- a/app/Services/TikTok/Request.php +++ b/app/Services/TikTok/Request.php @@ -6,17 +6,17 @@ abstract class Request { - protected $httpClient; - private $endpoint = ''; + protected Client $httpClient; + private string $endpoint = ''; public function __construct() { $this->httpClient = new Client(); } - public abstract function handle(); + public abstract function handle(): void; - public function getEndpoint() + public function getEndpoint(): string { return $this->endpoint; } diff --git a/app/Services/TikTok/UserInfo.php b/app/Services/TikTok/UserInfo.php index ca60f702..5d1125d5 100644 --- a/app/Services/TikTok/UserInfo.php +++ b/app/Services/TikTok/UserInfo.php @@ -4,6 +4,5 @@ class UserInfo extends Request { -// private $endpoint = 'user-info'; - public function handle() {} + public function handle(): void {} } diff --git a/app/Services/TikTok/Videos.php b/app/Services/TikTok/Videos.php index 82980c66..b71d6480 100644 --- a/app/Services/TikTok/Videos.php +++ b/app/Services/TikTok/Videos.php @@ -7,9 +7,7 @@ class Videos extends Request { -// private $endpoint = 'video-links'; - - public function handle() + public function handle(): void { $nextRequest = $this->httpClient->request('POST', 'https://open.tiktokapis.com/v2/video/list/', @@ -40,7 +38,9 @@ public function handle() if ($decoded["error"]) { $stage = '/video/list/'; - throw new InvalidArgumentException(json_encode($decoded)); + if ($exception = json_encode($decoded)) { + throw new InvalidArgumentException($exception); + } } } } diff --git a/app/Services/UserContactDetailsService.php b/app/Services/UserContactDetailsService.php index c823e776..67a59db1 100755 --- a/app/Services/UserContactDetailsService.php +++ b/app/Services/UserContactDetailsService.php @@ -4,7 +4,6 @@ namespace App\Services; -use App\Models\Cookbook; use App\Models\User; use App\Models\UserContactDetail; use Illuminate\Http\Request; @@ -18,14 +17,13 @@ public function __construct() $this->serviceModel = new UserContactDetail(); } - protected $contact_detail; - /** * Creates new user contact detail * * @param Request $request + * @return void */ - public function store(Request $request) + public function store(Request $request): void { $detail = new UserContactDetail($request->only([ 'user_id', diff --git a/app/Services/UserService.php b/app/Services/UserService.php index ce332e4d..09dbf6c3 100755 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -8,8 +8,11 @@ use App\Models\User; use App\Models\UserContactDetail; use App\Utils\DbHelper; +use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Collection; use Illuminate\Hashing\BcryptHasher; use Illuminate\Http\Request; +use Illuminate\Pagination\LengthAwarePaginator; /** * Class UserService @@ -24,7 +27,7 @@ public function __construct() /** * Get all users from the database */ - public function index() + public function index(): LengthAwarePaginator { return User::paginate(15); } @@ -32,7 +35,7 @@ public function index() /** * Create a new user resource */ - public function store(Request $request) + public function store(Request $request): bool { $user = new User([ 'name' => $request->name, @@ -61,7 +64,7 @@ public function store(Request $request) return false; } - public function show($q) + public function show(string|int $q): Collection { return $this->findWhere($q)->get()->append(['tiktok_videos']); } @@ -103,10 +106,10 @@ public function update(Request $request, string $option) } /** - * @param $q - * @return \Illuminate\Database\Eloquent\Builder + * @param string|int $q + * @return Builder */ - public function findWhere($q) + public function findWhere(string|int $q): Builder { return User::with(['cookbooks', 'recipes']) ->where('id', '=', $q) diff --git a/app/Traits/EncryptsPayload.php b/app/Traits/EncryptsPayload.php index 79c598bc..3cc53a49 100755 --- a/app/Traits/EncryptsPayload.php +++ b/app/Traits/EncryptsPayload.php @@ -11,7 +11,7 @@ trait EncryptsPayload /** * Encrypts the given payload using Crypt * - * @param array $payload + * @param array $payload * @return string */ public function encryptPayload(array $payload): string diff --git a/app/Utils/UriHelper.php b/app/Utils/UriHelper.php index 3f1344b7..55b5b181 100644 --- a/app/Utils/UriHelper.php +++ b/app/Utils/UriHelper.php @@ -6,6 +6,9 @@ class UriHelper { + /** + * @param array $parameters + */ public static function buildHttpQuery(string $redirectToPage, array $parameters): string { $redirectToPage = $redirectToPage . '.beta-version-1-staging'; diff --git a/bootstrap/cache/packages.php b/bootstrap/cache/packages.php index b4fdb599..1bbbf62a 100755 --- a/bootstrap/cache/packages.php +++ b/bootstrap/cache/packages.php @@ -6,6 +6,17 @@ 0 => 'Hammerstone\\Sidecar\\Providers\\SidecarServiceProvider', ), ), + 'ichtrojan/laravel-otp' => + array ( + 'providers' => + array ( + 0 => 'Ichtrojan\\Otp\\OtpServiceProvider', + ), + 'aliases' => + array ( + 'Otp' => 'Ichtrojan\\Otp\\Otp', + ), + ), 'ipinfo/ipinfolaravel' => array ( 'providers' => @@ -94,6 +105,17 @@ 0 => 'SocialiteProviders\\Manager\\ServiceProvider', ), ), + 'spatie/laravel-health' => + array ( + 'providers' => + array ( + 0 => 'Spatie\\Health\\HealthServiceProvider', + ), + 'aliases' => + array ( + 'Health' => 'Spatie\\Health\\Facades\\Health', + ), + ), 'spatie/laravel-ignition' => array ( 'providers' => diff --git a/bootstrap/cache/services.php b/bootstrap/cache/services.php index 1b915976..3163625f 100755 --- a/bootstrap/cache/services.php +++ b/bootstrap/cache/services.php @@ -24,28 +24,30 @@ 20 => 'Illuminate\\Validation\\ValidationServiceProvider', 21 => 'Illuminate\\View\\ViewServiceProvider', 22 => 'Hammerstone\\Sidecar\\Providers\\SidecarServiceProvider', - 23 => 'ipinfo\\ipinfolaravel\\ipinfolaravelServiceProvider', - 24 => 'Laravel\\Sail\\SailServiceProvider', - 25 => 'Laravel\\Socialite\\SocialiteServiceProvider', - 26 => 'Laravel\\Tinker\\TinkerServiceProvider', - 27 => 'Carbon\\Laravel\\ServiceProvider', - 28 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider', - 29 => 'Termwind\\Laravel\\TermwindServiceProvider', - 30 => 'PHPOpenSourceSaver\\JWTAuth\\Providers\\LaravelServiceProvider', - 31 => 'Sentry\\Laravel\\ServiceProvider', - 32 => 'Sentry\\Laravel\\Tracing\\ServiceProvider', - 33 => 'SocialiteProviders\\Manager\\ServiceProvider', - 34 => 'Spatie\\LaravelIgnition\\IgnitionServiceProvider', - 35 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider', - 36 => 'Ichtrojan\\Otp\\OtpServiceProvider', - 37 => 'App\\Providers\\AppServiceProvider', - 38 => 'App\\Providers\\AuthServiceProvider', - 39 => 'App\\Providers\\EventServiceProvider', - 40 => 'App\\Providers\\RouteServiceProvider', - 41 => 'Laravel\\Socialite\\SocialiteServiceProvider', - 42 => 'SocialiteProviders\\Manager\\ServiceProvider', - 43 => 'Thedevsaddam\\LaravelSchema\\LaravelSchemaServiceProvider', - 44 => 'Sentry\\Laravel\\ServiceProvider', + 23 => 'Ichtrojan\\Otp\\OtpServiceProvider', + 24 => 'ipinfo\\ipinfolaravel\\ipinfolaravelServiceProvider', + 25 => 'Laravel\\Sail\\SailServiceProvider', + 26 => 'Laravel\\Socialite\\SocialiteServiceProvider', + 27 => 'Laravel\\Tinker\\TinkerServiceProvider', + 28 => 'Carbon\\Laravel\\ServiceProvider', + 29 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider', + 30 => 'Termwind\\Laravel\\TermwindServiceProvider', + 31 => 'PHPOpenSourceSaver\\JWTAuth\\Providers\\LaravelServiceProvider', + 32 => 'Sentry\\Laravel\\ServiceProvider', + 33 => 'Sentry\\Laravel\\Tracing\\ServiceProvider', + 34 => 'SocialiteProviders\\Manager\\ServiceProvider', + 35 => 'Spatie\\Health\\HealthServiceProvider', + 36 => 'Spatie\\LaravelIgnition\\IgnitionServiceProvider', + 37 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider', + 38 => 'Ichtrojan\\Otp\\OtpServiceProvider', + 39 => 'App\\Providers\\AppServiceProvider', + 40 => 'App\\Providers\\AuthServiceProvider', + 41 => 'App\\Providers\\EventServiceProvider', + 42 => 'App\\Providers\\RouteServiceProvider', + 43 => 'Laravel\\Socialite\\SocialiteServiceProvider', + 44 => 'SocialiteProviders\\Manager\\ServiceProvider', + 45 => 'Thedevsaddam\\LaravelSchema\\LaravelSchemaServiceProvider', + 46 => 'Sentry\\Laravel\\ServiceProvider', ), 'eager' => array ( @@ -60,22 +62,24 @@ 8 => 'Illuminate\\Session\\SessionServiceProvider', 9 => 'Illuminate\\View\\ViewServiceProvider', 10 => 'Hammerstone\\Sidecar\\Providers\\SidecarServiceProvider', - 11 => 'ipinfo\\ipinfolaravel\\ipinfolaravelServiceProvider', - 12 => 'Carbon\\Laravel\\ServiceProvider', - 13 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider', - 14 => 'Termwind\\Laravel\\TermwindServiceProvider', - 15 => 'PHPOpenSourceSaver\\JWTAuth\\Providers\\LaravelServiceProvider', - 16 => 'Sentry\\Laravel\\ServiceProvider', - 17 => 'Sentry\\Laravel\\Tracing\\ServiceProvider', - 18 => 'Spatie\\LaravelIgnition\\IgnitionServiceProvider', - 19 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider', - 20 => 'Ichtrojan\\Otp\\OtpServiceProvider', - 21 => 'App\\Providers\\AppServiceProvider', - 22 => 'App\\Providers\\AuthServiceProvider', - 23 => 'App\\Providers\\EventServiceProvider', - 24 => 'App\\Providers\\RouteServiceProvider', - 25 => 'Thedevsaddam\\LaravelSchema\\LaravelSchemaServiceProvider', - 26 => 'Sentry\\Laravel\\ServiceProvider', + 11 => 'Ichtrojan\\Otp\\OtpServiceProvider', + 12 => 'ipinfo\\ipinfolaravel\\ipinfolaravelServiceProvider', + 13 => 'Carbon\\Laravel\\ServiceProvider', + 14 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider', + 15 => 'Termwind\\Laravel\\TermwindServiceProvider', + 16 => 'PHPOpenSourceSaver\\JWTAuth\\Providers\\LaravelServiceProvider', + 17 => 'Sentry\\Laravel\\ServiceProvider', + 18 => 'Sentry\\Laravel\\Tracing\\ServiceProvider', + 19 => 'Spatie\\Health\\HealthServiceProvider', + 20 => 'Spatie\\LaravelIgnition\\IgnitionServiceProvider', + 21 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider', + 22 => 'Ichtrojan\\Otp\\OtpServiceProvider', + 23 => 'App\\Providers\\AppServiceProvider', + 24 => 'App\\Providers\\AuthServiceProvider', + 25 => 'App\\Providers\\EventServiceProvider', + 26 => 'App\\Providers\\RouteServiceProvider', + 27 => 'Thedevsaddam\\LaravelSchema\\LaravelSchemaServiceProvider', + 28 => 'Sentry\\Laravel\\ServiceProvider', ), 'deferred' => array ( @@ -183,6 +187,7 @@ 'Illuminate\\Foundation\\Console\\StubPublishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'Illuminate\\Foundation\\Console\\TestMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'Illuminate\\Foundation\\Console\\VendorPublishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'Illuminate\\Foundation\\Console\\ViewMakeCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'migrator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'migration.repository' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'migration.creator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', diff --git a/composer.json b/composer.json index ccc391d5..087b10b9 100755 --- a/composer.json +++ b/composer.json @@ -34,7 +34,9 @@ "spatie/laravel-ignition": "^2.1", "ichtrojan/laravel-otp": "^1.4", "symfony/mailgun-mailer": "^6.3", - "symfony/http-client": "^6.3" + "symfony/http-client": "^6.3", + "spatie/laravel-health": "^1.29", + "spatie/cpu-load-health-check": "^1.0" }, "require-dev": { "mockery/mockery": "^1.4.2", @@ -42,7 +44,8 @@ "ext-json": "*", "fakerphp/faker": "1.19.0", "laravel/sail": "^1.15", - "nunomaduro/larastan": "^2.0" + "nunomaduro/larastan": "^2.6", + "phpstan/phpstan": "^1.10" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 0e036149..16521bfa 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cbaa099e6b60953f3d5c207308352615", + "content-hash": "5ed8ec07dfccb4e0f2fc72c98dc2bfed", "packages": [ { "name": "aws/aws-crt-php", @@ -5921,6 +5921,147 @@ ], "time": "2023-06-28T12:59:17+00:00" }, + { + "name": "spatie/cpu-load-health-check", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/spatie/cpu-load-health-check.git", + "reference": "7653cd34540dba36d0052826c3aa4abdb7fa5435" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/cpu-load-health-check/zipball/7653cd34540dba36d0052826c3aa4abdb7fa5435", + "reference": "7653cd34540dba36d0052826c3aa4abdb7fa5435", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "nunomaduro/collision": "^5.10", + "pestphp/pest": "^1.21", + "pestphp/pest-plugin-laravel": "^1.1", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5", + "spatie/laravel-health": "^1.2", + "spatie/laravel-ray": "^1.26" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\CpuLoadHealthCheck\\": "src", + "Spatie\\CpuLoadHealthCheck\\Database\\Factories\\": "database/factories" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "A Laravel Health check to monitor CPU load", + "homepage": "https://github.com/spatie/cpu-load-health-check", + "keywords": [ + "cpu-load-health-check", + "laravel", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/cpu-load-health-check/issues", + "source": "https://github.com/spatie/cpu-load-health-check/tree/1.0.4" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2023-10-03T08:36:33+00:00" + }, + { + "name": "spatie/enum", + "version": "3.13.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/enum.git", + "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/enum/zipball/f1a0f464ba909491a53e60a955ce84ad7cd93a2c", + "reference": "f1a0f464ba909491a53e60a955ce84ad7cd93a2c", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^8.0" + }, + "require-dev": { + "fakerphp/faker": "^1.9.1", + "larapack/dd": "^1.1", + "phpunit/phpunit": "^9.0", + "vimeo/psalm": "^4.3" + }, + "suggest": { + "fakerphp/faker": "To use the enum faker provider", + "phpunit/phpunit": "To use the enum assertions" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Enum\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brent Roose", + "email": "brent@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + }, + { + "name": "Tom Witkowski", + "email": "dev@gummibeer.de", + "homepage": "https://gummibeer.de", + "role": "Developer" + } + ], + "description": "PHP Enums", + "homepage": "https://github.com/spatie/enum", + "keywords": [ + "enum", + "enumerable", + "spatie" + ], + "support": { + "docs": "https://docs.spatie.be/enum", + "issues": "https://github.com/spatie/enum/issues", + "source": "https://github.com/spatie/enum" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-04-22T08:51:55+00:00" + }, { "name": "spatie/flare-client-php", "version": "1.4.2", @@ -6074,6 +6215,99 @@ ], "time": "2023-09-19T15:29:52+00:00" }, + { + "name": "spatie/laravel-health", + "version": "1.29.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-health.git", + "reference": "daf8f00127a830ab38cbc7a08598a6e93aecd69c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-health/zipball/daf8f00127a830ab38cbc7a08598a6e93aecd69c", + "reference": "daf8f00127a830ab38cbc7a08598a6e93aecd69c", + "shasum": "" + }, + "require": { + "dragonmantank/cron-expression": "^3.3.1", + "guzzlehttp/guzzle": "^6.5|^7.4.5|^7.2", + "illuminate/console": "^8.75|^9.0|^10.0|^11.0", + "illuminate/contracts": "^8.75|^9.0|^10.0|^11.0", + "illuminate/database": "^8.75|^9.0|^10.0|^11.0", + "illuminate/notifications": "^8.75|^9.0|^10.0|^11.0", + "illuminate/support": "^8.75|^9.0|^10.0|^11.0", + "nunomaduro/termwind": "^1.0|^2.0", + "php": "^8.0", + "spatie/enum": "^3.13", + "spatie/laravel-package-tools": "^1.12.1", + "spatie/regex": "^3.1.1|^3.1", + "spatie/temporary-directory": "^2.2", + "symfony/process": "^5.4|^6.0|^7.0" + }, + "require-dev": { + "larastan/larastan": "^1.0.3|^2.4", + "laravel/horizon": "^5.9.10", + "laravel/slack-notification-channel": "^2.4|^3.2", + "nunomaduro/collision": "^5.10|^6.2.1|^6.1|^8.0", + "orchestra/testbench": "^6.23|^7.6|^8.0|^9.0", + "pestphp/pest": "^1.21.3|^2.34", + "pestphp/pest-plugin-laravel": "^1.2|^2.3", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.1.1", + "phpunit/phpunit": "^9.5.21|^9.5.10|^10.5", + "spatie/laravel-ray": "^1.30", + "spatie/pest-plugin-snapshots": "^1.1|^2.1", + "spatie/pest-plugin-test-time": "^1.1.1|^1.1|^2.0", + "spatie/test-time": "^1.3" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\Health\\HealthServiceProvider" + ], + "aliases": { + "Health": "Spatie\\Health\\Facades\\Health" + } + } + }, + "autoload": { + "psr-4": { + "Spatie\\Health\\": "src", + "Spatie\\Health\\Database\\Factories\\": "database/factories" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Monitor the health of a Laravel application", + "homepage": "https://github.com/spatie/laravel-health", + "keywords": [ + "laravel", + "laravel-health", + "spatie" + ], + "support": { + "source": "https://github.com/spatie/laravel-health/tree/1.29.0" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-05-02T10:06:22+00:00" + }, { "name": "spatie/laravel-ignition", "version": "2.3.0", @@ -6166,6 +6400,190 @@ ], "time": "2023-08-23T06:24:34+00:00" }, + { + "name": "spatie/laravel-package-tools", + "version": "1.16.4", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-package-tools.git", + "reference": "ddf678e78d7f8b17e5cdd99c0c3413a4a6592e53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/ddf678e78d7f8b17e5cdd99c0c3413a4a6592e53", + "reference": "ddf678e78d7f8b17e5cdd99c0c3413a4a6592e53", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^9.28|^10.0|^11.0", + "php": "^8.0" + }, + "require-dev": { + "mockery/mockery": "^1.5", + "orchestra/testbench": "^7.7|^8.0", + "pestphp/pest": "^1.22", + "phpunit/phpunit": "^9.5.24", + "spatie/pest-plugin-test-time": "^1.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\LaravelPackageTools\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Tools for creating Laravel packages", + "homepage": "https://github.com/spatie/laravel-package-tools", + "keywords": [ + "laravel-package-tools", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-package-tools/issues", + "source": "https://github.com/spatie/laravel-package-tools/tree/1.16.4" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-03-20T07:29:11+00:00" + }, + { + "name": "spatie/regex", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/regex.git", + "reference": "d543de2019a0068e7b80da0ba24f1c51c7469303" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/regex/zipball/d543de2019a0068e7b80da0ba24f1c51c7469303", + "reference": "d543de2019a0068e7b80da0ba24f1c51c7469303", + "shasum": "" + }, + "require": { + "php": "^8.0|^8.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Regex\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian De Deyne", + "email": "sebastian@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "A sane interface for php's built in preg_* functions", + "homepage": "https://github.com/spatie/regex", + "keywords": [ + "expression", + "expressions", + "regex", + "regular", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/regex/issues", + "source": "https://github.com/spatie/regex/tree/3.1.1" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2021-11-30T21:13:59+00:00" + }, + { + "name": "spatie/temporary-directory", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/temporary-directory.git", + "reference": "76949fa18f8e1a7f663fd2eaa1d00e0bcea0752a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/temporary-directory/zipball/76949fa18f8e1a7f663fd2eaa1d00e0bcea0752a", + "reference": "76949fa18f8e1a7f663fd2eaa1d00e0bcea0752a", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\TemporaryDirectory\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Vanderbist", + "email": "alex@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Easily create, use and destroy temporary directories", + "homepage": "https://github.com/spatie/temporary-directory", + "keywords": [ + "php", + "spatie", + "temporary-directory" + ], + "support": { + "issues": "https://github.com/spatie/temporary-directory/issues", + "source": "https://github.com/spatie/temporary-directory/tree/2.2.1" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2023-12-25T11:46:58+00:00" + }, { "name": "symfony/cache", "version": "v6.3.4", @@ -9860,12 +10278,12 @@ "version": "v2.6.4", "source": { "type": "git", - "url": "https://github.com/nunomaduro/larastan.git", + "url": "https://github.com/larastan/larastan.git", "reference": "6c5e8820f3db6397546f3ce48520af9d312aed27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/larastan/zipball/6c5e8820f3db6397546f3ce48520af9d312aed27", + "url": "https://api.github.com/repos/larastan/larastan/zipball/6c5e8820f3db6397546f3ce48520af9d312aed27", "reference": "6c5e8820f3db6397546f3ce48520af9d312aed27", "shasum": "" }, @@ -9928,8 +10346,8 @@ "static analysis" ], "support": { - "issues": "https://github.com/nunomaduro/larastan/issues", - "source": "https://github.com/nunomaduro/larastan/tree/v2.6.4" + "issues": "https://github.com/larastan/larastan/issues", + "source": "https://github.com/larastan/larastan/tree/v2.6.4" }, "funding": [ { @@ -9949,6 +10367,7 @@ "type": "patreon" } ], + "abandoned": "larastan/larastan", "time": "2023-07-29T12:13:13+00:00" }, { @@ -10151,16 +10570,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.35", + "version": "1.10.67", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3" + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e730e5facb75ffe09dfb229795e8c01a459f26c3", - "reference": "e730e5facb75ffe09dfb229795e8c01a459f26c3", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", "shasum": "" }, "require": { @@ -10203,13 +10622,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2023-09-19T15:27:56+00:00" + "time": "2024-04-16T07:22:02+00:00" }, { "name": "phpunit/php-code-coverage", @@ -11686,5 +12101,5 @@ "platform-dev": { "ext-json": "*" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/config/app.php b/config/app.php index 4e37d085..25f4369f 100755 --- a/config/app.php +++ b/config/app.php @@ -234,5 +234,4 @@ 'Socialite' => Laravel\Socialite\Facades\Socialite::class, 'Otp' => Ichtrojan\Otp\Otp::class, ], - ]; diff --git a/config/database.php b/config/database.php index 5b95adc2..6a56a101 100755 --- a/config/database.php +++ b/config/database.php @@ -46,51 +46,20 @@ ], 'mysql' => [ + 'read' => [ + 'host' => env('DB_HOST'), + ], + 'write' => [ + 'host' => env('DB_HOST'), + ], + 'sticky' => true, 'driver' => 'mysql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), - 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'prefix_indexes' => true, - 'strict' => true, - 'engine' => null, - 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), - ]) : [], - ], - - 'pgsql' => [ - 'driver' => 'pgsql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '5432'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'prefix_indexes' => true, - 'schema' => 'public', - 'sslmode' => 'prefer', - ], - - 'sqlsrv' => [ - 'driver' => 'sqlsrv', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', 'localhost'), - 'port' => env('DB_PORT', '1433'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'prefix_indexes' => true, + 'prefix' => '' ], ], diff --git a/config/tiktok.php b/config/tiktok.php new file mode 100644 index 00000000..0b67a5fe --- /dev/null +++ b/config/tiktok.php @@ -0,0 +1,3 @@ + 'v1'], function () { - Route::get('/ping', function () { - return 'Cookbooks api v1'; - }); + Route::get('/ping', [HealthCheckController::class, 'check']); Route::get('/callback/tiktok', [ 'uses' => 'AuthController@tikTokHandleCallback', @@ -26,7 +25,7 @@ Route::get('/webhooks/tiktok', function() { return response()->json([ - 'message' => 'payload recieved with thanks' + 'message' => 'payload received with thanks' ]); });