__DIR__ . DIRECTORY_SEPARATOR . 'compilation_cache', ]); $data = new JsonDatabase(__DIR__ . DIRECTORY_SEPARATOR . 'data'); $tor = new Tor(); $api = new Api(); $cave = new Cave(); try { // Initialize Database $data->init(); // Initialize Tor in order to register routes $tor->init(); // Initialize Tor API in order to register routes $api->init(); // Initialize CA Endpoint $cave->init(); // Handle routes $routes->handle(); } catch (RouteNotFoundException $ex) { $routes->request->status(404, "Route not found")->send(["error" => ["message" => $ex->getMessage()]]); } catch (CallbackNotFound $ex) { $routes->request->status(404, "Callback method not found")->send(["error" => ["message" => $ex->getMessage()]]); } catch (Exception $ex) { $code = $ex->getCode() ?? 500; $routes->request->status($code)->send(["error" => ["message" => $ex->getMessage()]]); } ?>