mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
refactor: update JSON usage to use scoped Json namespace
This commit is contained in:
@@ -149,7 +149,7 @@ void handleRestfulRequest(
|
||||
Client& client,
|
||||
const RouteInfo& route,
|
||||
const std::string& method,
|
||||
const Json::Value& body,
|
||||
const ::Json::Value& body,
|
||||
const std::map<std::string, std::string>& query,
|
||||
ResponseSender send_success,
|
||||
ErrorSender send_error
|
||||
@@ -211,9 +211,9 @@ void handleRestfulRequest(
|
||||
}
|
||||
|
||||
if (operation == "list") {
|
||||
Json::Value options(Json::objectValue);
|
||||
Json::Value filter(Json::objectValue);
|
||||
Json::Value sort(Json::objectValue);
|
||||
::Json::Value options(::Json::objectValue);
|
||||
::Json::Value filter(::Json::objectValue);
|
||||
::Json::Value sort(::Json::objectValue);
|
||||
|
||||
bool limit_set = false;
|
||||
bool page_set = false;
|
||||
|
||||
@@ -66,7 +66,7 @@ std::string toPascalCase(const std::string& snake_case);
|
||||
*/
|
||||
std::string toLower(const std::string& str);
|
||||
|
||||
using ResponseSender = std::function<void(const Json::Value&)>;
|
||||
using ResponseSender = std::function<void(const ::Json::Value&)>;
|
||||
using ErrorSender = std::function<void(const std::string&, int)>;
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ void handleRestfulRequest(
|
||||
Client& client,
|
||||
const RouteInfo& route,
|
||||
const std::string& method,
|
||||
const Json::Value& body,
|
||||
const ::Json::Value& body,
|
||||
const std::map<std::string, std::string>& query,
|
||||
ResponseSender send_success,
|
||||
ErrorSender send_error
|
||||
|
||||
@@ -19,30 +19,30 @@ namespace {
|
||||
/**
|
||||
* @brief Load schema registry from JSON file
|
||||
*/
|
||||
Json::Value load_registry(const std::string& path) {
|
||||
Json::Value registry;
|
||||
::Json::Value load_registry(const std::string& path) {
|
||||
::Json::Value registry;
|
||||
|
||||
if (!fs::exists(path)) {
|
||||
registry["version"] = "1.0.0";
|
||||
registry["packages"] = Json::Value(Json::objectValue);
|
||||
registry["migrationQueue"] = Json::Value(Json::arrayValue);
|
||||
registry["packages"] = ::Json::Value(::Json::objectValue);
|
||||
registry["migrationQueue"] = ::Json::Value(::Json::arrayValue);
|
||||
return registry;
|
||||
}
|
||||
|
||||
std::ifstream file(path);
|
||||
if (!file.is_open()) {
|
||||
registry["version"] = "1.0.0";
|
||||
registry["packages"] = Json::Value(Json::objectValue);
|
||||
registry["migrationQueue"] = Json::Value(Json::arrayValue);
|
||||
registry["packages"] = ::Json::Value(::Json::objectValue);
|
||||
registry["migrationQueue"] = ::Json::Value(::Json::arrayValue);
|
||||
return registry;
|
||||
}
|
||||
|
||||
Json::CharReaderBuilder reader;
|
||||
::Json::CharReaderBuilder reader;
|
||||
JSONCPP_STRING errs;
|
||||
if (!Json::parseFromStream(reader, file, ®istry, &errs)) {
|
||||
if (!::Json::parseFromStream(reader, file, ®istry, &errs)) {
|
||||
registry["version"] = "1.0.0";
|
||||
registry["packages"] = Json::Value(Json::objectValue);
|
||||
registry["migrationQueue"] = Json::Value(Json::arrayValue);
|
||||
registry["packages"] = ::Json::Value(::Json::objectValue);
|
||||
registry["migrationQueue"] = ::Json::Value(::Json::arrayValue);
|
||||
}
|
||||
|
||||
return registry;
|
||||
@@ -51,15 +51,15 @@ Json::Value load_registry(const std::string& path) {
|
||||
/**
|
||||
* @brief Save schema registry to JSON file
|
||||
*/
|
||||
bool save_registry(const Json::Value& registry, const std::string& path) {
|
||||
bool save_registry(const ::Json::Value& registry, const std::string& path) {
|
||||
std::ofstream file(path);
|
||||
if (!file.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Json::StreamWriterBuilder writer;
|
||||
::Json::StreamWriterBuilder writer;
|
||||
writer["indentation"] = " ";
|
||||
std::unique_ptr<Json::StreamWriter> stream_writer(writer.newStreamWriter());
|
||||
std::unique_ptr<::Json::StreamWriter> stream_writer(writer.newStreamWriter());
|
||||
stream_writer->write(registry, &file);
|
||||
return true;
|
||||
}
|
||||
@@ -122,8 +122,8 @@ std::string get_table_name(const std::string& packageId, const std::string& enti
|
||||
/**
|
||||
* @brief Get pending migrations from registry
|
||||
*/
|
||||
Json::Value get_pending_migrations(const Json::Value& registry) {
|
||||
Json::Value pending(Json::arrayValue);
|
||||
::Json::Value get_pending_migrations(const ::Json::Value& registry) {
|
||||
::Json::Value pending(::Json::arrayValue);
|
||||
|
||||
const auto& queue = registry["migrationQueue"];
|
||||
for (const auto& migration : queue) {
|
||||
@@ -138,8 +138,8 @@ Json::Value get_pending_migrations(const Json::Value& registry) {
|
||||
/**
|
||||
* @brief Get approved migrations from registry
|
||||
*/
|
||||
Json::Value get_approved_migrations(const Json::Value& registry) {
|
||||
Json::Value approved(Json::arrayValue);
|
||||
::Json::Value get_approved_migrations(const ::Json::Value& registry) {
|
||||
::Json::Value approved(::Json::arrayValue);
|
||||
|
||||
const auto& queue = registry["migrationQueue"];
|
||||
for (const auto& migration : queue) {
|
||||
@@ -168,7 +168,7 @@ std::string yaml_type_to_prisma(const std::string& yaml_type) {
|
||||
/**
|
||||
* @brief Generate Prisma model for an entity
|
||||
*/
|
||||
std::string entity_to_prisma(const Json::Value& entity, const std::string& packageId) {
|
||||
std::string entity_to_prisma(const ::Json::Value& entity, const std::string& packageId) {
|
||||
const std::string name = entity["name"].asString();
|
||||
const std::string prefixed = get_prefixed_name(packageId, name);
|
||||
const std::string table = get_table_name(packageId, name);
|
||||
@@ -218,7 +218,7 @@ void handle_schema_list(const std::string& registry_path,
|
||||
auto registry = load_registry(registry_path);
|
||||
auto pending = get_pending_migrations(registry);
|
||||
|
||||
Json::Value response;
|
||||
::Json::Value response;
|
||||
response["status"] = "ok";
|
||||
response["pendingCount"] = pending.size();
|
||||
response["migrations"] = pending;
|
||||
@@ -239,7 +239,7 @@ void handle_schema_scan(const std::string& registry_path,
|
||||
|
||||
int scanned = 0;
|
||||
int queued = 0;
|
||||
Json::Value errors(Json::arrayValue);
|
||||
::Json::Value errors(::Json::arrayValue);
|
||||
|
||||
if (!fs::exists(packages_path)) {
|
||||
send_error("Packages directory not found: " + packages_path, 404);
|
||||
@@ -263,7 +263,7 @@ void handle_schema_scan(const std::string& registry_path,
|
||||
|
||||
save_registry(registry, registry_path);
|
||||
|
||||
Json::Value response;
|
||||
::Json::Value response;
|
||||
response["status"] = "ok";
|
||||
response["action"] = "scan";
|
||||
response["packagesScanned"] = scanned;
|
||||
@@ -307,7 +307,7 @@ void handle_schema_approve(const std::string& registry_path,
|
||||
|
||||
save_registry(registry, registry_path);
|
||||
|
||||
Json::Value response;
|
||||
::Json::Value response;
|
||||
response["status"] = "ok";
|
||||
response["action"] = "approve";
|
||||
response["approved"] = approved_count;
|
||||
@@ -344,7 +344,7 @@ void handle_schema_reject(const std::string& registry_path,
|
||||
|
||||
save_registry(registry, registry_path);
|
||||
|
||||
Json::Value response;
|
||||
::Json::Value response;
|
||||
response["status"] = "ok";
|
||||
response["action"] = "reject";
|
||||
response["id"] = id;
|
||||
@@ -365,7 +365,7 @@ void handle_schema_generate(const std::string& registry_path,
|
||||
auto approved = get_approved_migrations(registry);
|
||||
|
||||
if (approved.empty()) {
|
||||
Json::Value response;
|
||||
::Json::Value response;
|
||||
response["status"] = "ok";
|
||||
response["action"] = "generate";
|
||||
response["generated"] = false;
|
||||
@@ -398,7 +398,7 @@ void handle_schema_generate(const std::string& registry_path,
|
||||
out << oss.str();
|
||||
out.close();
|
||||
|
||||
Json::Value response;
|
||||
::Json::Value response;
|
||||
response["status"] = "ok";
|
||||
response["action"] = "generate";
|
||||
response["generated"] = true;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace dbal {
|
||||
namespace daemon {
|
||||
namespace rpc {
|
||||
|
||||
using ResponseSender = std::function<void(const Json::Value&)>;
|
||||
using ResponseSender = std::function<void(const ::Json::Value&)>;
|
||||
using ErrorSender = std::function<void(const std::string&, int)>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace rpc {
|
||||
|
||||
void handle_user_list(Client& client,
|
||||
const std::string& tenantId,
|
||||
const Json::Value& options,
|
||||
const ::Json::Value& options,
|
||||
ResponseSender send_success,
|
||||
ErrorSender send_error) {
|
||||
if (tenantId.empty()) {
|
||||
@@ -57,7 +57,7 @@ void handle_user_read(Client& client,
|
||||
|
||||
void handle_user_create(Client& client,
|
||||
const std::string& tenantId,
|
||||
const Json::Value& payload,
|
||||
const ::Json::Value& payload,
|
||||
ResponseSender send_success,
|
||||
ErrorSender send_error) {
|
||||
if (tenantId.empty()) {
|
||||
@@ -92,7 +92,7 @@ void handle_user_create(Client& client,
|
||||
void handle_user_update(Client& client,
|
||||
const std::string& tenantId,
|
||||
const std::string& id,
|
||||
const Json::Value& payload,
|
||||
const ::Json::Value& payload,
|
||||
ResponseSender send_success,
|
||||
ErrorSender send_error) {
|
||||
if (tenantId.empty()) {
|
||||
@@ -177,7 +177,7 @@ void handle_user_delete(Client& client,
|
||||
return;
|
||||
}
|
||||
|
||||
Json::Value body;
|
||||
::Json::Value body;
|
||||
body["deleted"] = result.value();
|
||||
send_success(body);
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace dbal {
|
||||
namespace daemon {
|
||||
namespace rpc {
|
||||
|
||||
using ResponseSender = std::function<void(const Json::Value&)>;
|
||||
using ResponseSender = std::function<void(const ::Json::Value&)>;
|
||||
using ErrorSender = std::function<void(const std::string&, int)>;
|
||||
|
||||
void handle_user_list(Client& client,
|
||||
const std::string& tenantId,
|
||||
const Json::Value& options,
|
||||
const ::Json::Value& options,
|
||||
ResponseSender send_success,
|
||||
ErrorSender send_error);
|
||||
|
||||
@@ -27,14 +27,14 @@ void handle_user_read(Client& client,
|
||||
|
||||
void handle_user_create(Client& client,
|
||||
const std::string& tenantId,
|
||||
const Json::Value& payload,
|
||||
const ::Json::Value& payload,
|
||||
ResponseSender send_success,
|
||||
ErrorSender send_error);
|
||||
|
||||
void handle_user_update(Client& client,
|
||||
const std::string& tenantId,
|
||||
const std::string& id,
|
||||
const Json::Value& payload,
|
||||
const ::Json::Value& payload,
|
||||
ResponseSender send_success,
|
||||
ErrorSender send_error);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace dbal {
|
||||
namespace daemon {
|
||||
|
||||
drogon::HttpResponsePtr build_json_response(const Json::Value& body) {
|
||||
drogon::HttpResponsePtr build_json_response(const ::Json::Value& body) {
|
||||
auto response = drogon::HttpResponse::newHttpJsonResponse(body);
|
||||
response->addHeader("Server", "DBAL/1.0.0");
|
||||
return response;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
namespace dbal {
|
||||
namespace daemon {
|
||||
|
||||
drogon::HttpResponsePtr build_json_response(const Json::Value& body);
|
||||
drogon::HttpResponsePtr build_json_response(const ::Json::Value& body);
|
||||
|
||||
} // namespace daemon
|
||||
} // namespace dbal
|
||||
|
||||
@@ -10,14 +10,14 @@ long long timestamp_to_epoch_ms(const Timestamp& timestamp) {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(timestamp.time_since_epoch()).count();
|
||||
}
|
||||
|
||||
Json::Value user_to_json(const User& user) {
|
||||
Json::Value value(Json::objectValue);
|
||||
::Json::Value user_to_json(const User& user) {
|
||||
::Json::Value value(::Json::objectValue);
|
||||
value["id"] = user.id;
|
||||
value["tenantId"] = user.tenantId.value_or("");
|
||||
value["username"] = user.username;
|
||||
value["email"] = user.email;
|
||||
value["role"] = user.role;
|
||||
value["createdAt"] = static_cast<Json::Int64>(timestamp_to_epoch_ms(user.createdAt));
|
||||
value["createdAt"] = static_cast<::Json::Int64>(timestamp_to_epoch_ms(user.createdAt));
|
||||
if (user.profilePicture.has_value()) {
|
||||
value["profilePicture"] = user.profilePicture.value();
|
||||
}
|
||||
@@ -27,21 +27,21 @@ Json::Value user_to_json(const User& user) {
|
||||
value["isInstanceOwner"] = user.isInstanceOwner;
|
||||
if (user.passwordChangeTimestamp.has_value()) {
|
||||
value["passwordChangeTimestamp"] =
|
||||
static_cast<Json::Int64>(timestamp_to_epoch_ms(user.passwordChangeTimestamp.value()));
|
||||
static_cast<::Json::Int64>(timestamp_to_epoch_ms(user.passwordChangeTimestamp.value()));
|
||||
}
|
||||
value["firstLogin"] = user.firstLogin;
|
||||
return value;
|
||||
}
|
||||
|
||||
Json::Value users_to_json(const std::vector<User>& users) {
|
||||
Json::Value arr(Json::arrayValue);
|
||||
::Json::Value users_to_json(const std::vector<User>& users) {
|
||||
::Json::Value arr(::Json::arrayValue);
|
||||
for (const auto& user : users) {
|
||||
arr.append(user_to_json(user));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
ListOptions list_options_from_json(const Json::Value& json) {
|
||||
ListOptions list_options_from_json(const ::Json::Value& json) {
|
||||
ListOptions options;
|
||||
if (!json.isNull()) {
|
||||
if (json.isMember("page") && json["page"].isInt()) {
|
||||
@@ -64,13 +64,13 @@ ListOptions list_options_from_json(const Json::Value& json) {
|
||||
return options;
|
||||
}
|
||||
|
||||
Json::Value list_response_value(const std::vector<User>& users, const ListOptions& options) {
|
||||
Json::Value value(Json::objectValue);
|
||||
::Json::Value list_response_value(const std::vector<User>& users, const ListOptions& options) {
|
||||
::Json::Value value(::Json::objectValue);
|
||||
value["data"] = users_to_json(users);
|
||||
value["total"] = static_cast<Json::Int64>(users.size());
|
||||
value["total"] = static_cast<::Json::Int64>(users.size());
|
||||
value["page"] = options.page;
|
||||
value["limit"] = options.limit;
|
||||
value["hasMore"] = Json::Value(false);
|
||||
value["hasMore"] = ::Json::Value(false);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ 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);
|
||||
::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);
|
||||
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
|
||||
|
||||
@@ -25,7 +25,7 @@ void Server::registerRoutes() {
|
||||
|
||||
auto health_handler = [](const drogon::HttpRequestPtr&,
|
||||
std::function<void(const drogon::HttpResponsePtr&)>&& callback) {
|
||||
Json::Value body;
|
||||
::Json::Value body;
|
||||
body["status"] = "healthy";
|
||||
body["service"] = "dbal";
|
||||
callback(build_json_response(body));
|
||||
@@ -33,7 +33,7 @@ void Server::registerRoutes() {
|
||||
|
||||
auto version_handler = [](const drogon::HttpRequestPtr&,
|
||||
std::function<void(const drogon::HttpResponsePtr&)>&& callback) {
|
||||
Json::Value body;
|
||||
::Json::Value body;
|
||||
body["version"] = "1.0.0";
|
||||
body["service"] = "DBAL Daemon";
|
||||
callback(build_json_response(body));
|
||||
@@ -41,7 +41,7 @@ void Server::registerRoutes() {
|
||||
|
||||
auto status_handler = [server_address](const drogon::HttpRequestPtr& request,
|
||||
std::function<void(const drogon::HttpResponsePtr&)>&& callback) {
|
||||
Json::Value body;
|
||||
::Json::Value body;
|
||||
body["status"] = "running";
|
||||
body["address"] = server_address;
|
||||
body["real_ip"] = resolve_real_ip(request);
|
||||
@@ -52,7 +52,7 @@ void Server::registerRoutes() {
|
||||
auto rpc_handler = [this](const drogon::HttpRequestPtr& request,
|
||||
std::function<void(const drogon::HttpResponsePtr&)>&& callback) {
|
||||
auto send_error = [&callback](const std::string& message, int status = 400) {
|
||||
Json::Value body;
|
||||
::Json::Value body;
|
||||
body["success"] = false;
|
||||
body["message"] = message;
|
||||
auto response = drogon::HttpResponse::newHttpJsonResponse(body);
|
||||
@@ -61,10 +61,10 @@ void Server::registerRoutes() {
|
||||
};
|
||||
|
||||
std::istringstream stream(request->getBody());
|
||||
Json::CharReaderBuilder reader_builder;
|
||||
Json::Value rpc_request;
|
||||
::Json::CharReaderBuilder reader_builder;
|
||||
::Json::Value rpc_request;
|
||||
JSONCPP_STRING errs;
|
||||
if (!Json::parseFromStream(reader_builder, stream, &rpc_request, &errs)) {
|
||||
if (!::Json::parseFromStream(reader_builder, stream, &rpc_request, &errs)) {
|
||||
send_error("Invalid JSON payload: " + std::string(errs), 400);
|
||||
return;
|
||||
}
|
||||
@@ -87,12 +87,12 @@ void Server::registerRoutes() {
|
||||
std::transform(action.begin(), action.end(), action.begin(),
|
||||
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||
|
||||
const auto payload = rpc_request.get("payload", Json::Value(Json::objectValue));
|
||||
const auto options_value = rpc_request.get("options", Json::Value(Json::objectValue));
|
||||
const auto payload = rpc_request.get("payload", ::Json::Value(::Json::objectValue));
|
||||
const auto options_value = rpc_request.get("options", ::Json::Value(::Json::objectValue));
|
||||
const std::string tenantId = rpc_request.get("tenantId", payload.get("tenantId", "")).asString();
|
||||
|
||||
auto send_success = [&callback](const Json::Value& data) {
|
||||
Json::Value body;
|
||||
auto send_success = [&callback](const ::Json::Value& data) {
|
||||
::Json::Value body;
|
||||
body["success"] = true;
|
||||
body["data"] = data;
|
||||
callback(build_json_response(body));
|
||||
@@ -161,12 +161,12 @@ void Server::registerRoutes() {
|
||||
const std::string packages_path = env_packages ? env_packages : "/app/packages";
|
||||
const std::string output_path = env_output ? env_output : "/app/prisma/generated-from-packages.prisma";
|
||||
|
||||
auto send_success = [&callback](const Json::Value& data) {
|
||||
auto send_success = [&callback](const ::Json::Value& data) {
|
||||
callback(build_json_response(data));
|
||||
};
|
||||
|
||||
auto send_error = [&callback](const std::string& message, int status) {
|
||||
Json::Value body;
|
||||
::Json::Value body;
|
||||
body["success"] = false;
|
||||
body["error"] = message;
|
||||
auto response = drogon::HttpResponse::newHttpJsonResponse(body);
|
||||
@@ -182,10 +182,10 @@ void Server::registerRoutes() {
|
||||
|
||||
// Handle POST - actions
|
||||
std::istringstream stream(request->getBody());
|
||||
Json::CharReaderBuilder reader_builder;
|
||||
Json::Value body;
|
||||
::Json::CharReaderBuilder reader_builder;
|
||||
::Json::Value body;
|
||||
JSONCPP_STRING errs;
|
||||
if (!Json::parseFromStream(reader_builder, stream, &body, &errs)) {
|
||||
if (!::Json::parseFromStream(reader_builder, stream, &body, &errs)) {
|
||||
send_error("Invalid JSON payload", 400);
|
||||
return;
|
||||
}
|
||||
@@ -224,15 +224,15 @@ void Server::registerRoutes() {
|
||||
const std::string& tenant,
|
||||
const std::string& package,
|
||||
const std::string& entity) {
|
||||
auto send_success = [&callback](const Json::Value& data) {
|
||||
Json::Value body;
|
||||
auto send_success = [&callback](const ::Json::Value& data) {
|
||||
::Json::Value body;
|
||||
body["success"] = true;
|
||||
body["data"] = data;
|
||||
callback(build_json_response(body));
|
||||
};
|
||||
|
||||
auto send_error = [&callback](const std::string& message, int status) {
|
||||
Json::Value body;
|
||||
::Json::Value body;
|
||||
body["success"] = false;
|
||||
body["error"] = message;
|
||||
auto response = drogon::HttpResponse::newHttpJsonResponse(body);
|
||||
@@ -263,12 +263,12 @@ void Server::registerRoutes() {
|
||||
}
|
||||
|
||||
// Parse body for POST/PUT/PATCH
|
||||
Json::Value body(Json::objectValue);
|
||||
::Json::Value body(::Json::objectValue);
|
||||
if (method == "POST" || method == "PUT" || method == "PATCH") {
|
||||
std::istringstream stream(request->getBody());
|
||||
Json::CharReaderBuilder reader;
|
||||
::Json::CharReaderBuilder reader;
|
||||
JSONCPP_STRING errs;
|
||||
Json::parseFromStream(reader, stream, &body, &errs);
|
||||
::Json::parseFromStream(reader, stream, &body, &errs);
|
||||
}
|
||||
|
||||
// Parse query parameters
|
||||
@@ -287,15 +287,15 @@ void Server::registerRoutes() {
|
||||
const std::string& package,
|
||||
const std::string& entity,
|
||||
const std::string& id) {
|
||||
auto send_success = [&callback](const Json::Value& data) {
|
||||
Json::Value body;
|
||||
auto send_success = [&callback](const ::Json::Value& data) {
|
||||
::Json::Value body;
|
||||
body["success"] = true;
|
||||
body["data"] = data;
|
||||
callback(build_json_response(body));
|
||||
};
|
||||
|
||||
auto send_error = [&callback](const std::string& message, int status) {
|
||||
Json::Value body;
|
||||
::Json::Value body;
|
||||
body["success"] = false;
|
||||
body["error"] = message;
|
||||
auto response = drogon::HttpResponse::newHttpJsonResponse(body);
|
||||
@@ -321,12 +321,12 @@ void Server::registerRoutes() {
|
||||
default: method = "UNKNOWN"; break;
|
||||
}
|
||||
|
||||
Json::Value body(Json::objectValue);
|
||||
::Json::Value body(::Json::objectValue);
|
||||
if (method == "POST" || method == "PUT" || method == "PATCH") {
|
||||
std::istringstream stream(request->getBody());
|
||||
Json::CharReaderBuilder reader;
|
||||
::Json::CharReaderBuilder reader;
|
||||
JSONCPP_STRING errs;
|
||||
Json::parseFromStream(reader, stream, &body, &errs);
|
||||
::Json::parseFromStream(reader, stream, &body, &errs);
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> query;
|
||||
@@ -345,15 +345,15 @@ void Server::registerRoutes() {
|
||||
const std::string& entity,
|
||||
const std::string& id,
|
||||
const std::string& action) {
|
||||
auto send_success = [&callback](const Json::Value& data) {
|
||||
Json::Value body;
|
||||
auto send_success = [&callback](const ::Json::Value& data) {
|
||||
::Json::Value body;
|
||||
body["success"] = true;
|
||||
body["data"] = data;
|
||||
callback(build_json_response(body));
|
||||
};
|
||||
|
||||
auto send_error = [&callback](const std::string& message, int status) {
|
||||
Json::Value body;
|
||||
::Json::Value body;
|
||||
body["success"] = false;
|
||||
body["error"] = message;
|
||||
auto response = drogon::HttpResponse::newHttpJsonResponse(body);
|
||||
@@ -379,12 +379,12 @@ void Server::registerRoutes() {
|
||||
default: method = "UNKNOWN"; break;
|
||||
}
|
||||
|
||||
Json::Value body(Json::objectValue);
|
||||
::Json::Value body(::Json::objectValue);
|
||||
if (method == "POST" || method == "PUT" || method == "PATCH") {
|
||||
std::istringstream stream(request->getBody());
|
||||
Json::CharReaderBuilder reader;
|
||||
::Json::CharReaderBuilder reader;
|
||||
JSONCPP_STRING errs;
|
||||
Json::parseFromStream(reader, stream, &body, &errs);
|
||||
::Json::parseFromStream(reader, stream, &body, &errs);
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> query;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { setAppConfig } from '../../app-config'
|
||||
import { setComments } from '../../comments'
|
||||
import { setComponentConfigs, setComponentHierarchy } from '../../components'
|
||||
import { setLuaScripts } from '../../lua-scripts'
|
||||
import { setPages } from '../../pages'
|
||||
import { setSchemas } from '../../schemas'
|
||||
import type { DatabaseSchema } from '../../types'
|
||||
@@ -17,7 +16,6 @@ export async function importDatabase(jsonData: string): Promise<void> {
|
||||
|
||||
if (data.users !== undefined) await setUsers(data.users)
|
||||
if (data.workflows !== undefined) await setWorkflows(data.workflows)
|
||||
if (data.luaScripts !== undefined) await setLuaScripts(data.luaScripts)
|
||||
if (data.pages !== undefined) await setPages(data.pages)
|
||||
if (data.schemas !== undefined) await setSchemas(data.schemas)
|
||||
if (data.appConfig !== undefined) await setAppConfig(data.appConfig)
|
||||
|
||||
Reference in New Issue
Block a user