From b643842c4421a1595030ba42ba25d5188db038a6 Mon Sep 17 00:00:00 2001 From: David Westgate Date: Sat, 27 Apr 2024 01:04:47 -0700 Subject: [PATCH] further updates to readme --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 761c62e..1946b04 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ A useful package for serializing and deserializing data (specifically json), use #### src/main.rs Our applications main entry point, here we declare the use of the applications external packages for easier management. -`main` is then responsible for creating the new question `store` (behind the necessary tokio `RwLock`). `main` creates the axum router, and specifies all of the routes our application supports by pointing them to handler in the `src/api.rs` file via the appropriate http methods, before serving the axum service +`main` is then responsible for creating the new question `store` (behind the necessary tokio `RwLock`). `main` creates the axum router, and specifies all of the routes our application supports by pointing them to handlers in the `src/api.rs` file via the appropriate http methods, before serving the axum service #### src/api.rs Five handler are defined here for our five API endpoints, supporting the basic CRUD operations regarding questions. Care was taken to handle most common possible error cases, such as attempting to get a question by an id which does not exist, or attempting to create a question with the same ID as one that already exists. @@ -52,7 +52,13 @@ This is the definition of our `struct Question`. An interesting potential for co To address this, I seperated the Question 'entity' from the Question 'DTO' (data transfer object) from an ORM philosophy. The result is that the Question entity does not contain a direct reference to the question ID, as it is assumed while we are in program space, the store's hashmap will manage this. `to_entity` and `to_dto` function implementions have been provided to make this easier to work with. #### src/store.rs - +The store is responsible for the management of the questions. It does this by +* Loading the questions from the `questions.json` (if it exists, or creating it if not) +* Creating an in-memory hashmap of the jokes +* Providing public functions to create, retrieve, update or delete questions +* Writing any mutating changes out to `questions.json` +* Handling possible unpermitted operations by returning errors +* Handling possible file or I/O errors with some sense of grace before panicing ### Looking ahead These are a few things still to be added #### Higher priority @@ -60,11 +66,14 @@ These are a few things still to be added * Support POST /answers * API documentation tooling (`utoipa`) * API testing tooling (`swagger`) -* Coded API tests +* Coded API tests with mock data * Specific defined Error types for common errors +* Additional comments (rustdoc) +* Serve basic web page(s) to utilize all APIs #### Lesser priority * Optimize flush/file writing: Write out the JSON in a pretty structure and avoid re-writing the whole file in cases when it can be avoid (like adding 1 item) * Use a database alltogether instead of a json file for persistance * Re-structure the application to serve API endpoint from an `api` directory, and generically serve web content from a `web` directory * Optimize the put/update handler to support path or body identification, and to update only individual fields passed. +* Host application on my raspberry pi on the internet