Skip to content

Commit 40df7d8

Browse files
committed
fix: correct Prettier extension id and extract playerId variable in .rest file
(#495)
1 parent 6092f68 commit 40df7d8

File tree

3 files changed

+83
-64
lines changed

3 files changed

+83
-64
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@
4747
"ms-azuretools.vscode-docker", // Docker (legacy) - Use vscode-containers instead
4848
"docker.docker", // Docker DX - Use ms-azuretools.vscode-containers
4949
"github.copilot", // Copilot (base) - Unified into copilot-chat
50-
"esbenp.prettier-vscode" // Prettier (legacy) - Use prettier.prettier-vscode instead
50+
"prettier.prettier-vscode" // Prettier (deprecated publisher) - Use esbenp.prettier-vscode instead
5151
]
5252
}

README.md

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,27 @@ Proof of Concept for a RESTful API made with [Node.js](https://nodejs.org/) [LTS
3232
- 📚 **Interactive API exploration** - Auto-generated OpenAPI docs with Swagger UI and `.rest` HTTP file for VS Code REST Client
3333
-**Performance optimizations** - In-memory caching with node-cache, Sequelize ORM, and efficient SQLite operations
3434
- 🧪 **Comprehensive integration tests** - Full endpoint coverage with Jest/Supertest and automated reporting to Codecov
35-
- 📖 **Token-efficient documentation** - AGENTS.md + auto-loaded Copilot instructions for AI-assisted development
35+
- 📖 **Token-efficient documentation** - Auto-loaded Copilot instructions for AI-assisted development
3636
- 🐳 **Full containerization** - Multi-stage Docker builds with Docker Compose orchestration
3737
- 🔄 **Complete CI/CD pipeline** - Automated linting (ESLint/Prettier), testing, Docker publishing, and GitHub releases
3838
-**Football-themed semantic versioning** - Memorable, alphabetical release names using football terminology
3939

4040
## Tech Stack
4141

42-
| Category | Technology |
43-
|------------------------|------------------------------------------------------------------------------------------------------------------------------|
44-
| **Runtime** | [Node.js 24 (LTS/Krypton)](https://github.com/nodejs/node) |
45-
| **Language** | [TypeScript 5.9](https://github.com/microsoft/TypeScript) |
46-
| **Module System** | Native ECMAScript Modules (ESM) - uses [tsx](https://github.com/privatenumber/tsx) for execution |
47-
| **Framework** | [Express.js 5](https://github.com/expressjs/express) |
48-
| **Database** | [SQLite3](https://github.com/sqlite/sqlite) with [Sequelize ORM](https://github.com/sequelize/sequelize) |
49-
| **Caching** | [node-cache](https://github.com/node-cache/node-cache) |
50-
| **Documentation** | [Swagger (OpenAPI 3.0)](https://github.com/swagger-api/swagger-ui) |
51-
| **Security** | [Helmet](https://github.com/helmetjs/helmet), [CORS](https://github.com/expressjs/cors) |
52-
| **Testing** | [Jest 30](https://github.com/jestjs/jest) with [Supertest](https://github.com/ladjs/supertest) |
53-
| **Containerization** | [Docker](https://github.com/docker) with multi-stage builds |
42+
| Category | Technology |
43+
|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
44+
| **Runtime** | [Node.js 24 (LTS/Krypton)](https://github.com/nodejs/node) |
45+
| **Language** | [TypeScript 5.9](https://github.com/microsoft/TypeScript) |
46+
| **Module System** | Native ECMAScript Modules (ESM) - uses [tsx](https://github.com/privatenumber/tsx) for execution |
47+
| **Framework** | [Express.js 5](https://github.com/expressjs/express) |
48+
| **Database** | [SQLite3](https://github.com/sqlite/sqlite) with [Sequelize ORM](https://github.com/sequelize/sequelize) |
49+
| **Caching** | [node-cache](https://github.com/node-cache/node-cache) |
50+
| **Documentation** | [Swagger (OpenAPI 3.0)](https://github.com/swagger-api/swagger-ui) |
51+
| **Security** | [Helmet](https://github.com/helmetjs/helmet), [CORS](https://github.com/expressjs/cors) |
52+
| **Testing** | [Jest 30](https://github.com/jestjs/jest) with [Supertest](https://github.com/ladjs/supertest) |
53+
| **Containerization** | [Docker](https://github.com/docker) with multi-stage builds |
5454
| **Code Quality** | [ESLint](https://github.com/eslint/eslint), [Prettier](https://github.com/prettier/prettier), [Commitlint](https://github.com/conventional-changelog/commitlint) |
55-
| **Dev Tools** | [tsx](https://github.com/privatenumber/tsx) (TypeScript executor), [nodemon](https://github.com/remy/nodemon) |
55+
| **Dev Tools** | [tsx](https://github.com/privatenumber/tsx) (TypeScript executor), [nodemon](https://github.com/remy/nodemon) |
5656

5757
> 💡 **Note:** While the repository name references `ts-node` (the original implementation), the project now uses [tsx](https://github.com/privatenumber/tsx) for faster, cleaner TypeScript execution without experimental flags.
5858
@@ -78,8 +78,6 @@ storage/ # Pre-seeded SQLite database
7878

7979
## Architecture
8080

81-
Layered architecture with dependency injection via constructors and interface-based contracts.
82-
8381
```mermaid
8482
%%{init: {
8583
"theme": "default",
@@ -92,62 +90,82 @@ Layered architecture with dependency injection via constructors and interface-ba
9290
"clusterBorder": "#999"
9391
}
9492
}}%%
95-
graph BT
96-
subgraph API[" "]
97-
server[server]
98-
app[app]
99-
routes[routes]
100-
controllers[controllers]
93+
graph RL
94+
95+
%% Tests (outside all layers)
96+
tests[tests]
97+
98+
%% Infrastructure Layer (external dependencies)
99+
subgraph Infrastructure[" "]
101100
Express[Express]
101+
Sequelize[Sequelize]
102+
nodeCache[node-cache]
102103
end
103104
105+
%% Data Layer
106+
subgraph Data[" "]
107+
database[database]
108+
end
109+
110+
%% Business Layer
104111
subgraph Business[" "]
105112
services[services]
106-
nodeCache[node-cache]
107113
end
108114
109-
subgraph Data[" "]
110-
database[database]
111-
models[models]
112-
Sequelize[Sequelize]
115+
%% HTTP Layer (composition root: server)
116+
subgraph HTTP[" "]
117+
controllers[controllers]
118+
routes[routes]
119+
app[app]
120+
server[server]
113121
end
114122
115-
%% Tests (outside layers)
116-
tests[tests]
123+
%% Cross-cutting type concern (outside all layers)
124+
models[models]
125+
126+
%% Supporting features (outside all layers)
127+
docs[docs]
128+
117129
118-
%% Detailed connections within layers
119-
database --> services
120-
models --> database
121-
models --> services
122-
models --> controllers
123130
131+
%% Strong (solid) dependencies — consumer actively invokes behavior
132+
Express --> app
133+
Express --> routes
134+
Express --> controllers
135+
Sequelize --> database
136+
nodeCache --> services
137+
database --> services
124138
services --> controllers
125139
controllers --> routes
126140
routes --> app
127141
app --> server
128142
129-
%% External Dependencies
130-
Sequelize --> database
131-
Sequelize --> models
132-
nodeCache --> services
133-
Express --> controllers
134-
Express --> routes
135-
Express --> app
136-
137-
%% Tests connection
143+
%% Soft (dotted) dependencies — structural type references only
144+
models -.-> database
145+
models -.-> services
146+
models -.-> controllers
147+
docs -.-> app
138148
app -.-> tests
139149
140150
%% Styling
141151
classDef core fill:#b3d9ff,stroke:#6db1ff,stroke-width:2px,color:#555,font-family:monospace;
142-
classDef deps fill:#ffcccc,stroke:#ff8f8f,stroke-width:2px,color:#555,font-family:monospace;
152+
classDef support fill:#fff3cc,stroke:#f0c040,stroke-width:2px,color:#555,font-family:monospace;
153+
classDef infra fill:#ffcccc,stroke:#ff8f8f,stroke-width:2px,color:#555,font-family:monospace;
143154
classDef test fill:#ccffcc,stroke:#53c45e,stroke-width:2px,color:#555,font-family:monospace;
144155
145156
class server,app,routes,controllers,services,database,models core
146-
class Express,Sequelize,nodeCache deps
157+
class docs support
158+
class Express,Sequelize,nodeCache infra
147159
class tests test
148160
```
149161

150-
_Simplified, conceptual project structure and main application flow. Not all dependencies are shown._
162+
**Arrow Semantics:** Arrows point from a dependency toward its consumer. Solid arrows (`-->`) denote strong (functional) dependencies: the consumer actively invokes behavior — calling methods, executing queries, or handling HTTP requests. Dotted arrows (`-.->`) denote soft (structural) dependencies: the consumer only references types or function signatures, without invoking runtime behavior. This distinction is grounded in UML's «use» dependency notation and classical coupling theory (Myers, 1978): strong arrows approximate control or stamp coupling, while soft arrows approximate data coupling, where only shared data structures cross the boundary.
163+
164+
**Composition Root Pattern:** [`server`](src/server.ts) acts as the composition root — all solid arrows originate from it, reflecting that it is the sole site where dependencies are instantiated, wired, and injected. It creates the Express application instance, initializes the database connection, and registers all routes. This pattern enables dependency injection, improves testability, and ensures that no other package bears responsibility for object creation or lifecycle management.
165+
166+
**Layered Architecture:** The codebase is organized into four conceptual layers: HTTP ([`routes`](src/routes/), [`controllers`](src/controllers/)), Business ([`services`](src/services/)), Data ([`database`](src/database/)), and Infrastructure (`Express`, `Sequelize`). The [`models`](src/models/) package is a cross-cutting type concern — it defines shared data structures consumed across all layers via soft (structural) dependencies, without containing logic or behavior of its own. Strong dependencies flow strictly downward through the layers, preserving the layer rule: no layer reaches upward to invoke behavior in a layer above it.
167+
168+
**Color Coding:** Core packages (blue) implement the application logic, supporting features (yellow) provide documentation and utilities, external dependencies (red) are third-party frameworks and ORMs, and tests (green) ensure code quality.
151169

152170
## API Endpoints
153171

rest/players.rest

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# https://marketplace.visualstudio.com/items?itemName=humao.rest-client
33

44
@baseUrl = http://localhost:9000
5+
@playerId = 12
56

67
# -----------------------------------------------------------------------------
78
# GET /health
@@ -46,7 +47,7 @@ POST {{baseUrl}}/players
4647
Content-Type: application/json
4748

4849
{
49-
"id": 12,
50+
"id": {{playerId}},
5051
"firstName": "Leandro",
5152
"middleName": "Daniel",
5253
"lastName": "Paredes",
@@ -156,11 +157,11 @@ Content-Type: application/json
156157
# -----------------------------------------------------------------------------
157158

158159
### Request PUT /players/{id} existing → Response status 204 No Content
159-
PUT {{baseUrl}}/players/12
160+
PUT {{baseUrl}}/players/{{playerId}}
160161
Content-Type: application/json
161162

162163
{
163-
"id": 12,
164+
"id": {{playerId}},
164165
"firstName": "Leandro",
165166
"middleName": "Daniel",
166167
"lastName": "Paredes",
@@ -221,73 +222,73 @@ Content-Type: application/json
221222
}
222223

223224
### Request PUT /players/{id} body empty → Response status 400 Bad Request
224-
PUT {{baseUrl}}/players/12
225+
PUT {{baseUrl}}/players/{{playerId}}
225226
Content-Type: application/json
226227

227228
{}
228229

229230
### Request PUT /players/{id} firstName missing → Response status 400 Bad Request
230-
PUT {{baseUrl}}/players/12
231+
PUT {{baseUrl}}/players/{{playerId}}
231232
Content-Type: application/json
232233

233234
{
234-
"id": 12,
235+
"id": {{playerId}},
235236
"lastName": "Doe",
236237
"squadNumber": 10,
237238
"position": "Forward"
238239
}
239240

240241
### Request PUT /players/{id} lastName missing → Response status 400 Bad Request
241-
PUT {{baseUrl}}/players/12
242+
PUT {{baseUrl}}/players/{{playerId}}
242243
Content-Type: application/json
243244

244245
{
245-
"id": 12,
246+
"id": {{playerId}},
246247
"firstName": "John",
247248
"squadNumber": 10,
248249
"position": "Forward"
249250
}
250251

251252
### Request PUT /players/{id} squadNumber missing → Response status 400 Bad Request
252-
PUT {{baseUrl}}/players/12
253+
PUT {{baseUrl}}/players/{{playerId}}
253254
Content-Type: application/json
254255

255256
{
256-
"id": 12,
257+
"id": {{playerId}},
257258
"firstName": "John",
258259
"lastName": "Doe",
259260
"position": "Forward"
260261
}
261262

262263
### Request PUT /players/{id} position missing → Response status 400 Bad Request
263-
PUT {{baseUrl}}/players/12
264+
PUT {{baseUrl}}/players/{{playerId}}
264265
Content-Type: application/json
265266

266267
{
267-
"id": 12,
268+
"id": {{playerId}},
268269
"firstName": "John",
269270
"lastName": "Doe",
270271
"squadNumber": 10
271272
}
272273

273274
### Request PUT /players/{id} squadNumber >99 → Response status 400 Bad Request
274-
PUT {{baseUrl}}/players/12
275+
PUT {{baseUrl}}/players/{{playerId}}
275276
Content-Type: application/json
276277

277278
{
278-
"id": 12,
279+
"id": {{playerId}},
279280
"firstName": "John",
280281
"lastName": "Doe",
281282
"squadNumber": 100,
282283
"position": "Forward"
283284
}
284285

285286
### Request PUT /players/{id} squadNumber <1 → Response status 400 Bad Request
286-
PUT {{baseUrl}}/players/12
287+
PUT {{baseUrl}}/players/{{playerId}}
287288
Content-Type: application/json
288289

289290
{
290-
"id": 12,
291+
"id": {{playerId}},
291292
"firstName": "John",
292293
"lastName": "Doe",
293294
"squadNumber": 0,
@@ -299,7 +300,7 @@ Content-Type: application/json
299300
# -----------------------------------------------------------------------------
300301

301302
### Request DELETE /players/{id} existing → Response status 204 No Content
302-
DELETE {{baseUrl}}/players/12
303+
DELETE {{baseUrl}}/players/{{playerId}}
303304

304305
### Request DELETE /players/{id} nonexistent → Response status 404 Not Found
305306
DELETE {{baseUrl}}/players/999

0 commit comments

Comments
 (0)