mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 22:04:56 +00:00
docs: dbal,cpp,role (5 files)
This commit is contained in:
38
dbal/cpp/src/daemon/server_helpers/role.cpp
Normal file
38
dbal/cpp/src/daemon/server_helpers/role.cpp
Normal 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
|
||||
17
dbal/cpp/src/daemon/server_helpers/role.hpp
Normal file
17
dbal/cpp/src/daemon/server_helpers/role.hpp
Normal 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
|
||||
22
dbal/cpp/src/daemon/server_helpers/serialization.hpp
Normal file
22
dbal/cpp/src/daemon/server_helpers/serialization.hpp
Normal 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
13
frontends/dbal/README.md
Normal 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/*`.
|
||||
6
frontends/dbal/app/api/status/route.ts
Normal file
6
frontends/dbal/app/api/status/route.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { getStatusResponse } from '@/status'
|
||||
|
||||
export function GET() {
|
||||
return NextResponse.json(getStatusResponse())
|
||||
}
|
||||
Reference in New Issue
Block a user