@@ -6,15 +6,16 @@ A RESTful API for managing tasks built with Java 21 and Spring Boot.
66
77## Tech Stack
88
9- | Layer | Technology |
10- | ------------| ------------------------|
11- | Language | Java 21 |
12- | Framework | Spring Boot 4.1.0-M2 |
13- | Persistence| H2 (file-based) |
14- | ORM | Spring Data JPA |
15- | Validation | Spring Boot Validation |
16- | Build Tool | Maven |
17- | CI/CD | GitHub Actions |
9+ | Layer | Technology |
10+ | ----------------| ------------------------|
11+ | Language | Java 21 |
12+ | Framework | Spring Boot 4.1.0-M2 |
13+ | Persistence | H2 (file-based) |
14+ | ORM | Spring Data JPA |
15+ | Validation | Spring Boot Validation |
16+ | Error Handling | @ControllerAdvice |
17+ | Build Tool | Maven |
18+ | CI/CD | GitHub Actions |
1819
1920---
2021
@@ -45,21 +46,22 @@ To inspect the database while the app is running, open the H2 console at `http:/
4546| ----------| ------------------------------|
4647| JDBC URL | ` jdbc:h2:file:./data/taskdb ` |
4748| Username | ` sa ` |
48- | Password | * < blank > * |
49+ | Password | * (leave blank) * |
4950
5051---
5152
5253## Endpoints
5354
54- | Method | Path | Description |
55- | --------| -------------------------| -------------------------|
56- | POST | ` /tasks ` | Create a task |
57- | GET | ` /tasks ` | Fetch all tasks |
58- | GET | ` /tasks/{id} ` | Fetch a task by ID |
59- | GET | ` /tasks/search/{name} ` | Fetch a task by name |
60- | PATCH | ` /tasks/{id}/complete ` | Mark a task as complete |
61- | DELETE | ` /tasks/{id} ` | Soft delete a task |
62- | PATCH | ` /tasks/{id} ` | Undo a delete |
55+ | Method | Path | Description |
56+ | --------| --------------------------------| --------------------------|
57+ | POST | ` /tasks ` | Create a task |
58+ | GET | ` /tasks ` | Fetch all tasks |
59+ | GET | ` /tasks/{id} ` | Fetch a task by ID |
60+ | GET | ` /tasks/search/{name} ` | Fetch a task by name |
61+ | GET | ` /tasks/search/status/{status} ` | Fetch tasks by status |
62+ | PATCH | ` /tasks/{id}/complete ` | Mark a task as complete |
63+ | DELETE | ` /tasks/{id} ` | Soft delete a task |
64+ | PATCH | ` /tasks/{id} ` | Undo a delete |
6365
6466### Examples
6567
@@ -92,6 +94,25 @@ curl -s -X PATCH http://localhost:8080/tasks/{id}
9294
9395---
9496
97+ ## Error Handling
98+
99+ All errors return a consistent JSON response:
100+ ``` json
101+ {
102+ "error" : " Task not found: abc-123" ,
103+ "status" : 404 ,
104+ "timestamp" : " 2026-03-15T10:00:00"
105+ }
106+ ```
107+
108+ | Scenario | Status |
109+ | ---------------------------| --------|
110+ | Task not found | 404 |
111+ | Invalid status value | 400 |
112+ | Unexpected server error | 500 |
113+
114+ ---
115+
95116## Tests
96117``` bash
97118./mvnw test
106127│ ├── java/com/taskmanagerapi/
107128│ │ ├── controller/
108129│ │ │ └── TaskController.java
130+ │ │ ├── exception/
131+ │ │ │ ├── GlobalExceptionHandler.java
132+ │ │ │ └── TaskNotFoundException.java
109133│ │ ├── model/
110134│ │ │ ├── Task.java
111135│ │ │ └── TaskStatus.java
0 commit comments