Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Build
run: cargo build --verbose
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Set up Ruby and FPM
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Set up Ruby and FPM
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-openapi-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0

Expand Down
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ sqlx = { version = "0.8", features = [
"sqlite",
"chrono",
] }
rndc = "0.1.3"
rndc = "0.1.4"
rand = "0.9"
sha2 = "0.10"
hex = "0.4"
thiserror = "2.0.17"

[dev-dependencies]
tempfile = "3.21.0"
Expand Down
1 change: 1 addition & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"baseBranches": [
"develop"
],
"automerge": true,
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling automerge for Renovate will automatically merge dependency updates without manual review. While this can speed up dependency management, it may introduce breaking changes or bugs from updated dependencies. Consider whether this aligns with your project's risk tolerance and testing strategy. You may want to limit automerge to specific types of updates (e.g., only patch versions) using additional configuration.

Suggested change
"automerge": true,
"automerge": false,

Copilot uses AI. Check for mistakes.
"packageRules": [
{
"matchPackagePatterns": [
Expand Down
35 changes: 10 additions & 25 deletions src/api/controller/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ impl RecordController {

let raw_records = match RecordService::get_records(zone_id).await {
Ok(records) => records,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
}
Err(err) => return err.into_response(),
};

let records = raw_records
Expand All @@ -42,39 +39,33 @@ impl RecordController {
.collect::<Vec<GetRecordResponse>>();

let json_body = json!({ "records": records });
(StatusCode::OK, Json(json_body))
(StatusCode::OK, Json(json_body)).into_response()
}

async fn get_record(Path(params): Path<GetRecordParam>) -> impl IntoResponse {
let record_id = params.id;

let raw_record = match RecordService::get_record(record_id).await {
Ok(record) => record,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
}
Err(err) => return err.into_response(),
};

let record = GetRecordResponse::from_record(&raw_record);

let json_body = json!({ "record": record });
(StatusCode::OK, Json(json_body))
(StatusCode::OK, Json(json_body)).into_response()
}

async fn create_record(JsonBody(body): JsonBody<CreateRecordRequest>) -> impl IntoResponse {
let raw_record = match RecordService::create_record(&body).await {
Ok(record) => record,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
}
Err(err) => return err.into_response(),
};

let record = GetRecordResponse::from_record(&raw_record);

let json_body = json!({ "record": record });
(StatusCode::CREATED, Json(json_body))
(StatusCode::CREATED, Json(json_body)).into_response()
}

async fn update_record(
Expand All @@ -85,16 +76,13 @@ impl RecordController {

let raw_record = match RecordService::update_record(record_id, &body).await {
Ok(record) => record,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
}
Err(err) => return err.into_response(),
};

let record = GetRecordResponse::from_record(&raw_record);

let json_body = json!({ "record": record });
(StatusCode::OK, Json(json_body))
(StatusCode::OK, Json(json_body)).into_response()
}

async fn delete_record(Path(params): Path<DeleteRecordParam>) -> impl IntoResponse {
Expand All @@ -103,12 +91,9 @@ impl RecordController {
match RecordService::delete_record(record_id).await {
Ok(_) => {
let json_body = json!({ "message": "Record deleted successfully" });
(StatusCode::OK, Json(json_body))
}
Err(err) => {
let json_body = json!({ "error": err });
(StatusCode::BAD_REQUEST, Json(json_body))
(StatusCode::OK, Json(json_body)).into_response()
}
Err(err) => err.into_response(),
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions src/api/controller/record_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ impl RecordHistoryController {
let raw_record_histories = match RecordHistoryService::get_record_histories(record_id).await
{
Ok(record_histories) => record_histories,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
}
Err(err) => return err.into_response(),
};

let record_histories = raw_record_histories
Expand All @@ -39,7 +36,7 @@ impl RecordHistoryController {
.collect::<Vec<GetRecordHistoryResponse>>();

let json_body = json!({ "record_histories": record_histories });
(StatusCode::OK, Json(json_body))
(StatusCode::OK, Json(json_body)).into_response()
}

async fn delete_record_history(
Expand All @@ -50,12 +47,9 @@ impl RecordHistoryController {
match RecordHistoryService::delete_record_history(history_id).await {
Ok(_) => {
let json_body = json!({ "message": "Record history deleted successfully" });
(StatusCode::OK, Json(json_body))
}
Err(err) => {
let json_body = json!({ "error": err });
(StatusCode::BAD_REQUEST, Json(json_body))
(StatusCode::OK, Json(json_body)).into_response()
}
Err(err) => err.into_response(),
}
}
}
Expand Down
89 changes: 31 additions & 58 deletions src/api/controller/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,17 @@ impl ZoneController {
}

async fn get_zones() -> impl IntoResponse {
let raw_zones = match ZoneService::get_zones().await {
Ok(zones) => zones,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
match ZoneService::get_zones().await {
Ok(zones) => {
let zones = zones
.iter()
.map(GetZoneResponse::from_zone)
.collect::<Vec<GetZoneResponse>>();
let json_body = json!({ "zones": zones });
(StatusCode::OK, Json(json_body)).into_response()
}
};

let zones = raw_zones
.iter()
.map(GetZoneResponse::from_zone)
.collect::<Vec<GetZoneResponse>>();

let json_body = json!({ "zones": zones });
(StatusCode::OK, Json(json_body))
Err(err) => err.into_response(),
}
}

async fn get_zone(
Expand All @@ -60,19 +56,13 @@ impl ZoneController {

let raw_zone = match ZoneService::get_zone(zone_id).await {
Ok(zone) => zone,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
}
Err(err) => return err.into_response(),
};

let raw_records = match records_query {
Some(true) => match RecordService::get_records(Some(zone_id)).await {
Ok(records) => records,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
}
Err(err) => return err.into_response(),
},
_ => vec![],
};
Expand All @@ -83,26 +73,20 @@ impl ZoneController {

let zone = GetZoneResponse::from_zone(&raw_zone);
let json_body = json!({ "zone": zone, "records": records });
(StatusCode::OK, Json(json_body))
(StatusCode::OK, Json(json_body)).into_response()
}

async fn get_zone_rendered(Path(params): Path<GetZoneParam>) -> impl IntoResponse {
let zone_id = params.id;

let raw_zone = match ZoneService::get_zone(zone_id).await {
Ok(zone) => zone,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body)).into_response();
}
Err(err) => return err.into_response(),
};

let raw_records = match RecordService::get_records(Some(zone_id)).await {
Ok(records) => records,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body)).into_response();
}
Err(err) => return err.into_response(),
};

let zone_str = Serializer::serialize_zone(&raw_zone, &raw_records);
Expand All @@ -115,18 +99,14 @@ impl ZoneController {
}

async fn create_zone(JsonBody(body): JsonBody<CreateZoneRequest>) -> impl IntoResponse {
let raw_zone = match ZoneService::create_zone(&body).await {
Ok(zone) => zone,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
match ZoneService::create_zone(&body).await {
Ok(zone) => {
let zone = GetZoneResponse::from_zone(&zone);
let json_body = json!({ "zone": zone });
(StatusCode::CREATED, Json(json_body)).into_response()
}
};

let zone = GetZoneResponse::from_zone(&raw_zone);

let json_body = json!({ "zone": zone });
(StatusCode::CREATED, Json(json_body))
Err(err) => err.into_response(),
}
}

async fn update_zone(
Expand All @@ -135,18 +115,14 @@ impl ZoneController {
) -> impl IntoResponse {
let zone_id = params.id;

let raw_zone = match ZoneService::update_zone(zone_id, &body).await {
Ok(zone) => zone,
Err(err) => {
let json_body = json!({ "error": err });
return (StatusCode::BAD_REQUEST, Json(json_body));
match ZoneService::update_zone(zone_id, &body).await {
Ok(zone) => {
let zone = GetZoneResponse::from_zone(&zone);
let json_body = json!({ "zone": zone });
(StatusCode::OK, Json(json_body)).into_response()
}
};

let zone = GetZoneResponse::from_zone(&raw_zone);

let json_body = json!({ "zone": zone });
(StatusCode::OK, Json(json_body))
Err(err) => err.into_response(),
}
}

async fn delete_zone(Path(params): Path<DeleteZoneParam>) -> impl IntoResponse {
Expand All @@ -155,12 +131,9 @@ impl ZoneController {
match ZoneService::delete_zone(zone_id).await {
Ok(_) => {
let json_body = json!({ "message": "Zone deleted successfully" });
(StatusCode::OK, Json(json_body))
}
Err(err) => {
let json_body = json!({ "error": format!("Failed to delete zone: {}", err) });
(StatusCode::BAD_REQUEST, Json(json_body))
(StatusCode::OK, Json(json_body)).into_response()
}
Err(err) => err.into_response(),
}
}
}
Expand Down
Loading
Loading