docs: dbal,cpp,role (5 files)

This commit is contained in:
2025-12-26 05:48:19 +00:00
parent 3e86a0e8e7
commit 375a5f52f0
5 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
#include "server_helpers/role.hpp"
#include <algorithm>
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<char>(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

View File

@@ -0,0 +1,17 @@
#ifndef DBAL_SERVER_HELPERS_ROLE_HPP
#define DBAL_SERVER_HELPERS_ROLE_HPP
#include <string>
#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

View File

@@ -0,0 +1,22 @@
#ifndef DBAL_SERVER_HELPERS_SERIALIZATION_HPP
#define DBAL_SERVER_HELPERS_SERIALIZATION_HPP
#include <json/json.h>
#include <vector>
#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<User>& users);
ListOptions list_options_from_json(const Json::Value& json);
Json::Value list_response_value(const std::vector<User>& users, const ListOptions& options);
} // namespace daemon
} // namespace dbal
#endif // DBAL_SERVER_HELPERS_SERIALIZATION_HPP

13
frontends/dbal/README.md Normal file
View File

@@ -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/*`.

View File

@@ -0,0 +1,6 @@
import { NextResponse } from 'next/server'
import { getStatusResponse } from '@/status'
export function GET() {
return NextResponse.json(getStatusResponse())
}