Skip to content

Commit 11af501

Browse files
nanotaboadaclaude
andcommitted
chore(docs): remove redundant VOLUME_STORAGE_PATH, fix stale refs, expand REST examples
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d39058f commit 11af501

4 files changed

Lines changed: 131 additions & 22 deletions

File tree

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ REST API for managing football players built with Rust and Rocket. Implements CR
77
## Tech Stack
88

99
- **Language**: Rust 2024 Edition (enforced via `rust-toolchain.toml`)
10-
- **Framework**: Rocket 0.5 (async)
10+
- **Framework**: Rocket 0.5.1 (async)
1111
- **Serialization**: Serde (JSON)
1212
- **Unique IDs**: uuid (v4 + serde features)
1313
- **ORM / Migrations**: Diesel (SQLite + r2d2 features) + diesel_migrations; `embed_migrations!()` runs pending migrations on startup

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Once the application is running, you can access:
154154

155155
- **API Server**: `http://localhost:9000`
156156
- **Health Check**: `http://localhost:9000/health`
157+
- **Swagger UI**: `http://localhost:9000/swagger-ui/`
157158

158159
## Containers
159160

@@ -197,8 +198,10 @@ docker pull ghcr.io/nanotaboada/rust-samples-rocket-restful:latest
197198
## Environment Variables
198199

199200
```bash
200-
# Database storage path (default: ./storage/players-sqlite3.db)
201-
STORAGE_PATH=./storage/players-sqlite3.db
201+
# Database storage path
202+
# Container default (set in Dockerfile): /storage/players-sqlite3.db
203+
# Local dev fallback (no env var set): storage/players-sqlite3.db
204+
STORAGE_PATH=/storage/players-sqlite3.db
202205

203206
# Rocket profile: debug or release (default: debug)
204207
ROCKET_PROFILE=release

rest/players.rest

Lines changed: 122 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
### - VS Code: REST Client extension (humao.rest-client)
44
### - JetBrains IDEs: built-in HTTP Client
55

6-
@baseUrl = http://localhost:9000
7-
@newSquadNumber = 27
8-
@existingSquadNumber = 23
6+
@baseUrl = http://localhost:9000
7+
@existingId = acc433bf-d505-51fe-831e-45eb44c4d43c
8+
@nonexistentId = 00000000-0000-0000-0000-000000000000
9+
@unknownId = f47ac10b-58cc-4372-a567-0e02b2c3d479
10+
@newSquadNumber = 27
11+
@existingSquadNumber = 23
12+
@nonexistentSquadNumber = 999
13+
@unknownSquadNumber = 28
914

1015
# -----------------------------------------------------------------------------
1116

@@ -15,7 +20,9 @@ GET {{baseUrl}}/health
1520

1621
###
1722

18-
### Create Player
23+
# POST /players ---------------------------------------------------------------
24+
25+
### Create Player (valid body)
1926
# POST /players → 201 Created
2027
POST {{baseUrl}}/players
2128
Content-Type: application/json
@@ -35,26 +42,73 @@ Content-Type: application/json
3542

3643
###
3744

45+
### Create Player (duplicate squad number)
46+
# POST /players → 409 Conflict
47+
# Requires: "Create Player (valid body)" above to have run first.
48+
POST {{baseUrl}}/players
49+
Content-Type: application/json
50+
51+
{
52+
"firstName": "Giovani",
53+
"middleName": "",
54+
"lastName": "Lo Celso",
55+
"dateOfBirth": "1996-07-09T00:00:00.000Z",
56+
"squadNumber": 27,
57+
"position": "Central Midfield",
58+
"abbrPosition": "CM",
59+
"team": "Real Betis Balompié",
60+
"league": "La Liga",
61+
"starting11": false
62+
}
63+
64+
###
65+
66+
# GET /players ----------------------------------------------------------------
67+
3868
### Get All Players
3969
# GET /players → 200 OK
4070
GET {{baseUrl}}/players
4171

4272
###
4373

44-
### Get Player by ID
45-
# GET /players/:id → 200 OK
46-
GET {{baseUrl}}/players/acc433bf-d505-51fe-831e-45eb44c4d43c
74+
# GET /players/{id} -----------------------------------------------------------
75+
76+
### Get Player by ID (existing)
77+
# GET /players/{id} → 200 OK
78+
GET {{baseUrl}}/players/{{existingId}}
79+
80+
###
81+
82+
### Get Player by ID (nonexistent)
83+
# GET /players/{id} → 404 Not Found
84+
GET {{baseUrl}}/players/{{nonexistentId}}
4785

4886
###
4987

50-
### Get Player by Squad Number
51-
# GET /players/squadnumber/:squadnumber → 200 OK
88+
### Get Player by ID (unknown)
89+
# GET /players/{id} → 404 Not Found
90+
GET {{baseUrl}}/players/{{unknownId}}
91+
92+
###
93+
94+
# GET /players/squadnumber/{squad_number} -------------------------------------
95+
96+
### Get Player by Squad Number (existing)
97+
# GET /players/squadnumber/{squad_number} → 200 OK
5298
GET {{baseUrl}}/players/squadnumber/10
5399

54100
###
55101

56-
### Update Player
57-
# PUT /players/squadnumber/:squadnumber → 200 OK
102+
### Get Player by Squad Number (nonexistent)
103+
# GET /players/squadnumber/{squad_number} → 404 Not Found
104+
GET {{baseUrl}}/players/squadnumber/{{nonexistentSquadNumber}}
105+
106+
###
107+
108+
# PUT /players/squadnumber/{squad_number} -------------------------------------
109+
110+
### Update Player (existing)
111+
# PUT /players/squadnumber/{squad_number} → 204 No Content
58112
PUT {{baseUrl}}/players/squadnumber/{{existingSquadNumber}}
59113
Content-Type: application/json
60114

@@ -73,9 +127,63 @@ Content-Type: application/json
73127

74128
###
75129

76-
### Delete Player
77-
# DELETE /players/squadnumber/:squadnumber → 204 No Content
78-
# Requires Create Player to have been run first.
130+
### Update Player (nonexistent)
131+
# PUT /players/squadnumber/{squad_number} → 404 Not Found
132+
PUT {{baseUrl}}/players/squadnumber/{{nonexistentSquadNumber}}
133+
Content-Type: application/json
134+
135+
{
136+
"firstName": "Emiliano",
137+
"middleName": "",
138+
"lastName": "Martínez",
139+
"dateOfBirth": "1992-09-02T00:00:00.000Z",
140+
"squadNumber": 23,
141+
"position": "Goalkeeper",
142+
"abbrPosition": "GK",
143+
"team": "Aston Villa FC",
144+
"league": "Premier League",
145+
"starting11": true
146+
}
147+
148+
###
149+
150+
### Update Player (unknown)
151+
# PUT /players/squadnumber/{squad_number} → 404 Not Found
152+
PUT {{baseUrl}}/players/squadnumber/{{unknownSquadNumber}}
153+
Content-Type: application/json
154+
155+
{
156+
"firstName": "Emiliano",
157+
"middleName": "",
158+
"lastName": "Martínez",
159+
"dateOfBirth": "1992-09-02T00:00:00.000Z",
160+
"squadNumber": 23,
161+
"position": "Goalkeeper",
162+
"abbrPosition": "GK",
163+
"team": "Aston Villa FC",
164+
"league": "Premier League",
165+
"starting11": true
166+
}
167+
168+
###
169+
170+
# DELETE /players/squadnumber/{squad_number} ----------------------------------
171+
172+
### Delete Player (existing)
173+
# DELETE /players/squadnumber/{squad_number} → 204 No Content
174+
# Requires: "Create Player (valid body)" above to have run first.
79175
DELETE {{baseUrl}}/players/squadnumber/{{newSquadNumber}}
80176

81177
###
178+
179+
### Delete Player (nonexistent)
180+
# DELETE /players/squadnumber/{squad_number} → 404 Not Found
181+
DELETE {{baseUrl}}/players/squadnumber/{{nonexistentSquadNumber}}
182+
183+
###
184+
185+
### Delete Player (unknown)
186+
# DELETE /players/squadnumber/{squad_number} → 404 Not Found
187+
DELETE {{baseUrl}}/players/squadnumber/{{unknownSquadNumber}}
188+
189+
###

scripts/entrypoint.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ log() {
77
return 0
88
}
99

10-
VOLUME_STORAGE_PATH="${STORAGE_PATH:-/storage/players-sqlite3.db}"
11-
1210
log "✔ Starting container..."
1311

14-
mkdir -p "$(dirname "$VOLUME_STORAGE_PATH")"
12+
mkdir -p "$(dirname "$STORAGE_PATH")"
1513

16-
if [ ! -f "$VOLUME_STORAGE_PATH" ]; then
14+
if [ ! -f "$STORAGE_PATH" ]; then
1715
log "⚠️ No existing database file found in volume."
1816
log "🗄️ Diesel migrations will initialize the database on first start."
1917
else
20-
log "✔ Existing database file found at $VOLUME_STORAGE_PATH."
18+
log "✔ Existing database file found at $STORAGE_PATH."
2119
fi
2220

2321
log "✔ Ready!"

0 commit comments

Comments
 (0)