feat(api): expose HTTP REST endpoints for DID resolution, mailbox relay, and health
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start in src/main.rs, where the node builds NodeConfig, MailboxStore and KeyTransparencyLog and prints a health line before exiting, then look at src/health.rs, src/merkle.rs and src/relay.rs for the data they expose. The new router belongs in src/http_server.rs, which must stay under 300 lines. Check docs/API.md for the response schemas and tests/node_test.rs for the existing tests, which must keep passing. Done means all five endpoints return the documented status codes and JSON, and fmt, clippy and test pass.
Written by the indexing model from the issue text.
Description
Part of Meta-Issue alfonsodg/sonaraim#2
Ref alfonsodg/sonaraim-node#2
Problem
src/main.rs:1-34 currently initializes NodeConfig, MailboxStore, and KeyTransparencyLog, prints a single JSON health line to stdout, and exits. It does not bind an HTTP listener on NODE_HTTP_HOST:NODE_HTTP_PORT (8040) to serve the documented REST endpoints (GET /health, POST /v1/identity, GET /v1/identity/{did}, POST /v1/relay/envelopes, GET /v1/relay/mailboxes/{mailbox_id}).
Affected Files & Locations
src/main.rs:1-34src/health.rs:1-75src/merkle.rs:42-269src/relay.rs:34-127src/http_server.rs(new HTTP server & router module, < 300 lines)tests/node_test.rs:1-167
Evidence
// src/main.rs:27-33
let health = HealthStatus::new(&config.node_id, "0.1.0", 0, log.tree_size());
println!("{}", health.to_json());
Impact and Blast Radius
sonaraim-b2b, sonaraim-admin, and sonaraim-app depend on sonaraim-node's HTTP API (8040) to register and resolve DIDs, verify Merkle inclusion proofs, publish SealedEnvelope messages, and drain recipient mailboxes.
Historical Context and Anti-Regression
Builds on e62fca0 (Issue #1). All 5 existing unit tests in tests/node_test.rs must continue passing without modification.
Proposed Solution
- Implement
src/http_server.rsexposing:GET /health->200 OKPOST /v1/identity->201 Created(registersdid:sonaraimordid:weband returns Merkle proof)GET /v1/identity/{did}->200 OK/404 Not FoundPOST /v1/relay/envelopes->202 Accepted(storesSealedEnvelopeand returnswake_up_token)GET /v1/relay/mailboxes/{mailbox_id}->200 OK(drains active envelopes for mailbox)
- Standardize error responses using
{"error": {"code": "...", "message": "..."}}.
Acceptance Criteria
- HTTP server binds to configured
NODE_HTTP_HOST:NODE_HTTP_PORT(or ephemeral port0in tests). - Every exposed endpoint and HTTP method (
GET /health,POST /v1/identity,GET /v1/identity/{did},POST /v1/relay/envelopes,GET /v1/relay/mailboxes/{mailbox_id}) is tested with valid and invalid payloads (200,201,202,400,404,405). - All files remain under 300 lines and pass
cargo fmt --check,cargo clippy -- -D warnings, andcargo test.
Validation Criteria
| Level | Applies | Test | Scenario | Pass |
|---|---|---|---|---|
| Unit | Yes | tests/node_test.rs |
Request parsing, route dispatch, error formatting | 100% pass (cargo test) |
| Integration | Yes | tests/node_test.rs |
Live TCP HTTP requests exercising all 5 endpoints and methods | Status codes and JSON bodies verified |
| Contract | Yes | docs/API.md |
Response JSON structure matches docs/API.md specification |
100% schema match |
| E2E | Yes | curl verification on Sandbox (REMOTE.md) |
Live HTTP requests against running sonaraim-node container |
HTTP 200/201/202 verified |
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from alfonsodg/sonaraim-node
-
bug(node): SigV4 presign date applies the epoch offset twice — media uploads can never validateOpenarea::node effort::s impact::medium priority::medium source::auto status::review type::bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
alfonsodg/sonaraim-node#29 · 1 comment ·
-
area::node effort::xs impact::low priority::low source::auto status::review type::docs
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
alfonsodg/sonaraim-node#28 · 1 comment ·
-
area::node effort::s impact::medium priority::low source::auto status::review type::docs
Difficulty 3/5 1-2 days Newbie friendliness 72/100
alfonsodg/sonaraim-node#27 · 1 comment ·
-
area::node effort::m impact::medium priority::medium source::user status::review type::refactor
Difficulty 1/5 Under an hour Newbie friendliness 20/100
alfonsodg/sonaraim-node#26 · 1 comment ·
-
area::node effort::m impact::high priority::medium source::auto status::review type::bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
alfonsodg/sonaraim-node#25 · 2 comments ·
All issues in alfonsodg/sonaraim-node
Similar issues
-
O-windows relnotes relnotes-needs-review relnotes-tracking-issue T-libs
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
marketing
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Maintainers usually reply within 1 day
-
num_ode_rk4_adaptive rejects atol = 0 while accepting rtol = 0 and while num_ode_dopri5 accepts bothOpenarea/ode-pde good first issue help wanted kind/contract severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Apich-Organization/rssn#383 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
Maintainers usually reply within 1 day
-
KT-2245 e2e specs that call the backend directly fall back to the developer's own Kronn on :3140Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day