Simple Express.js REST API for managing an in-memory playing card collection.
| Method | Endpoint | Description | Body (JSON) |
|---|---|---|---|
| GET | /cards | List all cards | |
| GET | /cards/:id | Get a card by ID | |
| POST | /cards | Create a new card | { "suit": "Hearts", "value": "Ace" } |
| DELETE | /cards/:id | Delete a card by ID |
- suit must be one of: Hearts, Spades, Diamonds, Clubs
- value must be one of: Ace, King, Queen, Jack, 10, 9, 8, 7, 6, 5, 4, 3, 2
EXP 2/
package.json
src/
app.js
server.js
data/cardsData.js
controllers/cardsController.js
routes/cards.js
middleware/errorHandler.js
test/
cards.test.js
cd "EXP 2"
npm install
npm run dev # http://localhost:3000curl http://localhost:3000/cards
curl -X POST http://localhost:3000/cards \
-H 'Content-Type: application/json' \
-d '{"suit":"Clubs","value":"Jack"}'
curl http://localhost:3000/cards/2
curl -X DELETE http://localhost:3000/cards/1npm testData is in-memory and resets on server restart.