You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: adds lesson_26 homework and lesson_27 pre-work (#593)
* feat: adds lesson_26 homework and lesson_27 pre-work
Signed-off-by: Anthony D. Mays <anthony@morganlatimer.com>
* tests: adds unit tests for media items controller
Signed-off-by: Anthony D. Mays <anthony@morganlatimer.com>
* chore: updating slides
Signed-off-by: Anthony D. Mays <anthony@morganlatimer.com>
* chore: adds build checks
Signed-off-by: Anthony D. Mays <anthony@morganlatimer.com>
---------
Signed-off-by: Anthony D. Mays <anthony@morganlatimer.com>
Copy file name to clipboardExpand all lines: lesson_26/README.md
+46-1Lines changed: 46 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,4 +19,49 @@ Please review the following resources before lecture:
19
19
20
20
## Homework
21
21
22
-
- TODO(anthonydmays): Add details here.
22
+
-[ ] Complete the [Creating a Library API](#creating-a-library-api) assignment.
23
+
-[ ] Do pre-work for [lesson 27](/lesson_27/).
24
+
25
+
### Creating a Library API
26
+
27
+
We are continuing to build atop the foundation of our library app. For this assignment, you will help implement the API that will be used by a yet-to-come front-end app.
28
+
29
+
* You will implement the [MediaItemsController][controller-file] to enable the following API:
30
+
*`GET /items` - Retrieves a list of media items
31
+
*`POST /items` - Creates a new media item
32
+
*`GET /items/:id` - Retrieves a single media item with the given ID.
33
+
*`DELETE /items/:id` - Deletes a single media item with the given ID.
34
+
* Study the tests in [MediaItemsControllerTest][controller-test-file] to understand what you should accept and return in the API.
35
+
* You should not need to make any code changes outside of the `com.codedifferently.lesson26.web` package.
36
+
37
+
#### Running the API
38
+
39
+
You can run the server using the usual `./gradlew run` command from the `api/java` directory. If you want to test that the server is running correctly, you can use `curl` like so:
40
+
41
+
```bash
42
+
curl http://localhost:3001/items | json_pp
43
+
```
44
+
45
+
The project also includes an OpenAPI user interface (Swagger) for navigating the API. Just visit http://localhost:3001/swagger-ui.html to access it.
46
+
47
+
Alternatively, you can also test the API using the tool [Postman][postman-link]. I recommend installing this tool to make it easier to test things.
48
+
49
+
#### Debugging the API
50
+
51
+
Remember that you can debug the API by visiting the main function in [Lesson26.java][main-file] and clicking `Debug main`. You'll be able to set breakpoints in your code to see what's happening and fix issues.
52
+
53
+

54
+
55
+
56
+
#### TypeScript API
57
+
58
+
This project also includes a fully functioning TypeScript version of the Java project. You can visit `api/javascript/api_app` to execute it using `npm start` and view the OpenAPI documentation at http://localhost:3000/api (note that it runs on port 3000).
59
+
60
+
## Additional resources
61
+
62
+
*[gRPC vs REST: Comparing API Styles in Practice (Article)](https://dev.to/anthonydmays/grpc-vs-rest-comparing-api-styles-in-practice-4bl): This article explains why the stuff most people call REST isn't actually.
0 commit comments