Cache routes

This commit is contained in:
Bernd Bestel 2023-05-21 14:13:05 +02:00
parent 89761ac141
commit c3dd1c4187
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 58 additions and 86 deletions

View File

@ -102,5 +102,7 @@ $errorMiddleware->setDefaultErrorHandler(
$app->add(new CorsMiddleware($app->getResponseFactory())); $app->add(new CorsMiddleware($app->getResponseFactory()));
$app->getRouteCollector()->setCacheFile(GROCY_DATAPATH . '/viewcache/route_cache.php');
ob_clean(); // No response output before here ob_clean(); // No response output before here
$app->run(); $app->run();

View File

@ -43,109 +43,79 @@ $app->group('', function (RouteCollectorProxy $group) {
$group->get('/product/{productId}/grocycode', '\Grocy\Controllers\StockController:ProductGrocycodeImage'); $group->get('/product/{productId}/grocycode', '\Grocy\Controllers\StockController:ProductGrocycodeImage');
// Stock handling routes // Stock handling routes
if (GROCY_FEATURE_FLAG_STOCK) $group->get('/stockoverview', '\Grocy\Controllers\StockController:Overview');
{ $group->get('/stockentries', '\Grocy\Controllers\StockController:Stockentries');
$group->get('/stockoverview', '\Grocy\Controllers\StockController:Overview'); $group->get('/purchase', '\Grocy\Controllers\StockController:Purchase');
$group->get('/stockentries', '\Grocy\Controllers\StockController:Stockentries'); $group->get('/consume', '\Grocy\Controllers\StockController:Consume');
$group->get('/purchase', '\Grocy\Controllers\StockController:Purchase'); $group->get('/transfer', '\Grocy\Controllers\StockController:Transfer');
$group->get('/consume', '\Grocy\Controllers\StockController:Consume'); $group->get('/inventory', '\Grocy\Controllers\StockController:Inventory');
$group->get('/transfer', '\Grocy\Controllers\StockController:Transfer'); $group->get('/stockentry/{entryId}', '\Grocy\Controllers\StockController:StockEntryEditForm');
$group->get('/inventory', '\Grocy\Controllers\StockController:Inventory'); $group->get('/stocksettings', '\Grocy\Controllers\StockController:StockSettings');
$group->get('/stockentry/{entryId}', '\Grocy\Controllers\StockController:StockEntryEditForm'); $group->get('/locations', '\Grocy\Controllers\StockController:LocationsList');
$group->get('/stocksettings', '\Grocy\Controllers\StockController:StockSettings'); $group->get('/location/{locationId}', '\Grocy\Controllers\StockController:LocationEditForm');
$group->get('/locations', '\Grocy\Controllers\StockController:LocationsList'); $group->get('/stockjournal', '\Grocy\Controllers\StockController:Journal');
$group->get('/location/{locationId}', '\Grocy\Controllers\StockController:LocationEditForm'); $group->get('/locationcontentsheet', '\Grocy\Controllers\StockController:LocationContentSheet');
$group->get('/stockjournal', '\Grocy\Controllers\StockController:Journal'); $group->get('/quantityunitpluraltesting', '\Grocy\Controllers\StockController:QuantityUnitPluralFormTesting');
$group->get('/locationcontentsheet', '\Grocy\Controllers\StockController:LocationContentSheet'); $group->get('/stockjournal/summary', '\Grocy\Controllers\StockController:JournalSummary');
$group->get('/quantityunitpluraltesting', '\Grocy\Controllers\StockController:QuantityUnitPluralFormTesting'); $group->get('/productbarcodes/{productBarcodeId}', '\Grocy\Controllers\StockController:ProductBarcodesEditForm');
$group->get('/stockjournal/summary', '\Grocy\Controllers\StockController:JournalSummary'); $group->get('/stockentry/{entryId}/grocycode', '\Grocy\Controllers\StockController:StockEntryGrocycodeImage');
$group->get('/productbarcodes/{productBarcodeId}', '\Grocy\Controllers\StockController:ProductBarcodesEditForm'); $group->get('/stockentry/{entryId}/label', '\Grocy\Controllers\StockController:StockEntryGrocycodeLabel');
$group->get('/stockentry/{entryId}/grocycode', '\Grocy\Controllers\StockController:StockEntryGrocycodeImage'); $group->get('/quantityunitconversionsresolved', '\Grocy\Controllers\StockController:QuantityUnitConversionsResolved');
$group->get('/stockentry/{entryId}/label', '\Grocy\Controllers\StockController:StockEntryGrocycodeLabel'); $group->get('/stockreports/spendings', '\Grocy\Controllers\StockReportsController:Spendings');
$group->get('/quantityunitconversionsresolved', '\Grocy\Controllers\StockController:QuantityUnitConversionsResolved');
$group->get('/stockreports/spendings', '\Grocy\Controllers\StockReportsController:Spendings');
}
// Stock price tracking // Stock price tracking
if (GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) $group->get('/shoppinglocations', '\Grocy\Controllers\StockController:ShoppingLocationsList');
{ $group->get('/shoppinglocation/{shoppingLocationId}', '\Grocy\Controllers\StockController:ShoppingLocationEditForm');
$group->get('/shoppinglocations', '\Grocy\Controllers\StockController:ShoppingLocationsList');
$group->get('/shoppinglocation/{shoppingLocationId}', '\Grocy\Controllers\StockController:ShoppingLocationEditForm');
}
// Shopping list routes // Shopping list routes
if (GROCY_FEATURE_FLAG_SHOPPINGLIST) $group->get('/shoppinglist', '\Grocy\Controllers\StockController:ShoppingList');
{ $group->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm');
$group->get('/shoppinglist', '\Grocy\Controllers\StockController:ShoppingList'); $group->get('/shoppinglist/{listId}', '\Grocy\Controllers\StockController:ShoppingListEditForm');
$group->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm'); $group->get('/shoppinglistsettings', '\Grocy\Controllers\StockController:ShoppingListSettings');
$group->get('/shoppinglist/{listId}', '\Grocy\Controllers\StockController:ShoppingListEditForm');
$group->get('/shoppinglistsettings', '\Grocy\Controllers\StockController:ShoppingListSettings');
}
// Recipe routes // Recipe routes
if (GROCY_FEATURE_FLAG_RECIPES) $group->get('/recipes', '\Grocy\Controllers\RecipesController:Overview');
{ $group->get('/recipe/{recipeId}', '\Grocy\Controllers\RecipesController:RecipeEditForm');
$group->get('/recipes', '\Grocy\Controllers\RecipesController:Overview'); $group->get('/recipe/{recipeId}/pos/{recipePosId}', '\Grocy\Controllers\RecipesController:RecipePosEditForm');
$group->get('/recipe/{recipeId}', '\Grocy\Controllers\RecipesController:RecipeEditForm'); $group->get('/recipessettings', '\Grocy\Controllers\RecipesController:RecipesSettings');
$group->get('/recipe/{recipeId}/pos/{recipePosId}', '\Grocy\Controllers\RecipesController:RecipePosEditForm'); $group->get('/recipe/{recipeId}/grocycode', '\Grocy\Controllers\RecipesController:RecipeGrocycodeImage');
$group->get('/recipessettings', '\Grocy\Controllers\RecipesController:RecipesSettings');
$group->get('/recipe/{recipeId}/grocycode', '\Grocy\Controllers\RecipesController:RecipeGrocycodeImage');
if (GROCY_FEATURE_FLAG_RECIPES_MEALPLAN) // Meal plan routes
{ $group->get('/mealplan', '\Grocy\Controllers\RecipesController:MealPlan');
$group->get('/mealplan', '\Grocy\Controllers\RecipesController:MealPlan'); $group->get('/mealplansections', '\Grocy\Controllers\RecipesController:MealPlanSectionsList');
$group->get('/mealplansections', '\Grocy\Controllers\RecipesController:MealPlanSectionsList'); $group->get('/mealplansection/{sectionId}', '\Grocy\Controllers\RecipesController:MealPlanSectionEditForm');
$group->get('/mealplansection/{sectionId}', '\Grocy\Controllers\RecipesController:MealPlanSectionEditForm');
}
}
// Chore routes // Chore routes
if (GROCY_FEATURE_FLAG_CHORES) $group->get('/choresoverview', '\Grocy\Controllers\ChoresController:Overview');
{ $group->get('/choretracking', '\Grocy\Controllers\ChoresController:TrackChoreExecution');
$group->get('/choresoverview', '\Grocy\Controllers\ChoresController:Overview'); $group->get('/choresjournal', '\Grocy\Controllers\ChoresController:Journal');
$group->get('/choretracking', '\Grocy\Controllers\ChoresController:TrackChoreExecution'); $group->get('/chores', '\Grocy\Controllers\ChoresController:ChoresList');
$group->get('/choresjournal', '\Grocy\Controllers\ChoresController:Journal'); $group->get('/chore/{choreId}', '\Grocy\Controllers\ChoresController:ChoreEditForm');
$group->get('/chores', '\Grocy\Controllers\ChoresController:ChoresList'); $group->get('/choressettings', '\Grocy\Controllers\ChoresController:ChoresSettings');
$group->get('/chore/{choreId}', '\Grocy\Controllers\ChoresController:ChoreEditForm'); $group->get('/chore/{choreId}/grocycode', '\Grocy\Controllers\ChoresController:ChoreGrocycodeImage');
$group->get('/choressettings', '\Grocy\Controllers\ChoresController:ChoresSettings');
$group->get('/chore/{choreId}/grocycode', '\Grocy\Controllers\ChoresController:ChoreGrocycodeImage');
}
// Battery routes // Battery routes
if (GROCY_FEATURE_FLAG_BATTERIES) $group->get('/batteriesoverview', '\Grocy\Controllers\BatteriesController:Overview');
{ $group->get('/batterytracking', '\Grocy\Controllers\BatteriesController:TrackChargeCycle');
$group->get('/batteriesoverview', '\Grocy\Controllers\BatteriesController:Overview'); $group->get('/batteriesjournal', '\Grocy\Controllers\BatteriesController:Journal');
$group->get('/batterytracking', '\Grocy\Controllers\BatteriesController:TrackChargeCycle'); $group->get('/batteries', '\Grocy\Controllers\BatteriesController:BatteriesList');
$group->get('/batteriesjournal', '\Grocy\Controllers\BatteriesController:Journal'); $group->get('/battery/{batteryId}', '\Grocy\Controllers\BatteriesController:BatteryEditForm');
$group->get('/batteries', '\Grocy\Controllers\BatteriesController:BatteriesList'); $group->get('/batteriessettings', '\Grocy\Controllers\BatteriesController:BatteriesSettings');
$group->get('/battery/{batteryId}', '\Grocy\Controllers\BatteriesController:BatteryEditForm'); $group->get('/battery/{batteryId}/grocycode', '\Grocy\Controllers\BatteriesController:BatteryGrocycodeImage');
$group->get('/batteriessettings', '\Grocy\Controllers\BatteriesController:BatteriesSettings');
$group->get('/battery/{batteryId}/grocycode', '\Grocy\Controllers\BatteriesController:BatteryGrocycodeImage');
}
// Task routes // Task routes
if (GROCY_FEATURE_FLAG_TASKS) $group->get('/tasks', '\Grocy\Controllers\TasksController:Overview');
{ $group->get('/task/{taskId}', '\Grocy\Controllers\TasksController:TaskEditForm');
$group->get('/tasks', '\Grocy\Controllers\TasksController:Overview'); $group->get('/taskcategories', '\Grocy\Controllers\TasksController:TaskCategoriesList');
$group->get('/task/{taskId}', '\Grocy\Controllers\TasksController:TaskEditForm'); $group->get('/taskcategory/{categoryId}', '\Grocy\Controllers\TasksController:TaskCategoryEditForm');
$group->get('/taskcategories', '\Grocy\Controllers\TasksController:TaskCategoriesList'); $group->get('/taskssettings', '\Grocy\Controllers\TasksController:TasksSettings');
$group->get('/taskcategory/{categoryId}', '\Grocy\Controllers\TasksController:TaskCategoryEditForm');
$group->get('/taskssettings', '\Grocy\Controllers\TasksController:TasksSettings');
}
// Equipment routes // Equipment routes
if (GROCY_FEATURE_FLAG_EQUIPMENT) $group->get('/equipment', '\Grocy\Controllers\EquipmentController:Overview');
{ $group->get('/equipment/{equipmentId}', '\Grocy\Controllers\EquipmentController:EditForm');
$group->get('/equipment', '\Grocy\Controllers\EquipmentController:Overview');
$group->get('/equipment/{equipmentId}', '\Grocy\Controllers\EquipmentController:EditForm');
}
// Calendar routes // Calendar routes
if (GROCY_FEATURE_FLAG_CALENDAR) $group->get('/calendar', '\Grocy\Controllers\CalendarController:Overview');
{
$group->get('/calendar', '\Grocy\Controllers\CalendarController:Overview');
}
// OpenAPI routes // OpenAPI routes
$group->get('/api', '\Grocy\Controllers\OpenApiController:DocumentationUi'); $group->get('/api', '\Grocy\Controllers\OpenApiController:DocumentationUi');