router(); $template = $app->template(); $auth = $app->auth(); $translator = $app->translator(); $authController = new AuthController($template, $auth, $translator); $integrationRepository = new IntegrationRepository( $app->db(), (string) $app->config('app.integrations.secret', '') ); $appSettingsRepository = new AppSettingsRepository($app->db()); $cronJobRepository = new CronJobRepository($app->db()); $usersController = new UsersController($template, $translator, $auth, $app->users(), $integrationRepository); $marketplaceRepository = new MarketplaceRepository($app->db()); $shopProClient = new ShopProClient(); $channelOffersRepository = new ChannelOffersRepository($app->db()); $productLinksRepository = new ProductLinksRepository($app->db()); $linkMatcherService = new LinkMatcherService(); $productLinksService = new ProductLinksService( $productLinksRepository, $channelOffersRepository, $integrationRepository, $linkMatcherService, $app->db() ); $productLinksController = new ProductLinksController($translator, $auth, $productLinksService); $offerImportService = new OfferImportService($shopProClient, $channelOffersRepository, $app->db()); $productRepository = new ProductRepository($app->db()); $settingsController = new SettingsController( $template, $translator, $auth, $app->migrator(), $integrationRepository, $shopProClient, $offerImportService, $cronJobRepository, $appSettingsRepository, $productRepository, $app->db(), $app->logger() ); $productValidator = new ProductValidator(); $productService = new ProductService($app->db(), $productRepository, $productValidator); $shopProExportService = new ShopProExportService($app->db(), $productRepository, $integrationRepository, $shopProClient); $gs1Service = new GS1Service($productRepository, $appSettingsRepository); $productsController = new ProductsController( $template, $translator, $auth, $productRepository, $productService, $integrationRepository, $productLinksService, $shopProExportService, $gs1Service ); $marketplaceController = new MarketplaceController( $template, $translator, $auth, $marketplaceRepository, $integrationRepository, $shopProClient, $productRepository ); $authMiddleware = new AuthMiddleware($auth); $router->get('/health', static fn (Request $request): Response => Response::json([ 'status' => 'ok', 'app' => (string) $app->config('app.name', 'orderPRO'), 'timestamp' => date(DATE_ATOM), ])); $router->get('/', static function (Request $request) use ($auth): Response { return $auth->check() ? Response::redirect('/dashboard') : Response::redirect('/login'); }); $router->get('/login', [$authController, 'showLogin']); $router->post('/login', [$authController, 'login']); $router->post('/logout', [$authController, 'logout'], [$authMiddleware]); $router->get('/dashboard', static function (Request $request) use ($template, $auth, $translator, $integrationRepository): Response { $user = $auth->user(); $html = $template->render('dashboard/index', [ 'title' => $translator->get('dashboard.title'), 'activeMenu' => 'dashboard', 'user' => $user, 'csrfToken' => Csrf::token(), 'marketplaceIntegrations' => array_values(array_filter( $integrationRepository->listByType('shoppro'), static fn (array $row): bool => (bool) ($row['is_active'] ?? false) )), ], 'layouts/app'); return Response::html($html); }, [$authMiddleware]); $router->get('/users', [$usersController, 'index'], [$authMiddleware]); $router->post('/users', [$usersController, 'store'], [$authMiddleware]); $router->get('/products', [$productsController, 'index'], [$authMiddleware]); $router->get('/products/show', [$productsController, 'show'], [$authMiddleware]); $router->get('/products/{id}', [$productsController, 'show'], [$authMiddleware]); $router->get('/marketplace', [$marketplaceController, 'index'], [$authMiddleware]); $router->get('/marketplace/{integration_id}', [$marketplaceController, 'offers'], [$authMiddleware]); $router->get('/marketplace/{integration_id}/categories', [$marketplaceController, 'categoriesJson'], [$authMiddleware]); $router->get('/marketplace/{integration_id}/product/{external_product_id}/categories', [$marketplaceController, 'productCategoriesJson'], [$authMiddleware]); $router->post('/marketplace/{integration_id}/product/{external_product_id}/categories', [$marketplaceController, 'saveProductCategoriesJson'], [$authMiddleware]); $router->get('/products/links', [$productsController, 'links'], [$authMiddleware]); $router->get('/products/{id}/links', [$productsController, 'links'], [$authMiddleware]); $router->get('/products/{id}/links/suggestions', [$productsController, 'linkSuggestions'], [$authMiddleware]); $router->get('/products/create', [$productsController, 'create'], [$authMiddleware]); $router->post('/products', [$productsController, 'store'], [$authMiddleware]); $router->get('/products/edit', [$productsController, 'edit'], [$authMiddleware]); $router->post('/products/update', [$productsController, 'update'], [$authMiddleware]); $router->post('/products/delete', [$productsController, 'destroy'], [$authMiddleware]); $router->post('/products/images/upload', [$productsController, 'uploadImage'], [$authMiddleware]); $router->post('/products/images/set-main', [$productsController, 'setMainImage'], [$authMiddleware]); $router->post('/products/images/delete', [$productsController, 'deleteImage'], [$authMiddleware]); $router->post('/products/links/create', [$productLinksController, 'create'], [$authMiddleware]); $router->post('/products/links/relink', [$productLinksController, 'relink'], [$authMiddleware]); $router->post('/products/links/unlink', [$productLinksController, 'unlink'], [$authMiddleware]); $router->post('/products/{id}/links', [$productLinksController, 'create'], [$authMiddleware]); $router->post('/products/{id}/links/{mapId}/relink', [$productLinksController, 'relink'], [$authMiddleware]); $router->post('/products/{id}/links/{mapId}/unlink', [$productLinksController, 'unlink'], [$authMiddleware]); $router->post('/products/import/shoppro', [$settingsController, 'importProducts'], [$authMiddleware]); $router->post('/products/export/shoppro', [$productsController, 'exportShopPro'], [$authMiddleware]); $router->post('/products/{id}/assign-ean', [$productsController, 'assignGs1Ean'], [$authMiddleware]); $router->get('/settings/integrations', static fn (Request $request): Response => Response::redirect('/settings/integrations/shoppro'), [$authMiddleware]); $router->get('/settings/integrations/shoppro', [$settingsController, 'integrations'], [$authMiddleware]); $router->post('/settings/integrations/save', [$settingsController, 'saveIntegration'], [$authMiddleware]); $router->post('/settings/integrations/shoppro/save', [$settingsController, 'saveIntegration'], [$authMiddleware]); $router->post('/settings/integrations/test', [$settingsController, 'testIntegration'], [$authMiddleware]); $router->post('/settings/integrations/shoppro/test', [$settingsController, 'testIntegration'], [$authMiddleware]); $router->post('/settings/integrations/import-one-product', [$settingsController, 'importOneProduct'], [$authMiddleware]); $router->post('/settings/integrations/shoppro/import-one-product', [$settingsController, 'importOneProduct'], [$authMiddleware]); $router->post('/settings/integrations/import-offers-cache', [$settingsController, 'importOffersCache'], [$authMiddleware]); $router->post('/settings/integrations/shoppro/import-offers-cache', [$settingsController, 'importOffersCache'], [$authMiddleware]); $router->get('/settings/database', [$settingsController, 'database'], [$authMiddleware]); $router->post('/settings/database/migrate', [$settingsController, 'migrate'], [$authMiddleware]); $router->get('/settings/cron', [$settingsController, 'cron'], [$authMiddleware]); $router->post('/settings/cron/save', [$settingsController, 'saveCronSettings'], [$authMiddleware]); $router->get('/settings/gs1', [$settingsController, 'gs1'], [$authMiddleware]); $router->post('/settings/gs1/save', [$settingsController, 'gs1Save'], [$authMiddleware]); };