Skip to content

Commit 0b33653

Browse files
authored
Merge pull request #88 from nanotaboada/chore/cleanup-stale-entrypoint-docs-and-rest
chore(docs): remove VOLUME_STORAGE_PATH, fix stale refs, expand REST examples
2 parents d39058f + 7ed1f0a commit 0b33653

4 files changed

Lines changed: 136 additions & 25 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: 125 additions & 17 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+
@createdSquadNumber = 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
@@ -25,7 +32,28 @@ Content-Type: application/json
2532
"middleName": "",
2633
"lastName": "Lo Celso",
2734
"dateOfBirth": "1996-07-09T00:00:00.000Z",
28-
"squadNumber": 27,
35+
"squadNumber": {{createdSquadNumber}},
36+
"position": "Central Midfield",
37+
"abbrPosition": "CM",
38+
"team": "Real Betis Balompié",
39+
"league": "La Liga",
40+
"starting11": false
41+
}
42+
43+
###
44+
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": {{createdSquadNumber}},
2957
"position": "Central Midfield",
3058
"abbrPosition": "CM",
3159
"team": "Real Betis Balompié",
@@ -35,26 +63,52 @@ Content-Type: application/json
3563

3664
###
3765

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

@@ -63,7 +117,27 @@ Content-Type: application/json
63117
"middleName": "",
64118
"lastName": "Martínez",
65119
"dateOfBirth": "1992-09-02T00:00:00.000Z",
66-
"squadNumber": 23,
120+
"squadNumber": {{existingSquadNumber}},
121+
"position": "Goalkeeper",
122+
"abbrPosition": "GK",
123+
"team": "Aston Villa FC",
124+
"league": "Premier League",
125+
"starting11": true
126+
}
127+
128+
###
129+
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": {{existingSquadNumber}},
67141
"position": "Goalkeeper",
68142
"abbrPosition": "GK",
69143
"team": "Aston Villa FC",
@@ -73,9 +147,43 @@ Content-Type: application/json
73147

74148
###
75149

76-
### Delete Player
77-
# DELETE /players/squadnumber/:squadnumber → 204 No Content
78-
# Requires Create Player to have been run first.
79-
DELETE {{baseUrl}}/players/squadnumber/{{newSquadNumber}}
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": {{existingSquadNumber}},
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.
175+
DELETE {{baseUrl}}/players/squadnumber/{{createdSquadNumber}}
176+
177+
###
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}}
80188

81189
###

scripts/entrypoint.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ 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+
STORAGE_PATH="${STORAGE_PATH:-storage/players-sqlite3.db}"
13+
14+
mkdir -p "$(dirname "$STORAGE_PATH")"
1515

16-
if [ ! -f "$VOLUME_STORAGE_PATH" ]; then
16+
if [ ! -f "$STORAGE_PATH" ]; then
1717
log "⚠️ No existing database file found in volume."
1818
log "🗄️ Diesel migrations will initialize the database on first start."
1919
else
20-
log "✔ Existing database file found at $VOLUME_STORAGE_PATH."
20+
log "✔ Existing database file found at $STORAGE_PATH."
2121
fi
2222

2323
log "✔ Ready!"

0 commit comments

Comments
 (0)