diff --git a/dbal/cpp/src/daemon/server_helpers/role.cpp b/dbal/cpp/src/daemon/server_helpers/role.cpp new file mode 100644 index 000000000..81ac58780 --- /dev/null +++ b/dbal/cpp/src/daemon/server_helpers/role.cpp @@ -0,0 +1,38 @@ +#include "server_helpers/role.hpp" + +#include + +namespace dbal { +namespace daemon { + +UserRole normalize_role(const std::string& role) { + std::string value = role; + std::transform(value.begin(), value.end(), value.begin(), + [](unsigned char c) { return static_cast(std::tolower(c)); }); + if (value == "admin") { + return UserRole::Admin; + } + if (value == "god") { + return UserRole::God; + } + if (value == "supergod") { + return UserRole::SuperGod; + } + return UserRole::User; +} + +std::string role_to_string(UserRole role) { + switch (role) { + case UserRole::Admin: + return "admin"; + case UserRole::God: + return "god"; + case UserRole::SuperGod: + return "supergod"; + default: + return "user"; + } +} + +} // namespace daemon +} // namespace dbal diff --git a/dbal/cpp/src/daemon/server_helpers/role.hpp b/dbal/cpp/src/daemon/server_helpers/role.hpp new file mode 100644 index 000000000..48bd0a58b --- /dev/null +++ b/dbal/cpp/src/daemon/server_helpers/role.hpp @@ -0,0 +1,17 @@ +#ifndef DBAL_SERVER_HELPERS_ROLE_HPP +#define DBAL_SERVER_HELPERS_ROLE_HPP + +#include + +#include "dbal/core/types.hpp" + +namespace dbal { +namespace daemon { + +UserRole normalize_role(const std::string& role); +std::string role_to_string(UserRole role); + +} // namespace daemon +} // namespace dbal + +#endif // DBAL_SERVER_HELPERS_ROLE_HPP diff --git a/dbal/cpp/src/daemon/server_helpers/serialization.hpp b/dbal/cpp/src/daemon/server_helpers/serialization.hpp new file mode 100644 index 000000000..5edc27458 --- /dev/null +++ b/dbal/cpp/src/daemon/server_helpers/serialization.hpp @@ -0,0 +1,22 @@ +#ifndef DBAL_SERVER_HELPERS_SERIALIZATION_HPP +#define DBAL_SERVER_HELPERS_SERIALIZATION_HPP + +#include +#include + +#include "dbal/core/types.hpp" + +namespace dbal { +namespace daemon { + +long long timestamp_to_epoch_ms(const Timestamp& timestamp); +Json::Value user_to_json(const User& user); +Json::Value users_to_json(const std::vector& users); + +ListOptions list_options_from_json(const Json::Value& json); +Json::Value list_response_value(const std::vector& users, const ListOptions& options); + +} // namespace daemon +} // namespace dbal + +#endif // DBAL_SERVER_HELPERS_SERIALIZATION_HPP diff --git a/frontends/dbal/README.md b/frontends/dbal/README.md new file mode 100644 index 000000000..2503f457f --- /dev/null +++ b/frontends/dbal/README.md @@ -0,0 +1,13 @@ +# DBAL Frontend + +This directory now hosts a standalone Next.js project that renders the DBAL Daemon marketing/status view and exposes the same `/api/status` endpoint used by the main workspace. + +## Getting started + +```bash +cd frontends/dbal +npm install +npm run dev +``` + +The project reuses the shared components in `src/` so the main `frontends/nextjs` app can still import `@dbal-ui/*`. diff --git a/frontends/dbal/app/api/status/route.ts b/frontends/dbal/app/api/status/route.ts new file mode 100644 index 000000000..fc759195b --- /dev/null +++ b/frontends/dbal/app/api/status/route.ts @@ -0,0 +1,6 @@ +import { NextResponse } from 'next/server' +import { getStatusResponse } from '@/status' + +export function GET() { + return NextResponse.json(getStatusResponse()) +}