Skip to content

Commit ec8336b

Browse files
committed
Merge #1957: SI-5: Deprecate rest-api-core and remove from workspace
5dda558 style(docs/packages.md): align table formatting with trailing pipes (Jose Celano) 807e3c7 docs(1943): remove stale rest-api-core references from docs/packages.md (Jose Celano) c783e84 docs(1943): address Copilot PR review comments (Jose Celano) 0f878ea fix(1943): remove stale rest-api-core references from Containerfile (Jose Celano) 0c397fa docs(skills): add use-rest-api skill for REST API usage instructions (Jose Celano) 4270f25 docs(1943): add manual verification evidence for API endpoints (Jose Celano) 00e657c feat(1943): deprecate rest-api-core and move container to rest-api-runtime-adapter (Jose Celano) e10a6a0 docs(1943): convert issue spec to folder format with ISSUE.md (Jose Celano) Pull request description: # SI-5: Deprecate `rest-api-core` and remove from workspace Closes #1943 ## Summary After SI-4 migrated the stats context to the contract-first architecture, the `rest-api-core` package became an empty shell with a single consumer (`axum-rest-api-server`). This PR: 1. Moves `TrackerHttpApiCoreContainer` (DI container) into `rest-api-runtime-adapter` 2. Removes the entire `packages/rest-api-core/` directory 3. Updates all import paths across the workspace 4. Removes workspace dependency and `deny.toml` wrapper rules 5. Removes the crate from the deployment publish workflow 6. Updates all documentation references (`AGENTS.md`, `docs/packages.md`) ## Changes ### Code Changes - **Moved** `TrackerHttpApiCoreContainer` from `rest-api-core` to `rest-api-runtime-adapter/src/container.rs` - **Updated** 7 import paths across `axum-rest-api-server` and `src/` to use `rest_api_runtime_adapter::container` - **Added** `tokio` dependency to `rest-api-runtime-adapter/Cargo.toml` (needed for the container) - **Removed** `rest-api-core` dependency from `axum-rest-api-server/Cargo.toml` and root `Cargo.toml` - **Deleted** entire `packages/rest-api-core/` directory (~1100 lines removed) - **Updated** `deny.toml` — removed `rest-api-core` from 3 wrapper rules - **Updated** `.github/workflows/deployment.yaml` — removed `cargo publish` step ### Documentation Changes - Converted issue spec to folder format (`ISSUE.md`) - Updated `AGENTS.md`, `packages/AGENTS.md`, `docs/packages.md` - Added new `use-rest-api` skill under `.github/skills/usage/` - Added manual verification evidence to the issue spec ## Verification - [x] Workspace builds cleanly (`cargo check --workspace`) - [x] Pre-commit checks pass - [x] Pre-push checks pass (full test suite incl. workspace-coupling) - [x] Manual verification: all API endpoints working correctly (stats, metrics, announce) ACKs for top commit: josecelano: ACK 5dda558 Tree-SHA512: bdad114f779b8817f0e405a615c4710ef92d7e88e9866610b64bd9bd2a08f39d77ec49880731d2a8d1f4866b649ceceda29876ed77dffa95ce23166620a490e2
2 parents 5a8e788 + 5dda558 commit ec8336b

31 files changed

Lines changed: 471 additions & 1267 deletions

File tree

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
name: use-rest-api
3+
description: Use the Torrust Tracker REST API. Covers authentication, all endpoints (stats, metrics, torrents, auth keys, whitelist), and making announce/scrape requests to verify API behaviour. Triggers on "use API", "test API", "call REST API", "query API", "API endpoint", "curl tracker", "tracker client", "announce request", or "verify API".
4+
metadata:
5+
author: torrust
6+
version: "1.0"
7+
---
8+
9+
# Use REST API
10+
11+
## Prerequisites
12+
13+
A running tracker with the REST API enabled. The default development config starts the API on port 1212:
14+
15+
```bash
16+
cargo run
17+
```
18+
19+
## Skill Links
20+
21+
This skill depends on these artifacts. If any of them change, review this skill.
22+
23+
- `share/default/config/tracker.development.sqlite3.toml`
24+
- `packages/axum-rest-api-server/src/v1/middlewares/auth.rs`
25+
- `packages/axum-rest-api-server/src/routes.rs`
26+
- `packages/axum-rest-api-server/src/v1/routes.rs`
27+
28+
Use the marker `skill-link: use-rest-api` in affected artifacts.
29+
30+
## Authentication
31+
32+
All API endpoints (except `/api/health_check`) require an access token.
33+
34+
### Header Method (preferred)
35+
36+
```bash
37+
curl -H "Authorization: Bearer MyAccessToken" http://localhost:1212/api/v1/stats
38+
```
39+
40+
### Query Parameter Method
41+
42+
```bash
43+
curl "http://localhost:1212/api/v1/stats?token=MyAccessToken"
44+
```
45+
46+
### Configuration
47+
48+
Tokens are defined in the TOML config file under `[http_api.access_tokens]`:
49+
50+
```toml
51+
[http_api.access_tokens]
52+
admin = "MyAccessToken"
53+
```
54+
55+
Every token in the map has identical permissions — the label (`admin`) is just a human-readable name.
56+
57+
## Endpoints
58+
59+
All endpoints use `http://localhost:1212` as base (default dev config).
60+
61+
### Health Check
62+
63+
| Method | Endpoint | Auth |
64+
| ------ | ------------------- | ----- |
65+
| GET | `/api/health_check` | ❌ No |
66+
67+
```bash
68+
curl -s http://localhost:1212/api/health_check
69+
```
70+
71+
### Stats
72+
73+
| Method | Endpoint | Auth |
74+
| ------ | ----------------- | ------ |
75+
| GET | `/api/v1/stats` | ✅ Yes |
76+
| GET | `/api/v1/metrics` | ✅ Yes |
77+
78+
```bash
79+
curl -s http://localhost:1212/api/v1/stats -H "Authorization: Bearer MyAccessToken"
80+
curl -s http://localhost:1212/api/v1/metrics -H "Authorization: Bearer MyAccessToken"
81+
```
82+
83+
### Auth Keys
84+
85+
| Method | Endpoint | Auth |
86+
| ------ | ------------------------------------ | ------ |
87+
| POST | `/api/v1/key/{seconds_valid_or_key}` | ✅ Yes |
88+
| DELETE | `/api/v1/key/{seconds_valid_or_key}` | ✅ Yes |
89+
| GET | `/api/v1/keys/reload` | ✅ Yes |
90+
| POST | `/api/v1/keys` | ✅ Yes |
91+
92+
### Whitelist
93+
94+
| Method | Endpoint | Auth |
95+
| ------ | ------------------------------- | ------ |
96+
| POST | `/api/v1/whitelist/{info_hash}` | ✅ Yes |
97+
| DELETE | `/api/v1/whitelist/{info_hash}` | ✅ Yes |
98+
| GET | `/api/v1/whitelist/reload` | ✅ Yes |
99+
100+
### Torrents
101+
102+
| Method | Endpoint | Auth |
103+
| ------ | ----------------------------- | ------ |
104+
| GET | `/api/v1/torrent/{info_hash}` | ✅ Yes |
105+
| GET | `/api/v1/torrents` | ✅ Yes |
106+
107+
## Making Announce Requests with the Tracker Client
108+
109+
The `tracker_client` binary can make BitTorrent announce requests to verify the tracker is working.
110+
111+
### UDP Announce
112+
113+
```bash
114+
cargo run -p torrust-tracker-client --bin tracker_client -- udp announce udp://localhost:6969/announce 0123456789abcdef0123456789abcdef01234567
115+
```
116+
117+
### HTTP Announce
118+
119+
```bash
120+
cargo run -p torrust-tracker-client --bin tracker_client -- http announce http://localhost:7070/announce 0123456789abcdef0123456789abcdef01234567
121+
```
122+
123+
### Scrape
124+
125+
```bash
126+
cargo run -p torrust-tracker-client --bin tracker_client -- udp scrape udp://localhost:6969/announce 0123456789abcdef0123456789abcdef01234567
127+
```
128+
129+
Output defaults to JSON. Use `--format text` for human-readable output.
130+
131+
## Verification Workflow
132+
133+
After making an announce request, verify the API reflects the activity:
134+
135+
1. Check stats changed:
136+
137+
```bash
138+
curl -s http://localhost:1212/api/v1/stats -H "Authorization: Bearer MyAccessToken"
139+
```
140+
141+
Expect `torrents` and `seeders` to increase.
142+
143+
2. Check metrics changed:
144+
145+
```bash
146+
curl -s http://localhost:1212/api/v1/metrics -H "Authorization: Bearer MyAccessToken"
147+
```
148+
149+
Expect protocol-specific counters to increase.
150+
151+
3. Check tracker console logs show the request was received:
152+
153+
```text
154+
active_peers_total=1 active_torrents_total=1
155+
```

.github/workflows/deployment.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ jobs:
6767
cargo publish -p torrust-tracker-axum-rest-api-server
6868
cargo publish -p torrust-tracker-axum-server
6969
cargo publish -p torrust-tracker-rest-api-client
70-
cargo publish -p torrust-tracker-rest-api-core
7170
cargo publish -p torrust-server-lib
7271
cargo publish -p torrust-tracker
7372
cargo publish -p torrust-tracker-client

AGENTS.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,27 @@ native IPv4/IPv6 support, private/whitelisted mode, and a management REST API.
6060

6161
All packages live under `packages/`. The workspace version is `3.0.0-develop`.
6262

63-
| Package | Crate Name | Prefix / Layer | Description |
64-
| --------------------------------- | ------------------------------------------------- | -------------- | --------------------------------------------- |
65-
| `axum-health-check-api-server` | `torrust-tracker-axum-health-check-api-server` | `axum-*` | Health monitoring endpoint |
66-
| `axum-http-server` | `torrust-tracker-axum-http-server` | `axum-*` | BitTorrent HTTP tracker server (BEP 3/23) |
67-
| `axum-rest-api-server` | `torrust-tracker-axum-rest-api-server` | `axum-*` | Management REST API server |
68-
| `axum-server` | `torrust-tracker-axum-server` | `axum-*` | Base Axum HTTP server infrastructure |
69-
| `configuration` | `torrust-tracker-configuration` | domain | Config file parsing, environment variables |
70-
| `events` | `torrust-tracker-events` | domain | Domain event definitions |
71-
| `http-protocol` | `torrust-tracker-http-protocol` | `*-protocol` | HTTP tracker protocol (BEP 3/23) parsing |
72-
| `http-core` | `torrust-tracker-http-core` | `*-core` | HTTP-specific tracker domain logic |
73-
| `primitives` | `torrust-tracker-primitives` | domain | Core domain types (InfoHash, PeerId, ...) |
74-
| `rest-api-client` | `torrust-tracker-rest-api-client` | client tools | REST API client library |
75-
| `rest-api-core` | `torrust-tracker-rest-api-core` | client tools | REST API core logic |
76-
| `swarm-coordination-registry` | `torrust-tracker-swarm-coordination-registry` | domain | Torrent/peer coordination registry |
77-
| `test-helpers` | `torrust-tracker-test-helpers` | utilities | Mock servers, test data generation |
78-
| `torrent-repository-benchmarking` | `torrust-tracker-torrent-repository-benchmarking` | benchmarking | Torrent storage benchmarks |
79-
| `tracker-client` | `torrust-tracker-client` | client tools | CLI tracker interaction/testing client |
80-
| `tracker-core` | `torrust-tracker-core` | `*-core` | Central tracker peer-management logic |
81-
| `udp-protocol` | `torrust-tracker-udp-protocol` | `*-protocol` | UDP tracker protocol (BEP 15) framing/parsing |
82-
| `udp-core` | `torrust-tracker-udp-core` | `*-core` | UDP-specific tracker domain logic |
83-
| `udp-server` | `torrust-tracker-udp-server` | server | UDP tracker server implementation |
63+
| Package | Crate Name | Prefix / Layer | Description |
64+
| --------------------------------- | ------------------------------------------------- | --------------- | --------------------------------------------- |
65+
| `axum-health-check-api-server` | `torrust-tracker-axum-health-check-api-server` | `axum-*` | Health monitoring endpoint |
66+
| `axum-http-server` | `torrust-tracker-axum-http-server` | `axum-*` | BitTorrent HTTP tracker server (BEP 3/23) |
67+
| `axum-rest-api-server` | `torrust-tracker-axum-rest-api-server` | `axum-*` | Management REST API server |
68+
| `axum-server` | `torrust-tracker-axum-server` | `axum-*` | Base Axum HTTP server infrastructure |
69+
| `configuration` | `torrust-tracker-configuration` | domain | Config file parsing, environment variables |
70+
| `events` | `torrust-tracker-events` | domain | Domain event definitions |
71+
| `http-protocol` | `torrust-tracker-http-protocol` | `*-protocol` | HTTP tracker protocol (BEP 3/23) parsing |
72+
| `http-core` | `torrust-tracker-http-core` | `*-core` | HTTP-specific tracker domain logic |
73+
| `primitives` | `torrust-tracker-primitives` | domain | Core domain types (InfoHash, PeerId, ...) |
74+
| `rest-api-client` | `torrust-tracker-rest-api-client` | client tools | REST API client library |
75+
| `rest-api-runtime-adapter` | `torrust-tracker-rest-api-runtime-adapter` | runtime adapter | REST API runtime adapter and container wiring |
76+
| `swarm-coordination-registry` | `torrust-tracker-swarm-coordination-registry` | domain | Torrent/peer coordination registry |
77+
| `test-helpers` | `torrust-tracker-test-helpers` | utilities | Mock servers, test data generation |
78+
| `torrent-repository-benchmarking` | `torrust-tracker-torrent-repository-benchmarking` | benchmarking | Torrent storage benchmarks |
79+
| `tracker-client` | `torrust-tracker-client` | client tools | CLI tracker interaction/testing client |
80+
| `tracker-core` | `torrust-tracker-core` | `*-core` | Central tracker peer-management logic |
81+
| `udp-protocol` | `torrust-tracker-udp-protocol` | `*-protocol` | UDP tracker protocol (BEP 15) framing/parsing |
82+
| `udp-core` | `torrust-tracker-udp-core` | `*-core` | UDP-specific tracker domain logic |
83+
| `udp-server` | `torrust-tracker-udp-server` | server | UDP tracker server implementation |
8484

8585
**Extracted packages** — previously part of this workspace, now in their own standalone repositories:
8686

Cargo.lock

Lines changed: 3 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ torrust-tracker-axum-http-server = { version = "3.0.0-develop", path = "packages
6262
torrust-tracker-axum-rest-api-server = { version = "3.0.0-develop", path = "packages/axum-rest-api-server" }
6363
torrust-tracker-axum-server = { version = "3.0.0-develop", path = "packages/axum-server" }
6464
torrust-tracker-rest-api-client = { version = "3.0.0-develop", path = "packages/rest-api-client" }
65-
torrust-tracker-rest-api-core = { version = "3.0.0-develop", path = "packages/rest-api-core" }
65+
torrust-tracker-rest-api-runtime-adapter = { version = "3.0.0-develop", path = "packages/rest-api-runtime-adapter" }
6666
torrust-tracker-rest-api-protocol = { version = "3.0.0-develop", path = "packages/rest-api-protocol" }
6767
torrust-server-lib = "0.1.0"
6868
torrust-clock = "3.0.0"

Containerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ COPY packages/http-protocol/Cargo.toml packages/http-protocol/
8080
COPY packages/http-core/Cargo.toml packages/http-core/
8181
COPY packages/primitives/Cargo.toml packages/primitives/
8282
COPY packages/rest-api-client/Cargo.toml packages/rest-api-client/
83-
COPY packages/rest-api-core/Cargo.toml packages/rest-api-core/
8483
COPY packages/rest-api-application/Cargo.toml packages/rest-api-application/
8584
COPY packages/rest-api-protocol/Cargo.toml packages/rest-api-protocol/
8685
COPY packages/rest-api-runtime-adapter/Cargo.toml packages/rest-api-runtime-adapter/
@@ -127,7 +126,6 @@ RUN mkdir -p \
127126
packages/http-core/benches \
128127
packages/primitives/src \
129128
packages/rest-api-client/src \
130-
packages/rest-api-core/src \
131129
packages/rest-api-application/src \
132130
packages/rest-api-protocol/src \
133131
packages/rest-api-runtime-adapter/src \
@@ -168,7 +166,6 @@ RUN mkdir -p \
168166
packages/http-core/benches/http_tracker_core_benchmark.rs \
169167
packages/primitives/src/lib.rs \
170168
packages/rest-api-client/src/lib.rs \
171-
packages/rest-api-core/src/lib.rs \
172169
packages/rest-api-application/src/lib.rs \
173170
packages/rest-api-protocol/src/lib.rs \
174171
packages/rest-api-runtime-adapter/src/lib.rs \

deny.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ deny = [
4949
"torrust-tracker-axum-rest-api-server",
5050
] },
5151

52-
# udp server — only server-layer + root + rest-api-core (pending fix) + runtime-adapter may depend on it
52+
# udp server — only server-layer + root + runtime-adapter may depend on it
5353
{ crate = "torrust-tracker-udp-server", wrappers = [
5454
"torrust-tracker",
5555
"torrust-tracker-axum-health-check-api-server",
5656
"torrust-tracker-axum-rest-api-server",
57-
"torrust-tracker-rest-api-core",
5857
"torrust-tracker-rest-api-runtime-adapter",
5958
] },
6059

@@ -84,13 +83,11 @@ deny = [
8483
"torrust-tracker",
8584
"torrust-tracker-axum-http-server",
8685
"torrust-tracker-axum-rest-api-server",
87-
"torrust-tracker-rest-api-core",
8886
"torrust-tracker-rest-api-runtime-adapter",
8987
] },
9088
{ crate = "torrust-tracker-udp-core", wrappers = [
9189
"torrust-tracker",
9290
"torrust-tracker-axum-rest-api-server",
93-
"torrust-tracker-rest-api-core",
9491
"torrust-tracker-rest-api-runtime-adapter",
9592
"torrust-tracker-udp-server",
9693
] },

docs/issues/open/1938-rest-api-contract-first-migration/EPIC.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ The contexts are ordered by complexity and dependency depth. Follow-up tasks (SI
9292
```
9393

9494
See the `torrent` context for the reference pattern.
95+
9596
- Define port traits in `rest-api-application` for each context's query/command operations.
9697
These are flat files named after the context in `packages/rest-api-application/src/ports/`:
9798

@@ -140,7 +141,7 @@ The contexts are ordered by complexity and dependency depth. Follow-up tasks (SI
140141
- [#1940](https://github.com/torrust/torrust-tracker/issues/1940)[SI-2](../1940-1938-si-2-migrate-whitelist-context.md): Migrate `whitelist` context
141142
- [#1941](https://github.com/torrust/torrust-tracker/issues/1941)[SI-3](../1941-1938-si-3-migrate-auth-key-context.md): Migrate `auth_key` context
142143
- [#1942](https://github.com/torrust/torrust-tracker/issues/1942)[SI-4](../1942-1938-si-4-migrate-stats-context.md): Migrate `stats` context
143-
- [#1943](https://github.com/torrust/torrust-tracker/issues/1943)[SI-5](../1943-1938-si-5-deprecate-rest-api-core.md): Deprecate `rest-api-core` and remove from workspace
144+
- [#1943](https://github.com/torrust/torrust-tracker/issues/1943)[SI-5](../1943-1938-si-5-deprecate-rest-api-core/ISSUE.md): Deprecate `rest-api-core` and remove from workspace
144145
- [#1944](https://github.com/torrust/torrust-tracker/issues/1944)[SI-6](../1944-1938-si-6-align-rest-api-client.md): Introduce `ApiClient` — a high-level typed client over protocol DTOs
145146

146147
## Contract Evolution Governance

0 commit comments

Comments
 (0)