diff --git a/README.md b/README.md
index db99724f..1077eb80 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,14 @@ Bar assistant is a self hosted application for managing your home bar. It allows
This repository only contains the API server, if you are looking for easy to use web client, take a look at [Salt Rim](https://github.com/karlomikus/vue-salt-rim).
+
+ Click here to view API demo.
+
+ Click here to view frontend demo.
+
+ Email: admin@example.com · Password: password
+
+
## Features
- Includes all current IBA cocktails
- Over 100 ingredients
diff --git a/app/Console/Commands/OpenBar.php b/app/Console/Commands/OpenBar.php
index c8c644fb..90d52a04 100644
--- a/app/Console/Commands/OpenBar.php
+++ b/app/Console/Commands/OpenBar.php
@@ -45,6 +45,8 @@ public function handle()
{
Model::unguard();
+ $this->info('Opening the bar in ' . App::environment() . ' environment...');
+
$this->info('Checking connection to your search server [' . config('scout.meilisearch.host') . ']...');
try {
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 34cd9dbb..b061561e 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -64,5 +64,6 @@ class Kernel extends HttpKernel
'signed' => \Kami\Cocktail\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
+ 'cacheResponse' => \Spatie\ResponseCache\Middlewares\CacheResponse::class,
];
}
diff --git a/composer.json b/composer.json
index 43cf8222..f5b636b9 100644
--- a/composer.json
+++ b/composer.json
@@ -14,6 +14,7 @@
"laravel/scout": "^9.4",
"laravel/tinker": "^2.7",
"meilisearch/meilisearch-php": "^0.25.0",
+ "spatie/laravel-responsecache": "^7.4",
"spatie/laravel-sluggable": "^3.4",
"symfony/yaml": "^6.1"
},
diff --git a/composer.lock b/composer.lock
index 000f182b..2088f0eb 100644
--- 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": "20a4532bd1d53d97314ea5577d293c11",
+ "content-hash": "947e57c73915f7ab7db00e1a74cdc1cd",
"packages": [
{
"name": "brick/math",
@@ -3572,6 +3572,149 @@
],
"time": "2022-09-16T03:22:46+00:00"
},
+ {
+ "name": "spatie/laravel-package-tools",
+ "version": "1.13.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/spatie/laravel-package-tools.git",
+ "reference": "4af8e608184471b5568af6265ebb0ca0025c131a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/4af8e608184471b5568af6265ebb0ca0025c131a",
+ "reference": "4af8e608184471b5568af6265ebb0ca0025c131a",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/contracts": "^9.28",
+ "php": "^8.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "^1.5",
+ "orchestra/testbench": "^7.7",
+ "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.13.7"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/spatie",
+ "type": "github"
+ }
+ ],
+ "time": "2022-11-15T09:10:09+00:00"
+ },
+ {
+ "name": "spatie/laravel-responsecache",
+ "version": "7.4.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/spatie/laravel-responsecache.git",
+ "reference": "59b28a5898da23a44e0a1b0be83db253733a8f86"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/spatie/laravel-responsecache/zipball/59b28a5898da23a44e0a1b0be83db253733a8f86",
+ "reference": "59b28a5898da23a44e0a1b0be83db253733a8f86",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/cache": "^8.71|^9.0",
+ "illuminate/console": "^8.71|^9.0",
+ "illuminate/container": "^8.71|^9.0",
+ "illuminate/http": "^8.71|^9.0",
+ "illuminate/support": "^8.71|^9.0",
+ "nesbot/carbon": "^2.35",
+ "php": "^8.0",
+ "spatie/laravel-package-tools": "^1.9"
+ },
+ "require-dev": {
+ "laravel/framework": "^9.0",
+ "mockery/mockery": "^1.4",
+ "orchestra/testbench": "^6.23|^7.0",
+ "phpunit/phpunit": "^9.4"
+ },
+ "type": "library",
+ "extra": {
+ "laravel": {
+ "providers": [
+ "Spatie\\ResponseCache\\ResponseCacheServiceProvider"
+ ],
+ "aliases": {
+ "ResponseCache": "Spatie\\ResponseCache\\Facades\\ResponseCache"
+ }
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Spatie\\ResponseCache\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Freek Van der Herten",
+ "email": "freek@spatie.be",
+ "homepage": "https://spatie.be",
+ "role": "Developer"
+ }
+ ],
+ "description": "Speed up a Laravel application by caching the entire response",
+ "homepage": "https://github.com/spatie/laravel-responsecache",
+ "keywords": [
+ "cache",
+ "laravel",
+ "laravel-responsecache",
+ "performance",
+ "response",
+ "spatie"
+ ],
+ "support": {
+ "source": "https://github.com/spatie/laravel-responsecache/tree/7.4.3"
+ },
+ "funding": [
+ {
+ "url": "https://spatie.be/open-source/support-us",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/spatie",
+ "type": "github"
+ }
+ ],
+ "time": "2022-09-24T12:15:10+00:00"
+ },
{
"name": "spatie/laravel-sluggable",
"version": "3.4.0",
diff --git a/config/bar-assistant.php b/config/bar-assistant.php
index 5a87c5cc..b4544ade 100644
--- a/config/bar-assistant.php
+++ b/config/bar-assistant.php
@@ -11,7 +11,7 @@
|
*/
- 'version' => 'v0.5.0',
+ 'version' => 'v0.5.1',
/*
|--------------------------------------------------------------------------
diff --git a/config/responsecache.php b/config/responsecache.php
new file mode 100644
index 00000000..331c24eb
--- /dev/null
+++ b/config/responsecache.php
@@ -0,0 +1,94 @@
+ env('RESPONSE_CACHE_ENABLED', true),
+
+ /*
+ * The given class will determinate if a request should be cached. The
+ * default class will cache all successful GET-requests.
+ *
+ * You can provide your own class given that it implements the
+ * CacheProfile interface.
+ */
+ 'cache_profile' => Spatie\ResponseCache\CacheProfiles\CacheAllSuccessfulGetRequests::class,
+
+ /*
+ * Optionally, you can specify a header that will force a cache bypass.
+ * This can be useful to monitor the performance of your application.
+ */
+ 'cache_bypass_header' => [
+ 'name' => env('CACHE_BYPASS_HEADER_NAME', null),
+ 'value' => env('CACHE_BYPASS_HEADER_VALUE', null),
+ ],
+
+ /*
+ * When using the default CacheRequestFilter this setting controls the
+ * default number of seconds responses must be cached.
+ */
+ 'cache_lifetime_in_seconds' => env('RESPONSE_CACHE_LIFETIME', 60 * 60 * 24 * 7),
+
+ /*
+ * This setting determines if a http header named with the cache time
+ * should be added to a cached response. This can be handy when
+ * debugging.
+ */
+ 'add_cache_time_header' => env('APP_DEBUG', true),
+
+ /*
+ * This setting determines the name of the http header that contains
+ * the time at which the response was cached
+ */
+ 'cache_time_header_name' => env('RESPONSE_CACHE_HEADER_NAME', 'laravel-responsecache'),
+
+ /*
+ * This setting determines if a http header named with the cache age
+ * should be added to a cached response. This can be handy when
+ * debugging.
+ * ONLY works when "add_cache_time_header" is also active!
+ */
+ 'add_cache_age_header' => env('RESPONSE_CACHE_AGE_HEADER', false),
+
+ /*
+ * This setting determines the name of the http header that contains
+ * the age of cache
+ */
+ 'cache_age_header_name' => env('RESPONSE_CACHE_AGE_HEADER_NAME', 'laravel-responsecache-age'),
+
+ /*
+ * Here you may define the cache store that should be used to store
+ * requests. This can be the name of any store that is
+ * configured in app/config/cache.php
+ */
+ 'cache_store' => env('RESPONSE_CACHE_DRIVER', 'file'),
+
+ /*
+ * Here you may define replacers that dynamically replace content from the response.
+ * Each replacer must implement the Replacer interface.
+ */
+ 'replacers' => [
+ \Spatie\ResponseCache\Replacers\CsrfTokenReplacer::class,
+ ],
+
+ /*
+ * If the cache driver you configured supports tags, you may specify a tag name
+ * here. All responses will be tagged. When clearing the responsecache only
+ * items with that tag will be flushed.
+ *
+ * You may use a string or an array here.
+ */
+ 'cache_tag' => '',
+
+ /*
+ * This class is responsible for generating a hash for a request. This hash
+ * is used to look up an cached response.
+ */
+ 'hasher' => \Spatie\ResponseCache\Hasher\DefaultHasher::class,
+
+ /*
+ * This class is responsible for serializing responses.
+ */
+ 'serializer' => \Spatie\ResponseCache\Serializers\DefaultSerializer::class,
+];
diff --git a/database/migrations/2022_09_28_000003_create_cocktails_table.php b/database/migrations/2022_09_28_000003_create_cocktails_table.php
index 90b1ffb3..91e6568e 100644
--- a/database/migrations/2022_09_28_000003_create_cocktails_table.php
+++ b/database/migrations/2022_09_28_000003_create_cocktails_table.php
@@ -40,7 +40,7 @@ public function up()
Schema::create('cocktail_favorites', function (Blueprint $table) {
$table->id();
- $table->foreignId('user_id')->constrained();
+ $table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->foreignId('cocktail_id')->unique()->constrained()->onDelete('cascade');
$table->timestamps();
});
diff --git a/database/migrations/2022_10_02_000004_create_tags_table.php b/database/migrations/2022_10_02_000004_create_tags_table.php
index 7400064e..0d9f6d48 100644
--- a/database/migrations/2022_10_02_000004_create_tags_table.php
+++ b/database/migrations/2022_10_02_000004_create_tags_table.php
@@ -20,7 +20,7 @@ public function up()
Schema::create('cocktail_tag', function (Blueprint $table) {
$table->id();
- $table->foreignId('tag_id')->constrained();
+ $table->foreignId('tag_id')->constrained()->onDelete('cascade');
$table->foreignId('cocktail_id')->constrained()->onDelete('cascade');
});
}
diff --git a/database/migrations/2022_10_06_174533_create_user_ingredients_table.php b/database/migrations/2022_10_06_174533_create_user_ingredients_table.php
index bcbf2071..897a1967 100644
--- a/database/migrations/2022_10_06_174533_create_user_ingredients_table.php
+++ b/database/migrations/2022_10_06_174533_create_user_ingredients_table.php
@@ -15,8 +15,8 @@ public function up()
{
Schema::create('user_ingredients', function (Blueprint $table) {
$table->id();
- $table->foreignId('user_id')->constrained();
- $table->foreignId('ingredient_id')->constrained();
+ $table->foreignId('user_id')->constrained()->onDelete('cascade');
+ $table->foreignId('ingredient_id')->constrained()->onDelete('cascade');
$table->unique(['user_id', 'ingredient_id']);
});
diff --git a/database/migrations/2022_10_22_132019_create_user_shopping_lists_table.php b/database/migrations/2022_10_22_132019_create_user_shopping_lists_table.php
index bc5b04d0..75739b39 100644
--- a/database/migrations/2022_10_22_132019_create_user_shopping_lists_table.php
+++ b/database/migrations/2022_10_22_132019_create_user_shopping_lists_table.php
@@ -15,8 +15,8 @@ public function up()
{
Schema::create('user_shopping_lists', function (Blueprint $table) {
$table->id();
- $table->foreignId('user_id')->constrained();
- $table->foreignId('ingredient_id')->constrained();
+ $table->foreignId('user_id')->constrained()->onDelete('cascade');
+ $table->foreignId('ingredient_id')->constrained()->onDelete('cascade');
$table->timestamps();
$table->unique(['user_id', 'ingredient_id']);