From a5ea445c973cfb5fa6663243ad82d4d93b330968 Mon Sep 17 00:00:00 2001 From: aa-florence Date: Wed, 19 Jun 2024 22:55:34 -0400 Subject: [PATCH 1/6] health-check changes --- app/Dtos/Contracts/isReadOnly.php | 8 + app/Dtos/HealthChecksDto.php | 34 ++ app/Dtos/TikTokUserDto.php | 4 +- .../Controllers/HealthCheckController.php | 115 +++++ composer.json | 4 +- composer.lock | 420 +++++++++++++++++- config/app.php | 1 - routes/api.php | 7 +- 8 files changed, 585 insertions(+), 8 deletions(-) create mode 100644 app/Dtos/Contracts/isReadOnly.php create mode 100644 app/Dtos/HealthChecksDto.php create mode 100644 app/Http/Controllers/HealthCheckController.php 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/HealthCheckController.php b/app/Http/Controllers/HealthCheckController.php new file mode 100644 index 00000000..91ff82c5 --- /dev/null +++ b/app/Http/Controllers/HealthCheckController.php @@ -0,0 +1,115 @@ +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(array_merge( + [ + EnvironmentCheck::new()->expectEnvironment(getenv('APP_ENV')), + UsedDiskSpaceCheck::new() + ->warnWhenUsedSpaceIsAbovePercentage(70) + ->failWhenUsedSpaceIsAbovePercentage(90), + CpuLoadCheck::new() + ->failWhenLoadIsHigherInTheLast5Minutes(2.0) + ->failWhenLoadIsHigherInTheLast15Minutes(1.5), + ], + $this->registerGetPingChecks(), + $this->registerPostPingChecks(), + [ + DatabaseCheck::new()->connectionName(getenv('DB_CONNECTION')), + CacheCheck::new()->driver('redis'), + ] + )); + } + + private function registerGetPingChecks(): array + { + $getEndpoints = [ + '/api/v1/users', + '/api/v1/cookbooks', + '/api/v1/recipes', + '/api/v1/policies', + '/api/v1/stats', + '/api/v1/categories', + ]; + + return $this->registerPingCheck($getEndpoints, 'GET'); + } + + private function registerPostPingChecks(): array + { + $postEndpoints = []; + + return $this->registerPingCheck($postEndpoints, 'POST'); + } + + private function registerPingCheck(array $urls, string $method): array + { + return array_map(function($url) use($method) { + $basePath = getenv('APP_URL'); + return PingCheck::new() + ->url($basePath . $url) + ->name($url) + ->method($method); + }, $urls); + } + + /** + * @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/composer.json b/composer.json index ccc391d5..9e166848 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", diff --git a/composer.lock b/composer.lock index 0e036149..ee6ead95 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": "a4e9787c1a523737182bf491d5ae6ee1", "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", 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/routes/api.php b/routes/api.php index 5d819123..a2dee7ca 100755 --- a/routes/api.php +++ b/routes/api.php @@ -12,12 +12,11 @@ use App\Http\Controllers\UserController; use App\Models\Flag; use Illuminate\Support\Facades\Route; +use App\Http\Controllers\HealthCheckController; Route::group(['prefix' => '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' ]); }); From 757df2355a057368aba5ce10e1e1281a9c172e53 Mon Sep 17 00:00:00 2001 From: aa-florence Date: Thu, 20 Jun 2024 00:38:10 -0400 Subject: [PATCH 2/6] fix db connection --- Dockerfile | 4 --- config/database.php | 74 +++++---------------------------------------- docker-compose.yml | 8 +++-- 3 files changed, 13 insertions(+), 73 deletions(-) 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/config/database.php b/config/database.php index 5b95adc2..dedaf133 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' => '' ], ], @@ -119,31 +88,4 @@ | */ - 'redis' => [ - - 'client' => env('REDIS_CLIENT', 'phpredis'), - - 'options' => [ - 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), - ], - - 'default' => [ - 'url' => env('REDIS_URL'), - 'host' => env('REDIS_HOST', '127.0.0.1'), - 'password' => env('REDIS_PASSWORD', null), - 'port' => env('REDIS_PORT', '6379'), - 'database' => env('REDIS_DB', '0'), - ], - - 'cache' => [ - 'url' => env('REDIS_URL'), - 'host' => env('REDIS_HOST', '127.0.0.1'), - 'password' => env('REDIS_PASSWORD', null), - 'port' => env('REDIS_PORT', '6379'), - 'database' => env('REDIS_CACHE_DB', '1'), - ], - - ], - ]; diff --git a/docker-compose.yml b/docker-compose.yml index b27d60d0..db8a2310 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,14 +13,16 @@ services: PHP_IDE_CONFIG: "serverName=localhost" XDEBUG_CONFIG: "idekey=PHPSTORM" db: - image: mysql:latest + image: mariadb:latest container_name: db environment: MYSQL_DATABASE: test_db MYSQL_PASSWORD: pass MYSQL_ROOT_PASSWORD: pass volumes: - - cookbooks-db:/var/lib/mysql + - mysqldata:/var/lib/mysql + ports: + - 3306:3306 networks: - cookbooks nginx: @@ -36,7 +38,7 @@ services: - cookbooks volumes: - cookbooks-db: + mysqldata: networks: cookbooks: From bca8abecf3a61d07dee407d1f44ceb680bf306f1 Mon Sep 17 00:00:00 2001 From: aa-florence Date: Thu, 20 Jun 2024 09:31:58 -0400 Subject: [PATCH 3/6] updating configs --- Makefile | 22 +- .../Controllers/HealthCheckController.php | 46 +- bootstrap/cache/config.php | 932 ++++++++++++++++++ bootstrap/cache/packages.php | 22 + bootstrap/cache/services.php | 81 +- config/database.php | 27 + docker-compose.yml | 30 +- 7 files changed, 1057 insertions(+), 103 deletions(-) create mode 100644 bootstrap/cache/config.php diff --git a/Makefile b/Makefile index a76c8efa..e4ab655a 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,16 +73,16 @@ 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 diff --git a/app/Http/Controllers/HealthCheckController.php b/app/Http/Controllers/HealthCheckController.php index 91ff82c5..94770a0d 100644 --- a/app/Http/Controllers/HealthCheckController.php +++ b/app/Http/Controllers/HealthCheckController.php @@ -8,10 +8,8 @@ use Spatie\Health\Checks\Checks\UsedDiskSpaceCheck; use Spatie\Health\Checks\Result; use Spatie\Health\Health; -use Spatie\Health\Checks\Checks\PingCheck; use Spatie\Health\Checks\Checks\DatabaseCheck; use Spatie\Health\Checks\Checks\EnvironmentCheck; -use Spatie\Health\Checks\Checks\CacheCheck; class HealthCheckController extends Controller { @@ -46,7 +44,7 @@ public function check(): JsonResponse */ private function registerChecks(): void { - $this->healthChecker->checks(array_merge( + $this->healthChecker->checks( [ EnvironmentCheck::new()->expectEnvironment(getenv('APP_ENV')), UsedDiskSpaceCheck::new() @@ -55,46 +53,10 @@ private function registerChecks(): void CpuLoadCheck::new() ->failWhenLoadIsHigherInTheLast5Minutes(2.0) ->failWhenLoadIsHigherInTheLast15Minutes(1.5), - ], - $this->registerGetPingChecks(), - $this->registerPostPingChecks(), - [ - DatabaseCheck::new()->connectionName(getenv('DB_CONNECTION')), - CacheCheck::new()->driver('redis'), + DatabaseCheck::new() + ->connectionName(getenv('DB_CONNECTION')) ] - )); - } - - private function registerGetPingChecks(): array - { - $getEndpoints = [ - '/api/v1/users', - '/api/v1/cookbooks', - '/api/v1/recipes', - '/api/v1/policies', - '/api/v1/stats', - '/api/v1/categories', - ]; - - return $this->registerPingCheck($getEndpoints, 'GET'); - } - - private function registerPostPingChecks(): array - { - $postEndpoints = []; - - return $this->registerPingCheck($postEndpoints, 'POST'); - } - - private function registerPingCheck(array $urls, string $method): array - { - return array_map(function($url) use($method) { - $basePath = getenv('APP_URL'); - return PingCheck::new() - ->url($basePath . $url) - ->name($url) - ->method($method); - }, $urls); + ); } /** diff --git a/bootstrap/cache/config.php b/bootstrap/cache/config.php new file mode 100644 index 00000000..332b77cb --- /dev/null +++ b/bootstrap/cache/config.php @@ -0,0 +1,932 @@ + + array ( + 'name' => 'Laravel', + 'env' => 'local', + 'debug' => true, + 'url' => 'http://localhost:8080', + 'asset_url' => NULL, + 'timezone' => 'UTC', + 'locale' => 'en', + 'fallback_locale' => 'en', + 'faker_locale' => 'en_US', + 'key' => 'base64:AUpD1xmzmeyWy8yxwLZ0mOwhznvs3qAFnblqcjHPKVY=', + 'cipher' => 'AES-256-CBC', + 'providers' => + array ( + 0 => 'Illuminate\\Auth\\AuthServiceProvider', + 1 => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', + 2 => 'Illuminate\\Bus\\BusServiceProvider', + 3 => 'Illuminate\\Cache\\CacheServiceProvider', + 4 => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 5 => 'Illuminate\\Cookie\\CookieServiceProvider', + 6 => 'Illuminate\\Database\\DatabaseServiceProvider', + 7 => 'Illuminate\\Encryption\\EncryptionServiceProvider', + 8 => 'Illuminate\\Filesystem\\FilesystemServiceProvider', + 9 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider', + 10 => 'Illuminate\\Hashing\\HashServiceProvider', + 11 => 'Illuminate\\Mail\\MailServiceProvider', + 12 => 'Illuminate\\Notifications\\NotificationServiceProvider', + 13 => 'Illuminate\\Pagination\\PaginationServiceProvider', + 14 => 'Illuminate\\Pipeline\\PipelineServiceProvider', + 15 => 'Illuminate\\Queue\\QueueServiceProvider', + 16 => 'Illuminate\\Redis\\RedisServiceProvider', + 17 => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider', + 18 => 'Illuminate\\Session\\SessionServiceProvider', + 19 => 'Illuminate\\Translation\\TranslationServiceProvider', + 20 => 'Illuminate\\Validation\\ValidationServiceProvider', + 21 => 'Illuminate\\View\\ViewServiceProvider', + 22 => 'Ichtrojan\\Otp\\OtpServiceProvider', + 23 => 'App\\Providers\\AppServiceProvider', + 24 => 'App\\Providers\\AuthServiceProvider', + 25 => 'App\\Providers\\EventServiceProvider', + 26 => 'App\\Providers\\RouteServiceProvider', + 27 => 'Laravel\\Socialite\\SocialiteServiceProvider', + 28 => 'SocialiteProviders\\Manager\\ServiceProvider', + 29 => 'Thedevsaddam\\LaravelSchema\\LaravelSchemaServiceProvider', + 30 => 'Sentry\\Laravel\\ServiceProvider', + ), + 'aliases' => + array ( + 'App' => 'Illuminate\\Support\\Facades\\App', + 'Arr' => 'Illuminate\\Support\\Arr', + 'Artisan' => 'Illuminate\\Support\\Facades\\Artisan', + 'Auth' => 'Illuminate\\Support\\Facades\\Auth', + 'Blade' => 'Illuminate\\Support\\Facades\\Blade', + 'Broadcast' => 'Illuminate\\Support\\Facades\\Broadcast', + 'Bus' => 'Illuminate\\Support\\Facades\\Bus', + 'Cache' => 'Illuminate\\Support\\Facades\\Cache', + 'Config' => 'Illuminate\\Support\\Facades\\Config', + 'Cookie' => 'Illuminate\\Support\\Facades\\Cookie', + 'Crypt' => 'Illuminate\\Support\\Facades\\Crypt', + 'DB' => 'Illuminate\\Support\\Facades\\DB', + 'Eloquent' => 'Illuminate\\Database\\Eloquent\\Model', + 'Event' => 'Illuminate\\Support\\Facades\\Event', + 'File' => 'Illuminate\\Support\\Facades\\File', + 'Gate' => 'Illuminate\\Support\\Facades\\Gate', + 'Hash' => 'Illuminate\\Support\\Facades\\Hash', + 'Http' => 'Illuminate\\Support\\Facades\\Http', + 'Lang' => 'Illuminate\\Support\\Facades\\Lang', + 'Log' => 'Illuminate\\Support\\Facades\\Log', + 'Mail' => 'Illuminate\\Support\\Facades\\Mail', + 'Notification' => 'Illuminate\\Support\\Facades\\Notification', + 'Password' => 'Illuminate\\Support\\Facades\\Password', + 'Queue' => 'Illuminate\\Support\\Facades\\Queue', + 'Redirect' => 'Illuminate\\Support\\Facades\\Redirect', + 'Redis' => 'Illuminate\\Support\\Facades\\Redis', + 'Request' => 'Illuminate\\Support\\Facades\\Request', + 'Response' => 'Illuminate\\Support\\Facades\\Response', + 'Route' => 'Illuminate\\Support\\Facades\\Route', + 'Schema' => 'Illuminate\\Support\\Facades\\Schema', + 'Session' => 'Illuminate\\Support\\Facades\\Session', + 'Storage' => 'Illuminate\\Support\\Facades\\Storage', + 'Str' => 'Illuminate\\Support\\Str', + 'URL' => 'Illuminate\\Support\\Facades\\URL', + 'Validator' => 'Illuminate\\Support\\Facades\\Validator', + 'View' => 'Illuminate\\Support\\Facades\\View', + 'Socialite' => 'Laravel\\Socialite\\Facades\\Socialite', + 'Otp' => 'Ichtrojan\\Otp\\Otp', + ), + ), + 'auth' => + array ( + 'defaults' => + array ( + 'guard' => 'api', + 'passwords' => 'users', + ), + 'guards' => + array ( + 'web' => + array ( + 'driver' => 'session', + 'provider' => 'users', + ), + 'api' => + array ( + 'driver' => 'jwt', + 'provider' => 'users', + 'hash' => false, + ), + ), + 'providers' => + array ( + 'users' => + array ( + 'driver' => 'eloquent', + 'model' => 'App\\Models\\User', + ), + ), + 'passwords' => + array ( + 'users' => + array ( + 'provider' => 'users', + 'table' => 'password_resets', + 'expire' => 60, + 'throttle' => 60, + ), + ), + 'password_timeout' => 10800, + ), + 'broadcasting' => + array ( + 'default' => 'null', + 'connections' => + array ( + 'pusher' => + array ( + 'driver' => 'pusher', + 'key' => NULL, + 'secret' => NULL, + 'app_id' => NULL, + 'options' => + array ( + 'cluster' => NULL, + 'useTLS' => true, + ), + ), + 'redis' => + array ( + 'driver' => 'redis', + 'connection' => 'default', + ), + 'log' => + array ( + 'driver' => 'log', + ), + 'null' => + array ( + 'driver' => 'null', + ), + ), + ), + 'cache' => + array ( + 'default' => 'file', + 'stores' => + array ( + 'apc' => + array ( + 'driver' => 'apc', + ), + 'array' => + array ( + 'driver' => 'array', + 'serialize' => false, + ), + 'database' => + array ( + 'driver' => 'database', + 'table' => 'cache', + 'connection' => NULL, + ), + 'file' => + array ( + 'driver' => 'file', + 'path' => '/var/www/storage/framework/cache/data', + ), + 'memcached' => + array ( + 'driver' => 'memcached', + 'persistent_id' => NULL, + 'sasl' => + array ( + 0 => NULL, + 1 => NULL, + ), + 'options' => + array ( + ), + 'servers' => + array ( + 0 => + array ( + 'host' => '127.0.0.1', + 'port' => 11211, + 'weight' => 100, + ), + ), + ), + 'redis' => + array ( + 'driver' => 'redis', + 'connection' => 'cache', + ), + 'dynamodb' => + array ( + 'driver' => 'dynamodb', + 'key' => NULL, + 'secret' => NULL, + 'region' => 'us-east-1', + 'table' => 'cache', + 'endpoint' => NULL, + ), + ), + 'prefix' => 'laravel_cache', + ), + 'cors' => + array ( + 'paths' => + array ( + 0 => 'api/*', + ), + 'allowed_methods' => + array ( + 0 => '*', + ), + 'allowed_origins' => + array ( + 0 => '*', + ), + 'allowed_origins_patterns' => + array ( + ), + 'allowed_headers' => + array ( + 0 => '*', + ), + 'exposed_headers' => + array ( + ), + 'max_age' => 0, + 'supports_credentials' => false, + ), + 'database' => + array ( + 'default' => 'mysql', + 'connections' => + array ( + 'sqlite' => + array ( + 'driver' => 'sqlite', + 'url' => NULL, + 'database' => 'test_db', + 'prefix' => '', + 'foreign_key_constraints' => true, + ), + 'mysql' => + array ( + 'read' => + array ( + 'host' => 'db', + ), + 'write' => + array ( + 'host' => 'db', + ), + 'sticky' => true, + 'driver' => 'mysql', + 'database' => 'test_db', + 'username' => 'root', + 'password' => 'pass', + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + ), + ), + 'migrations' => 'migrations', + ), + 'docs' => + array ( + 'api' => + array ( + 'users' => + array ( + 'register' => + array ( + 'method' => 'POST', + 'endpoint' => 'api/v1/auth/register', + ), + 'login' => + array ( + 'method' => 'POST', + 'endpoint' => 'api/v1/auth/login', + ), + ), + 'cookbooks' => + array ( + 'routes' => + array ( + 'view_all' => + array ( + 'GET' => 'api/v1/cookbooks', + ), + 'get_one' => + array ( + 'GET' => 'api/v1/cookbooks/:id', + ), + 'create_one' => + array ( + 'POST' => 'api/v1/cookbooks', + ), + 'partial_update_one' => + array ( + 'PATCH' => 'api/v1/cookbooks/:id', + ), + 'full_update_one' => + array ( + 'PUT' => 'api/v1/cookbooks/:id', + ), + ), + ), + ), + ), + 'filesystems' => + array ( + 'default' => 'local', + 'cloud' => 's3', + 'disks' => + array ( + 'local' => + array ( + 'driver' => 'local', + 'root' => '/var/www/storage/app', + ), + 'public' => + array ( + 'driver' => 'local', + 'root' => '/var/www/storage/app/public', + 'url' => 'http://localhost:8080/storage', + 'visibility' => 'public', + ), + 's3' => + array ( + 'driver' => 's3', + 'key' => NULL, + 'secret' => NULL, + 'region' => NULL, + 'bucket' => NULL, + 'url' => NULL, + 'endpoint' => NULL, + ), + ), + 'links' => + array ( + '/var/www/public/storage' => '/var/www/storage/app/public', + ), + ), + 'hashing' => + array ( + 'driver' => 'bcrypt', + 'bcrypt' => + array ( + 'rounds' => 10, + ), + 'argon' => + array ( + 'memory' => 1024, + 'threads' => 2, + 'time' => 2, + ), + ), + 'jwt' => + array ( + 'secret' => 'wHEYhImKUXCXhwWwRsxt6RGoIl1GQPP2bVyyfPGZQkGNNt60CfG27kBqmWYh5vco', + 'keys' => + array ( + 'public' => NULL, + 'private' => NULL, + 'passphrase' => NULL, + ), + 'ttl' => 1440, + 'refresh_ttl' => 20160, + 'algo' => 'HS256', + 'required_claims' => + array ( + 0 => 'iss', + 1 => 'iat', + 2 => 'exp', + 3 => 'nbf', + 4 => 'sub', + 5 => 'jti', + ), + 'persistent_claims' => + array ( + ), + 'lock_subject' => true, + 'leeway' => 0, + 'blacklist_enabled' => true, + 'blacklist_grace_period' => 0, + 'decrypt_cookies' => false, + 'providers' => + array ( + 'jwt' => 'Tymon\\JWTAuth\\Providers\\JWT\\Lcobucci', + 'auth' => 'Tymon\\JWTAuth\\Providers\\Auth\\Illuminate', + 'storage' => 'Tymon\\JWTAuth\\Providers\\Storage\\Illuminate', + ), + 'show_black_list_exception' => true, + ), + 'logging' => + array ( + 'default' => 'sentry', + 'channels' => + array ( + 'stack' => + array ( + 'driver' => 'stack', + 'channels' => + array ( + 0 => 'single', + ), + 'ignore_exceptions' => false, + ), + 'single' => + array ( + 'driver' => 'single', + 'path' => '/var/www/storage/logs/laravel.log', + 'level' => 'debug', + ), + 'daily' => + array ( + 'driver' => 'daily', + 'path' => '/var/www/storage/logs/laravel.log', + 'level' => 'debug', + 'days' => 14, + ), + 'slack' => + array ( + 'driver' => 'slack', + 'url' => NULL, + 'username' => 'Laravel Log', + 'emoji' => ':boom:', + 'level' => 'critical', + ), + 'papertrail' => + array ( + 'driver' => 'monolog', + 'level' => 'debug', + 'handler' => 'Monolog\\Handler\\SyslogUdpHandler', + 'handler_with' => + array ( + 'host' => NULL, + 'port' => NULL, + ), + ), + 'stderr' => + array ( + 'driver' => 'monolog', + 'handler' => 'Monolog\\Handler\\StreamHandler', + 'formatter' => NULL, + 'with' => + array ( + 'stream' => 'php://stderr', + ), + ), + 'syslog' => + array ( + 'driver' => 'syslog', + 'level' => 'debug', + ), + 'errorlog' => + array ( + 'driver' => 'errorlog', + 'level' => 'debug', + ), + 'null' => + array ( + 'driver' => 'monolog', + 'handler' => 'Monolog\\Handler\\NullHandler', + ), + 'emergency' => + array ( + 'path' => '/var/www/storage/logs/laravel.log', + ), + 'sentry' => + array ( + 'driver' => 'sentry', + 'channels' => + array ( + 0 => 'single', + 1 => 'sentry', + ), + ), + ), + ), + 'mail' => + array ( + 'default' => 'smtp', + 'mailers' => + array ( + 'smtp' => + array ( + 'transport' => 'smtp', + 'host' => '', + 'port' => '', + 'encryption' => '', + 'username' => '', + 'password' => '', + 'timeout' => NULL, + 'auth_mode' => NULL, + ), + 'ses' => + array ( + 'transport' => 'ses', + ), + 'mailgun' => + array ( + 'transport' => 'mailgun', + ), + 'postmark' => + array ( + 'transport' => 'postmark', + ), + 'sendmail' => + array ( + 'transport' => 'sendmail', + 'path' => '/usr/sbin/sendmail -bs', + ), + 'log' => + array ( + 'transport' => 'log', + 'channel' => NULL, + ), + 'array' => + array ( + 'transport' => 'array', + ), + ), + 'from' => + array ( + 'address' => '', + 'name' => '', + ), + 'markdown' => + array ( + 'theme' => 'default', + 'paths' => + array ( + 0 => '/var/www/resources/views/vendor/mail', + ), + ), + ), + 'queue' => + array ( + 'default' => 'database', + 'connections' => + array ( + 'sync' => + array ( + 'driver' => 'sync', + ), + 'database' => + array ( + 'driver' => 'database', + 'table' => 'jobs', + 'queue' => 'default', + 'retry_after' => 90, + ), + 'beanstalkd' => + array ( + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, + 'block_for' => 0, + ), + 'sqs' => + array ( + 'driver' => 'sqs', + 'key' => NULL, + 'secret' => NULL, + 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', + 'queue' => 'your-queue-name', + 'suffix' => NULL, + 'region' => 'us-east-1', + ), + 'redis' => + array ( + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => 'default', + 'retry_after' => 90, + 'block_for' => NULL, + ), + ), + 'failed' => + array ( + 'driver' => 'database', + 'database' => 'mysql', + 'table' => 'failed_jobs', + ), + ), + 'sentry' => + array ( + 'dsn' => '', + 'release' => NULL, + 'environment' => NULL, + 'sample_rate' => 1.0, + 'traces_sample_rate' => NULL, + 'profiles_sample_rate' => NULL, + 'send_default_pii' => false, + 'breadcrumbs' => + array ( + 'logs' => true, + 'cache' => true, + 'livewire' => true, + 'sql_queries' => true, + 'sql_bindings' => false, + 'queue_info' => true, + 'command_info' => true, + 'http_client_requests' => true, + ), + 'tracing' => + array ( + 'queue_job_transactions' => false, + 'queue_jobs' => true, + 'sql_queries' => true, + 'sql_origin' => true, + 'views' => true, + 'livewire' => true, + 'http_client_requests' => true, + 'redis_commands' => false, + 'redis_origin' => true, + 'missing_routes' => false, + 'continue_after_response' => true, + 'default_integrations' => true, + ), + ), + 'services' => + array ( + 'mailgun' => + array ( + 'domain' => '', + 'secret' => '', + 'endpoint' => 'api.mailgun.net', + ), + 'postmark' => + array ( + 'token' => NULL, + ), + 'ses' => + array ( + 'key' => NULL, + 'secret' => NULL, + 'region' => 'us-east-1', + ), + 'tiktok' => + array ( + 'client_id' => '', + 'client_secret' => '', + 'redirect' => '', + 'users' => + array ( + 'secret_pass' => 'fakePass', + ), + 'v1_host' => 'https://open-api.tiktok.com', + 'v2_host' => 'https://open.tiktokapis.com/v2', + ), + 'ipinfo' => + array ( + 'access_token' => '', + ), + 'faker' => + array ( + 'pass' => NULL, + ), + 'otp' => + array ( + 'digits' => 6, + 'validity' => 15, + ), + 'redirects' => + array ( + 'tiktok' => + array ( + 'web-client-vue2' => 'https://web.cookbookshq.com/tiktok/?', + 'beta-version-1-staging' => '/tiktok?', + ), + 'errors' => + array ( + 'web-client-vue2' => 'https://web.cookbookshq.com/errors/?', + 'beta-version-1-staging' => '/errors?', + ), + ), + ), + 'session' => + array ( + 'driver' => 'file', + 'lifetime' => 120, + 'expire_on_close' => false, + 'encrypt' => false, + 'files' => '/var/www/storage/framework/sessions', + 'connection' => NULL, + 'table' => 'sessions', + 'store' => NULL, + 'lottery' => + array ( + 0 => 2, + 1 => 100, + ), + 'cookie' => 'laravel_session', + 'path' => '/', + 'domain' => '', + 'secure' => false, + 'http_only' => true, + 'same_site' => 'lax', + ), + 'tinker' => + array ( + 'commands' => + array ( + ), + 'alias' => + array ( + ), + 'dont_alias' => + array ( + 0 => 'App\\Nova', + ), + ), + 'view' => + array ( + 'paths' => + array ( + 0 => '/var/www/resources/views', + ), + 'compiled' => '/var/www/storage/framework/views', + ), + 'sidecar' => + array ( + 'functions' => + array ( + ), + 'app_name' => NULL, + 'env' => 'local', + 'timeout' => 300, + 'memory' => 512, + 'storage' => 512, + 'architecture' => 'x86_64', + 'package_base_path' => '/var/www', + 'aws_key' => NULL, + 'aws_secret' => NULL, + 'aws_region' => NULL, + 'aws_bucket' => NULL, + 'execution_role' => NULL, + 'lambda_prefix' => 'SC', + ), + 'ipinfolaravel' => + array ( + ), + 'health' => + array ( + 'result_stores' => + array ( + 'Spatie\\Health\\ResultStores\\EloquentHealthResultStore' => + array ( + 'connection' => 'mysql', + 'model' => 'Spatie\\Health\\Models\\HealthCheckResultHistoryItem', + 'keep_history_for_days' => 5, + ), + ), + 'notifications' => + array ( + 'enabled' => true, + 'notifications' => + array ( + 'Spatie\\Health\\Notifications\\CheckFailedNotification' => + array ( + 0 => 'mail', + ), + ), + 'notifiable' => 'Spatie\\Health\\Notifications\\Notifiable', + 'throttle_notifications_for_minutes' => 60, + 'throttle_notifications_key' => 'health:latestNotificationSentAt:', + 'mail' => + array ( + 'to' => 'your@example.com', + 'from' => + array ( + 'address' => '', + 'name' => '', + ), + ), + 'slack' => + array ( + 'webhook_url' => '', + 'channel' => NULL, + 'username' => NULL, + 'icon' => NULL, + ), + ), + 'oh_dear_endpoint' => + array ( + 'enabled' => false, + 'always_send_fresh_results' => true, + 'secret' => NULL, + 'url' => '/oh-dear-health-check-results', + ), + 'theme' => 'light', + 'silence_health_queue_job' => true, + ), + 'flare' => + array ( + 'key' => NULL, + 'flare_middleware' => + array ( + 0 => 'Spatie\\FlareClient\\FlareMiddleware\\RemoveRequestIp', + 1 => 'Spatie\\FlareClient\\FlareMiddleware\\AddGitInformation', + 2 => 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddNotifierName', + 3 => 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddEnvironmentInformation', + 4 => 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddExceptionInformation', + 5 => 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddDumps', + 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddLogs' => + array ( + 'maximum_number_of_collected_logs' => 200, + ), + 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddQueries' => + array ( + 'maximum_number_of_collected_queries' => 200, + 'report_query_bindings' => true, + ), + 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddJobs' => + array ( + 'max_chained_job_reporting_depth' => 5, + ), + 'Spatie\\FlareClient\\FlareMiddleware\\CensorRequestBodyFields' => + array ( + 'censor_fields' => + array ( + 0 => 'password', + 1 => 'password_confirmation', + ), + ), + 'Spatie\\FlareClient\\FlareMiddleware\\CensorRequestHeaders' => + array ( + 'headers' => + array ( + 0 => 'API-KEY', + ), + ), + ), + 'send_logs_as_events' => true, + ), + 'ignition' => + array ( + 'editor' => 'phpstorm', + 'theme' => 'auto', + 'enable_share_button' => true, + 'register_commands' => false, + 'solution_providers' => + array ( + 0 => 'Spatie\\Ignition\\Solutions\\SolutionProviders\\BadMethodCallSolutionProvider', + 1 => 'Spatie\\Ignition\\Solutions\\SolutionProviders\\MergeConflictSolutionProvider', + 2 => 'Spatie\\Ignition\\Solutions\\SolutionProviders\\UndefinedPropertySolutionProvider', + 3 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\IncorrectValetDbCredentialsSolutionProvider', + 4 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingAppKeySolutionProvider', + 5 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\DefaultDbNameSolutionProvider', + 6 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\TableNotFoundSolutionProvider', + 7 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingImportSolutionProvider', + 8 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\InvalidRouteActionSolutionProvider', + 9 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\ViewNotFoundSolutionProvider', + 10 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\RunningLaravelDuskInProductionProvider', + 11 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingColumnSolutionProvider', + 12 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\UnknownValidationSolutionProvider', + 13 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingMixManifestSolutionProvider', + 14 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingViteManifestSolutionProvider', + 15 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingLivewireComponentSolutionProvider', + 16 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\UndefinedViewVariableSolutionProvider', + 17 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\GenericLaravelExceptionSolutionProvider', + 18 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\OpenAiSolutionProvider', + 19 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\SailNetworkSolutionProvider', + ), + 'ignored_solution_providers' => + array ( + ), + 'enable_runnable_solutions' => NULL, + 'remote_sites_path' => '/var/www', + 'local_sites_path' => '', + 'housekeeping_endpoint_prefix' => '_ignition', + 'settings_file_path' => '', + 'recorders' => + array ( + 0 => 'Spatie\\LaravelIgnition\\Recorders\\DumpRecorder\\DumpRecorder', + 1 => 'Spatie\\LaravelIgnition\\Recorders\\JobRecorder\\JobRecorder', + 2 => 'Spatie\\LaravelIgnition\\Recorders\\LogRecorder\\LogRecorder', + 3 => 'Spatie\\LaravelIgnition\\Recorders\\QueryRecorder\\QueryRecorder', + ), + 'open_ai_key' => NULL, + 'with_stack_frame_arguments' => true, + 'argument_reducers' => + array ( + 0 => 'Spatie\\Backtrace\\Arguments\\Reducers\\BaseTypeArgumentReducer', + 1 => 'Spatie\\Backtrace\\Arguments\\Reducers\\ArrayArgumentReducer', + 2 => 'Spatie\\Backtrace\\Arguments\\Reducers\\StdClassArgumentReducer', + 3 => 'Spatie\\Backtrace\\Arguments\\Reducers\\EnumArgumentReducer', + 4 => 'Spatie\\Backtrace\\Arguments\\Reducers\\ClosureArgumentReducer', + 5 => 'Spatie\\Backtrace\\Arguments\\Reducers\\DateTimeArgumentReducer', + 6 => 'Spatie\\Backtrace\\Arguments\\Reducers\\DateTimeZoneArgumentReducer', + 7 => 'Spatie\\Backtrace\\Arguments\\Reducers\\SymphonyRequestArgumentReducer', + 8 => 'Spatie\\LaravelIgnition\\ArgumentReducers\\ModelArgumentReducer', + 9 => 'Spatie\\LaravelIgnition\\ArgumentReducers\\CollectionArgumentReducer', + 10 => 'Spatie\\Backtrace\\Arguments\\Reducers\\StringableArgumentReducer', + ), + ), + 'horizon' => + array ( + 'silenced' => + array ( + 0 => 'Spatie\\Health\\Jobs\\HealthQueueJob', + ), + ), +); 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/config/database.php b/config/database.php index dedaf133..6a56a101 100755 --- a/config/database.php +++ b/config/database.php @@ -88,4 +88,31 @@ | */ + 'redis' => [ + + 'client' => env('REDIS_CLIENT', 'phpredis'), + + 'options' => [ + 'cluster' => env('REDIS_CLUSTER', 'redis'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), + ], + + 'default' => [ + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', '6379'), + 'database' => env('REDIS_DB', '0'), + ], + + 'cache' => [ + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', '6379'), + 'database' => env('REDIS_CACHE_DB', '1'), + ], + + ], + ]; diff --git a/docker-compose.yml b/docker-compose.yml index db8a2310..a747dac8 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,16 @@ version: "3.7" services: + nginx: + image: nginx:alpine + container_name: web-server + restart: unless-stopped + ports: + - "8080:80" + volumes: + - ./:/var/www + - ./docker-compose/nginx:/etc/nginx/conf.d/ + networks: + - cookbooks app: build: . container_name: cookbookshq @@ -9,9 +20,6 @@ services: - ./:/var/www networks: - cookbooks - environment: - PHP_IDE_CONFIG: "serverName=localhost" - XDEBUG_CONFIG: "idekey=PHPSTORM" db: image: mariadb:latest container_name: db @@ -25,20 +33,18 @@ services: - 3306:3306 networks: - cookbooks - nginx: - image: nginx:alpine - container_name: web-server + cache: + image: redis:latest + container_name: cache restart: unless-stopped ports: - - "8080:80" + - "6379:6379" volumes: - - ./:/var/www - - ./docker-compose/nginx:/etc/nginx/conf.d/ - networks: - - cookbooks - + - cache:/data volumes: mysqldata: + cache: + driver: local networks: cookbooks: From 078a19374341ed6e2cac8f7c92561758b820c0bb Mon Sep 17 00:00:00 2001 From: aa-florence Date: Thu, 20 Jun 2024 09:52:18 -0400 Subject: [PATCH 4/6] chore: more config --- Makefile | 11 +- bootstrap/cache/config.php | 932 ------------------------------------- docker-compose.yml | 4 +- 3 files changed, 6 insertions(+), 941 deletions(-) delete mode 100644 bootstrap/cache/config.php diff --git a/Makefile b/Makefile index e4ab655a..a1ac24fa 100755 --- a/Makefile +++ b/Makefile @@ -87,16 +87,13 @@ dump_autoload: ## 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/bootstrap/cache/config.php b/bootstrap/cache/config.php deleted file mode 100644 index 332b77cb..00000000 --- a/bootstrap/cache/config.php +++ /dev/null @@ -1,932 +0,0 @@ - - array ( - 'name' => 'Laravel', - 'env' => 'local', - 'debug' => true, - 'url' => 'http://localhost:8080', - 'asset_url' => NULL, - 'timezone' => 'UTC', - 'locale' => 'en', - 'fallback_locale' => 'en', - 'faker_locale' => 'en_US', - 'key' => 'base64:AUpD1xmzmeyWy8yxwLZ0mOwhznvs3qAFnblqcjHPKVY=', - 'cipher' => 'AES-256-CBC', - 'providers' => - array ( - 0 => 'Illuminate\\Auth\\AuthServiceProvider', - 1 => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', - 2 => 'Illuminate\\Bus\\BusServiceProvider', - 3 => 'Illuminate\\Cache\\CacheServiceProvider', - 4 => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', - 5 => 'Illuminate\\Cookie\\CookieServiceProvider', - 6 => 'Illuminate\\Database\\DatabaseServiceProvider', - 7 => 'Illuminate\\Encryption\\EncryptionServiceProvider', - 8 => 'Illuminate\\Filesystem\\FilesystemServiceProvider', - 9 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider', - 10 => 'Illuminate\\Hashing\\HashServiceProvider', - 11 => 'Illuminate\\Mail\\MailServiceProvider', - 12 => 'Illuminate\\Notifications\\NotificationServiceProvider', - 13 => 'Illuminate\\Pagination\\PaginationServiceProvider', - 14 => 'Illuminate\\Pipeline\\PipelineServiceProvider', - 15 => 'Illuminate\\Queue\\QueueServiceProvider', - 16 => 'Illuminate\\Redis\\RedisServiceProvider', - 17 => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider', - 18 => 'Illuminate\\Session\\SessionServiceProvider', - 19 => 'Illuminate\\Translation\\TranslationServiceProvider', - 20 => 'Illuminate\\Validation\\ValidationServiceProvider', - 21 => 'Illuminate\\View\\ViewServiceProvider', - 22 => 'Ichtrojan\\Otp\\OtpServiceProvider', - 23 => 'App\\Providers\\AppServiceProvider', - 24 => 'App\\Providers\\AuthServiceProvider', - 25 => 'App\\Providers\\EventServiceProvider', - 26 => 'App\\Providers\\RouteServiceProvider', - 27 => 'Laravel\\Socialite\\SocialiteServiceProvider', - 28 => 'SocialiteProviders\\Manager\\ServiceProvider', - 29 => 'Thedevsaddam\\LaravelSchema\\LaravelSchemaServiceProvider', - 30 => 'Sentry\\Laravel\\ServiceProvider', - ), - 'aliases' => - array ( - 'App' => 'Illuminate\\Support\\Facades\\App', - 'Arr' => 'Illuminate\\Support\\Arr', - 'Artisan' => 'Illuminate\\Support\\Facades\\Artisan', - 'Auth' => 'Illuminate\\Support\\Facades\\Auth', - 'Blade' => 'Illuminate\\Support\\Facades\\Blade', - 'Broadcast' => 'Illuminate\\Support\\Facades\\Broadcast', - 'Bus' => 'Illuminate\\Support\\Facades\\Bus', - 'Cache' => 'Illuminate\\Support\\Facades\\Cache', - 'Config' => 'Illuminate\\Support\\Facades\\Config', - 'Cookie' => 'Illuminate\\Support\\Facades\\Cookie', - 'Crypt' => 'Illuminate\\Support\\Facades\\Crypt', - 'DB' => 'Illuminate\\Support\\Facades\\DB', - 'Eloquent' => 'Illuminate\\Database\\Eloquent\\Model', - 'Event' => 'Illuminate\\Support\\Facades\\Event', - 'File' => 'Illuminate\\Support\\Facades\\File', - 'Gate' => 'Illuminate\\Support\\Facades\\Gate', - 'Hash' => 'Illuminate\\Support\\Facades\\Hash', - 'Http' => 'Illuminate\\Support\\Facades\\Http', - 'Lang' => 'Illuminate\\Support\\Facades\\Lang', - 'Log' => 'Illuminate\\Support\\Facades\\Log', - 'Mail' => 'Illuminate\\Support\\Facades\\Mail', - 'Notification' => 'Illuminate\\Support\\Facades\\Notification', - 'Password' => 'Illuminate\\Support\\Facades\\Password', - 'Queue' => 'Illuminate\\Support\\Facades\\Queue', - 'Redirect' => 'Illuminate\\Support\\Facades\\Redirect', - 'Redis' => 'Illuminate\\Support\\Facades\\Redis', - 'Request' => 'Illuminate\\Support\\Facades\\Request', - 'Response' => 'Illuminate\\Support\\Facades\\Response', - 'Route' => 'Illuminate\\Support\\Facades\\Route', - 'Schema' => 'Illuminate\\Support\\Facades\\Schema', - 'Session' => 'Illuminate\\Support\\Facades\\Session', - 'Storage' => 'Illuminate\\Support\\Facades\\Storage', - 'Str' => 'Illuminate\\Support\\Str', - 'URL' => 'Illuminate\\Support\\Facades\\URL', - 'Validator' => 'Illuminate\\Support\\Facades\\Validator', - 'View' => 'Illuminate\\Support\\Facades\\View', - 'Socialite' => 'Laravel\\Socialite\\Facades\\Socialite', - 'Otp' => 'Ichtrojan\\Otp\\Otp', - ), - ), - 'auth' => - array ( - 'defaults' => - array ( - 'guard' => 'api', - 'passwords' => 'users', - ), - 'guards' => - array ( - 'web' => - array ( - 'driver' => 'session', - 'provider' => 'users', - ), - 'api' => - array ( - 'driver' => 'jwt', - 'provider' => 'users', - 'hash' => false, - ), - ), - 'providers' => - array ( - 'users' => - array ( - 'driver' => 'eloquent', - 'model' => 'App\\Models\\User', - ), - ), - 'passwords' => - array ( - 'users' => - array ( - 'provider' => 'users', - 'table' => 'password_resets', - 'expire' => 60, - 'throttle' => 60, - ), - ), - 'password_timeout' => 10800, - ), - 'broadcasting' => - array ( - 'default' => 'null', - 'connections' => - array ( - 'pusher' => - array ( - 'driver' => 'pusher', - 'key' => NULL, - 'secret' => NULL, - 'app_id' => NULL, - 'options' => - array ( - 'cluster' => NULL, - 'useTLS' => true, - ), - ), - 'redis' => - array ( - 'driver' => 'redis', - 'connection' => 'default', - ), - 'log' => - array ( - 'driver' => 'log', - ), - 'null' => - array ( - 'driver' => 'null', - ), - ), - ), - 'cache' => - array ( - 'default' => 'file', - 'stores' => - array ( - 'apc' => - array ( - 'driver' => 'apc', - ), - 'array' => - array ( - 'driver' => 'array', - 'serialize' => false, - ), - 'database' => - array ( - 'driver' => 'database', - 'table' => 'cache', - 'connection' => NULL, - ), - 'file' => - array ( - 'driver' => 'file', - 'path' => '/var/www/storage/framework/cache/data', - ), - 'memcached' => - array ( - 'driver' => 'memcached', - 'persistent_id' => NULL, - 'sasl' => - array ( - 0 => NULL, - 1 => NULL, - ), - 'options' => - array ( - ), - 'servers' => - array ( - 0 => - array ( - 'host' => '127.0.0.1', - 'port' => 11211, - 'weight' => 100, - ), - ), - ), - 'redis' => - array ( - 'driver' => 'redis', - 'connection' => 'cache', - ), - 'dynamodb' => - array ( - 'driver' => 'dynamodb', - 'key' => NULL, - 'secret' => NULL, - 'region' => 'us-east-1', - 'table' => 'cache', - 'endpoint' => NULL, - ), - ), - 'prefix' => 'laravel_cache', - ), - 'cors' => - array ( - 'paths' => - array ( - 0 => 'api/*', - ), - 'allowed_methods' => - array ( - 0 => '*', - ), - 'allowed_origins' => - array ( - 0 => '*', - ), - 'allowed_origins_patterns' => - array ( - ), - 'allowed_headers' => - array ( - 0 => '*', - ), - 'exposed_headers' => - array ( - ), - 'max_age' => 0, - 'supports_credentials' => false, - ), - 'database' => - array ( - 'default' => 'mysql', - 'connections' => - array ( - 'sqlite' => - array ( - 'driver' => 'sqlite', - 'url' => NULL, - 'database' => 'test_db', - 'prefix' => '', - 'foreign_key_constraints' => true, - ), - 'mysql' => - array ( - 'read' => - array ( - 'host' => 'db', - ), - 'write' => - array ( - 'host' => 'db', - ), - 'sticky' => true, - 'driver' => 'mysql', - 'database' => 'test_db', - 'username' => 'root', - 'password' => 'pass', - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - ), - ), - 'migrations' => 'migrations', - ), - 'docs' => - array ( - 'api' => - array ( - 'users' => - array ( - 'register' => - array ( - 'method' => 'POST', - 'endpoint' => 'api/v1/auth/register', - ), - 'login' => - array ( - 'method' => 'POST', - 'endpoint' => 'api/v1/auth/login', - ), - ), - 'cookbooks' => - array ( - 'routes' => - array ( - 'view_all' => - array ( - 'GET' => 'api/v1/cookbooks', - ), - 'get_one' => - array ( - 'GET' => 'api/v1/cookbooks/:id', - ), - 'create_one' => - array ( - 'POST' => 'api/v1/cookbooks', - ), - 'partial_update_one' => - array ( - 'PATCH' => 'api/v1/cookbooks/:id', - ), - 'full_update_one' => - array ( - 'PUT' => 'api/v1/cookbooks/:id', - ), - ), - ), - ), - ), - 'filesystems' => - array ( - 'default' => 'local', - 'cloud' => 's3', - 'disks' => - array ( - 'local' => - array ( - 'driver' => 'local', - 'root' => '/var/www/storage/app', - ), - 'public' => - array ( - 'driver' => 'local', - 'root' => '/var/www/storage/app/public', - 'url' => 'http://localhost:8080/storage', - 'visibility' => 'public', - ), - 's3' => - array ( - 'driver' => 's3', - 'key' => NULL, - 'secret' => NULL, - 'region' => NULL, - 'bucket' => NULL, - 'url' => NULL, - 'endpoint' => NULL, - ), - ), - 'links' => - array ( - '/var/www/public/storage' => '/var/www/storage/app/public', - ), - ), - 'hashing' => - array ( - 'driver' => 'bcrypt', - 'bcrypt' => - array ( - 'rounds' => 10, - ), - 'argon' => - array ( - 'memory' => 1024, - 'threads' => 2, - 'time' => 2, - ), - ), - 'jwt' => - array ( - 'secret' => 'wHEYhImKUXCXhwWwRsxt6RGoIl1GQPP2bVyyfPGZQkGNNt60CfG27kBqmWYh5vco', - 'keys' => - array ( - 'public' => NULL, - 'private' => NULL, - 'passphrase' => NULL, - ), - 'ttl' => 1440, - 'refresh_ttl' => 20160, - 'algo' => 'HS256', - 'required_claims' => - array ( - 0 => 'iss', - 1 => 'iat', - 2 => 'exp', - 3 => 'nbf', - 4 => 'sub', - 5 => 'jti', - ), - 'persistent_claims' => - array ( - ), - 'lock_subject' => true, - 'leeway' => 0, - 'blacklist_enabled' => true, - 'blacklist_grace_period' => 0, - 'decrypt_cookies' => false, - 'providers' => - array ( - 'jwt' => 'Tymon\\JWTAuth\\Providers\\JWT\\Lcobucci', - 'auth' => 'Tymon\\JWTAuth\\Providers\\Auth\\Illuminate', - 'storage' => 'Tymon\\JWTAuth\\Providers\\Storage\\Illuminate', - ), - 'show_black_list_exception' => true, - ), - 'logging' => - array ( - 'default' => 'sentry', - 'channels' => - array ( - 'stack' => - array ( - 'driver' => 'stack', - 'channels' => - array ( - 0 => 'single', - ), - 'ignore_exceptions' => false, - ), - 'single' => - array ( - 'driver' => 'single', - 'path' => '/var/www/storage/logs/laravel.log', - 'level' => 'debug', - ), - 'daily' => - array ( - 'driver' => 'daily', - 'path' => '/var/www/storage/logs/laravel.log', - 'level' => 'debug', - 'days' => 14, - ), - 'slack' => - array ( - 'driver' => 'slack', - 'url' => NULL, - 'username' => 'Laravel Log', - 'emoji' => ':boom:', - 'level' => 'critical', - ), - 'papertrail' => - array ( - 'driver' => 'monolog', - 'level' => 'debug', - 'handler' => 'Monolog\\Handler\\SyslogUdpHandler', - 'handler_with' => - array ( - 'host' => NULL, - 'port' => NULL, - ), - ), - 'stderr' => - array ( - 'driver' => 'monolog', - 'handler' => 'Monolog\\Handler\\StreamHandler', - 'formatter' => NULL, - 'with' => - array ( - 'stream' => 'php://stderr', - ), - ), - 'syslog' => - array ( - 'driver' => 'syslog', - 'level' => 'debug', - ), - 'errorlog' => - array ( - 'driver' => 'errorlog', - 'level' => 'debug', - ), - 'null' => - array ( - 'driver' => 'monolog', - 'handler' => 'Monolog\\Handler\\NullHandler', - ), - 'emergency' => - array ( - 'path' => '/var/www/storage/logs/laravel.log', - ), - 'sentry' => - array ( - 'driver' => 'sentry', - 'channels' => - array ( - 0 => 'single', - 1 => 'sentry', - ), - ), - ), - ), - 'mail' => - array ( - 'default' => 'smtp', - 'mailers' => - array ( - 'smtp' => - array ( - 'transport' => 'smtp', - 'host' => '', - 'port' => '', - 'encryption' => '', - 'username' => '', - 'password' => '', - 'timeout' => NULL, - 'auth_mode' => NULL, - ), - 'ses' => - array ( - 'transport' => 'ses', - ), - 'mailgun' => - array ( - 'transport' => 'mailgun', - ), - 'postmark' => - array ( - 'transport' => 'postmark', - ), - 'sendmail' => - array ( - 'transport' => 'sendmail', - 'path' => '/usr/sbin/sendmail -bs', - ), - 'log' => - array ( - 'transport' => 'log', - 'channel' => NULL, - ), - 'array' => - array ( - 'transport' => 'array', - ), - ), - 'from' => - array ( - 'address' => '', - 'name' => '', - ), - 'markdown' => - array ( - 'theme' => 'default', - 'paths' => - array ( - 0 => '/var/www/resources/views/vendor/mail', - ), - ), - ), - 'queue' => - array ( - 'default' => 'database', - 'connections' => - array ( - 'sync' => - array ( - 'driver' => 'sync', - ), - 'database' => - array ( - 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', - 'retry_after' => 90, - ), - 'beanstalkd' => - array ( - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, - 'block_for' => 0, - ), - 'sqs' => - array ( - 'driver' => 'sqs', - 'key' => NULL, - 'secret' => NULL, - 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', - 'queue' => 'your-queue-name', - 'suffix' => NULL, - 'region' => 'us-east-1', - ), - 'redis' => - array ( - 'driver' => 'redis', - 'connection' => 'default', - 'queue' => 'default', - 'retry_after' => 90, - 'block_for' => NULL, - ), - ), - 'failed' => - array ( - 'driver' => 'database', - 'database' => 'mysql', - 'table' => 'failed_jobs', - ), - ), - 'sentry' => - array ( - 'dsn' => '', - 'release' => NULL, - 'environment' => NULL, - 'sample_rate' => 1.0, - 'traces_sample_rate' => NULL, - 'profiles_sample_rate' => NULL, - 'send_default_pii' => false, - 'breadcrumbs' => - array ( - 'logs' => true, - 'cache' => true, - 'livewire' => true, - 'sql_queries' => true, - 'sql_bindings' => false, - 'queue_info' => true, - 'command_info' => true, - 'http_client_requests' => true, - ), - 'tracing' => - array ( - 'queue_job_transactions' => false, - 'queue_jobs' => true, - 'sql_queries' => true, - 'sql_origin' => true, - 'views' => true, - 'livewire' => true, - 'http_client_requests' => true, - 'redis_commands' => false, - 'redis_origin' => true, - 'missing_routes' => false, - 'continue_after_response' => true, - 'default_integrations' => true, - ), - ), - 'services' => - array ( - 'mailgun' => - array ( - 'domain' => '', - 'secret' => '', - 'endpoint' => 'api.mailgun.net', - ), - 'postmark' => - array ( - 'token' => NULL, - ), - 'ses' => - array ( - 'key' => NULL, - 'secret' => NULL, - 'region' => 'us-east-1', - ), - 'tiktok' => - array ( - 'client_id' => '', - 'client_secret' => '', - 'redirect' => '', - 'users' => - array ( - 'secret_pass' => 'fakePass', - ), - 'v1_host' => 'https://open-api.tiktok.com', - 'v2_host' => 'https://open.tiktokapis.com/v2', - ), - 'ipinfo' => - array ( - 'access_token' => '', - ), - 'faker' => - array ( - 'pass' => NULL, - ), - 'otp' => - array ( - 'digits' => 6, - 'validity' => 15, - ), - 'redirects' => - array ( - 'tiktok' => - array ( - 'web-client-vue2' => 'https://web.cookbookshq.com/tiktok/?', - 'beta-version-1-staging' => '/tiktok?', - ), - 'errors' => - array ( - 'web-client-vue2' => 'https://web.cookbookshq.com/errors/?', - 'beta-version-1-staging' => '/errors?', - ), - ), - ), - 'session' => - array ( - 'driver' => 'file', - 'lifetime' => 120, - 'expire_on_close' => false, - 'encrypt' => false, - 'files' => '/var/www/storage/framework/sessions', - 'connection' => NULL, - 'table' => 'sessions', - 'store' => NULL, - 'lottery' => - array ( - 0 => 2, - 1 => 100, - ), - 'cookie' => 'laravel_session', - 'path' => '/', - 'domain' => '', - 'secure' => false, - 'http_only' => true, - 'same_site' => 'lax', - ), - 'tinker' => - array ( - 'commands' => - array ( - ), - 'alias' => - array ( - ), - 'dont_alias' => - array ( - 0 => 'App\\Nova', - ), - ), - 'view' => - array ( - 'paths' => - array ( - 0 => '/var/www/resources/views', - ), - 'compiled' => '/var/www/storage/framework/views', - ), - 'sidecar' => - array ( - 'functions' => - array ( - ), - 'app_name' => NULL, - 'env' => 'local', - 'timeout' => 300, - 'memory' => 512, - 'storage' => 512, - 'architecture' => 'x86_64', - 'package_base_path' => '/var/www', - 'aws_key' => NULL, - 'aws_secret' => NULL, - 'aws_region' => NULL, - 'aws_bucket' => NULL, - 'execution_role' => NULL, - 'lambda_prefix' => 'SC', - ), - 'ipinfolaravel' => - array ( - ), - 'health' => - array ( - 'result_stores' => - array ( - 'Spatie\\Health\\ResultStores\\EloquentHealthResultStore' => - array ( - 'connection' => 'mysql', - 'model' => 'Spatie\\Health\\Models\\HealthCheckResultHistoryItem', - 'keep_history_for_days' => 5, - ), - ), - 'notifications' => - array ( - 'enabled' => true, - 'notifications' => - array ( - 'Spatie\\Health\\Notifications\\CheckFailedNotification' => - array ( - 0 => 'mail', - ), - ), - 'notifiable' => 'Spatie\\Health\\Notifications\\Notifiable', - 'throttle_notifications_for_minutes' => 60, - 'throttle_notifications_key' => 'health:latestNotificationSentAt:', - 'mail' => - array ( - 'to' => 'your@example.com', - 'from' => - array ( - 'address' => '', - 'name' => '', - ), - ), - 'slack' => - array ( - 'webhook_url' => '', - 'channel' => NULL, - 'username' => NULL, - 'icon' => NULL, - ), - ), - 'oh_dear_endpoint' => - array ( - 'enabled' => false, - 'always_send_fresh_results' => true, - 'secret' => NULL, - 'url' => '/oh-dear-health-check-results', - ), - 'theme' => 'light', - 'silence_health_queue_job' => true, - ), - 'flare' => - array ( - 'key' => NULL, - 'flare_middleware' => - array ( - 0 => 'Spatie\\FlareClient\\FlareMiddleware\\RemoveRequestIp', - 1 => 'Spatie\\FlareClient\\FlareMiddleware\\AddGitInformation', - 2 => 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddNotifierName', - 3 => 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddEnvironmentInformation', - 4 => 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddExceptionInformation', - 5 => 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddDumps', - 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddLogs' => - array ( - 'maximum_number_of_collected_logs' => 200, - ), - 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddQueries' => - array ( - 'maximum_number_of_collected_queries' => 200, - 'report_query_bindings' => true, - ), - 'Spatie\\LaravelIgnition\\FlareMiddleware\\AddJobs' => - array ( - 'max_chained_job_reporting_depth' => 5, - ), - 'Spatie\\FlareClient\\FlareMiddleware\\CensorRequestBodyFields' => - array ( - 'censor_fields' => - array ( - 0 => 'password', - 1 => 'password_confirmation', - ), - ), - 'Spatie\\FlareClient\\FlareMiddleware\\CensorRequestHeaders' => - array ( - 'headers' => - array ( - 0 => 'API-KEY', - ), - ), - ), - 'send_logs_as_events' => true, - ), - 'ignition' => - array ( - 'editor' => 'phpstorm', - 'theme' => 'auto', - 'enable_share_button' => true, - 'register_commands' => false, - 'solution_providers' => - array ( - 0 => 'Spatie\\Ignition\\Solutions\\SolutionProviders\\BadMethodCallSolutionProvider', - 1 => 'Spatie\\Ignition\\Solutions\\SolutionProviders\\MergeConflictSolutionProvider', - 2 => 'Spatie\\Ignition\\Solutions\\SolutionProviders\\UndefinedPropertySolutionProvider', - 3 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\IncorrectValetDbCredentialsSolutionProvider', - 4 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingAppKeySolutionProvider', - 5 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\DefaultDbNameSolutionProvider', - 6 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\TableNotFoundSolutionProvider', - 7 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingImportSolutionProvider', - 8 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\InvalidRouteActionSolutionProvider', - 9 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\ViewNotFoundSolutionProvider', - 10 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\RunningLaravelDuskInProductionProvider', - 11 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingColumnSolutionProvider', - 12 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\UnknownValidationSolutionProvider', - 13 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingMixManifestSolutionProvider', - 14 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingViteManifestSolutionProvider', - 15 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\MissingLivewireComponentSolutionProvider', - 16 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\UndefinedViewVariableSolutionProvider', - 17 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\GenericLaravelExceptionSolutionProvider', - 18 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\OpenAiSolutionProvider', - 19 => 'Spatie\\LaravelIgnition\\Solutions\\SolutionProviders\\SailNetworkSolutionProvider', - ), - 'ignored_solution_providers' => - array ( - ), - 'enable_runnable_solutions' => NULL, - 'remote_sites_path' => '/var/www', - 'local_sites_path' => '', - 'housekeeping_endpoint_prefix' => '_ignition', - 'settings_file_path' => '', - 'recorders' => - array ( - 0 => 'Spatie\\LaravelIgnition\\Recorders\\DumpRecorder\\DumpRecorder', - 1 => 'Spatie\\LaravelIgnition\\Recorders\\JobRecorder\\JobRecorder', - 2 => 'Spatie\\LaravelIgnition\\Recorders\\LogRecorder\\LogRecorder', - 3 => 'Spatie\\LaravelIgnition\\Recorders\\QueryRecorder\\QueryRecorder', - ), - 'open_ai_key' => NULL, - 'with_stack_frame_arguments' => true, - 'argument_reducers' => - array ( - 0 => 'Spatie\\Backtrace\\Arguments\\Reducers\\BaseTypeArgumentReducer', - 1 => 'Spatie\\Backtrace\\Arguments\\Reducers\\ArrayArgumentReducer', - 2 => 'Spatie\\Backtrace\\Arguments\\Reducers\\StdClassArgumentReducer', - 3 => 'Spatie\\Backtrace\\Arguments\\Reducers\\EnumArgumentReducer', - 4 => 'Spatie\\Backtrace\\Arguments\\Reducers\\ClosureArgumentReducer', - 5 => 'Spatie\\Backtrace\\Arguments\\Reducers\\DateTimeArgumentReducer', - 6 => 'Spatie\\Backtrace\\Arguments\\Reducers\\DateTimeZoneArgumentReducer', - 7 => 'Spatie\\Backtrace\\Arguments\\Reducers\\SymphonyRequestArgumentReducer', - 8 => 'Spatie\\LaravelIgnition\\ArgumentReducers\\ModelArgumentReducer', - 9 => 'Spatie\\LaravelIgnition\\ArgumentReducers\\CollectionArgumentReducer', - 10 => 'Spatie\\Backtrace\\Arguments\\Reducers\\StringableArgumentReducer', - ), - ), - 'horizon' => - array ( - 'silenced' => - array ( - 0 => 'Spatie\\Health\\Jobs\\HealthQueueJob', - ), - ), -); diff --git a/docker-compose.yml b/docker-compose.yml index a747dac8..1b3c387f 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.7" services: nginx: - image: nginx:alpine + image: nginx:latest container_name: web-server restart: unless-stopped ports: @@ -24,7 +24,7 @@ services: image: mariadb:latest container_name: db environment: - MYSQL_DATABASE: test_db + MYSQL_DATABASE: cookbooks MYSQL_PASSWORD: pass MYSQL_ROOT_PASSWORD: pass volumes: From 63ff1b364da448e7d052c53e6b74cee3b8d665b0 Mon Sep 17 00:00:00 2001 From: aa-florence Date: Wed, 26 Jun 2024 13:27:32 -0400 Subject: [PATCH 5/6] heavy chore --- app/Http/Controllers/CommentController.php | 2 -- app/Http/Controllers/RecipeController.php | 1 - app/Http/Controllers/UserController.php | 3 --- app/Http/Middleware/JWTAuthGuard.php | 2 -- app/Interfaces/serviceInterface.php | 24 +++++++++++++++++-- app/Services/CookbookService.php | 3 --- app/Services/SearchService.php | 5 ---- app/Services/TikTok/AccessToken.php | 8 +++---- app/Services/TikTok/HttpRequestRunner.php | 25 +++++++++++++++----- app/Services/TikTok/Request.php | 8 +++---- app/Services/TikTok/UserInfo.php | 3 +-- app/Services/TikTok/Videos.php | 8 +++---- app/Services/UserContactDetailsService.php | 6 ++--- app/Services/UserService.php | 15 +++++++----- app/Traits/EncryptsPayload.php | 2 +- app/Utils/UriHelper.php | 3 +++ composer.json | 3 ++- composer.lock | 27 ++++++++++------------ config/tiktok.php | 3 +++ phpstan.neon | 12 ++++++---- 20 files changed, 93 insertions(+), 70 deletions(-) create mode 100644 config/tiktok.php 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/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/composer.json b/composer.json index 9e166848..087b10b9 100755 --- a/composer.json +++ b/composer.json @@ -44,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 ee6ead95..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": "a4e9787c1a523737182bf491d5ae6ee1", + "content-hash": "5ed8ec07dfccb4e0f2fc72c98dc2bfed", "packages": [ { "name": "aws/aws-crt-php", @@ -10278,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": "" }, @@ -10346,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": [ { @@ -10367,6 +10367,7 @@ "type": "patreon" } ], + "abandoned": "larastan/larastan", "time": "2023-07-29T12:13:13+00:00" }, { @@ -10569,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": { @@ -10621,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", @@ -12104,5 +12101,5 @@ "platform-dev": { "ext-json": "*" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } 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 @@ + Date: Wed, 26 Jun 2024 13:34:38 -0400 Subject: [PATCH 6/6] failing build --- .github/workflows/static-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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