{"id":19615026,"url":"https://github.com/ghurtchu/diary","last_synced_at":"2025-04-28T02:31:07.222Z","repository":{"id":54604283,"uuid":"522519358","full_name":"Ghurtchu/diary","owner":"Ghurtchu","description":":pencil2::clipboard: JWT auth based persistent (MongoDB) RESTful API for managing notes along with searching and sorting capabilities.","archived":false,"fork":false,"pushed_at":"2022-12-16T19:56:15.000Z","size":243,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2023-12-08T00:08:52.700Z","etag":null,"topics":["backend","crud","functional-programming","jwt","mongodb","onion-architecture","password-hashing","reactive-mongo","restful-api","scala","scala3","zio","zio-http","zlayer"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ghurtchu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-08T11:23:14.000Z","updated_at":"2023-12-08T00:08:52.701Z","dependencies_parsed_at":"2022-08-13T21:10:27.964Z","dependency_job_id":null,"html_url":"https://github.com/Ghurtchu/diary","commit_stats":null,"previous_names":["scalevolvable/diary","ghurtchu/diary"],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghurtchu%2Fdiary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghurtchu%2Fdiary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghurtchu%2Fdiary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghurtchu%2Fdiary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ghurtchu","download_url":"https://codeload.github.com/Ghurtchu/diary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224092034,"owners_count":17254152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","crud","functional-programming","jwt","mongodb","onion-architecture","password-hashing","reactive-mongo","restful-api","scala","scala3","zio","zio-http","zlayer"],"created_at":"2024-11-11T10:54:56.897Z","updated_at":"2024-11-11T10:54:57.900Z","avatar_url":"https://github.com/Ghurtchu.png","language":"Scala","readme":"### This is the backend application which enables users to perform CRUD operations on the notes. A note is a simple data structure which consists of a title, body and a few other fields. The app is built in the style of a RESTful API that enables devs to plug in multiple clients in their favorite language/framework/stack (browser, mobile, desktop etc..)\n\n### The app has no integration tests because I have a full time job.. LOL (might add them later though)\n---\n#### Below you will see the typical flow of the app usage:\n1) User registration\n   - User registers with email and password\n   - User email must be unique\n2) User login\n   - User must log in to get back a JSON Web Token (JWT)\n   - JWT will be used for accessing protected routes \n3) Display User notes\n   - User can fetch all notes which he/she has ever created/updated\n4) Create new User note\n   - User can create a new note with specified title and body\n5) Modify/Delete existing User notes\n   - User can change the fields of the specific note, or delete it at all\n6) Search/Sort User notes\n   - User can apply exact/non-exact searching and ascending/desending sorting to his/her notes\n\n#### Let's discuss step by step what each step does and how the HTTP Request/Response, API Endpoint and related things look like:\n---\n1) ### User registration\n   | Endpoint                              | HTTP Method | Content Type     | HTTP Success (Statuscode)   | HTTP Failure (Statuscode)         |\n   | ------------------------------------- | ----------- | ---------------- | --------------------------- | --------------------------------- |\n   | http://localhost:8080/api/user/signup | POST        | application/json | User has been created (200) | User already exists (409)         | \n   \n   #### Request Body: \n   ```json\n   {\n     \"name\": \"Nika\",\n     \"email\": \"nika@gmail.com\",\n     \"password\": \"my-strong-pass\"\n   }\n   ``` \n---\n2) ### User login\n   | Endpoint                              | HTTP Method | Content Type     | HTTP Success (Statuscode)    | HTTP Failure (Statuscode)         |\n   | ------------------------------------- | ----------- | ---------------- | ---------------------------- | --------------------------------- |\n   | http://localhost:8080/api/user/login  | POST        | application/json | ```{\"token\": \"JWT\"}``` (200) | Auth failed (401)                 | \n   \n   #### Request Body: \n   ```json\n   {\n     \"email\": \"nika@gmail.com\",\n     \"password\": \"my-strong-pass\"\n   }\n   ``` \n---   \n3) ### Display User notes\n   | Endpoint                        | HTTP Method | Content Type     | HTTP Success (Statuscode)    | HTTP Failure (Statuscode)         |\n   | ------------------------------- | ----------- | ---------------- | ---------------------------- | --------------------------------- |\n   | http://localhost:8080/api/notes | GET         | application/json | Notes in JSON format (200)   | Auth failed (401)                 | \n   \n   ##### hint: use the real JWT returend upon the successful login\n   #### Headers:\n   ```\n   Authorization: Bearer JWT\n   ```\n   #### Typical response: \n   ```json\n    [\n      {\n          \"id\": 7159997665991673534,\n          \"title\": \"I love Scala\",\n          \"body\": \"Scala rocks (most definitely)\",\n          \"createdAt\": \"09-16-2022\"\n      },\n      {\n          \"id\": 5746959445480553359,\n          \"title\": \"I kinda like Java\",\n          \"body\": \"Java rocks (kinda)\",\n          \"createdAt\": \"09-16-2022\"\n      },\n      {\n          \"id\": 3672367746746389626,\n          \"title\": \"I completely hate Python\",\n          \"body\": \"Python sucks (yep yep)\",\n          \"createdAt\": \"09-16-2022\"\n      }\n   ]\n   ```\n---\n4) ### Create new Note\n   | Endpoint                        | HTTP Method | Content Type     | HTTP Success (Statuscode)    | HTTP Failure (Statuscode)         |\n   | ------------------------------- | ----------- | ---------------- | ---------------------------- | --------------------------------- |\n   | http://localhost:8080/api/notes | POST        | application/json | Note has been created (200)  | Auth failed (401)                 | \n   \n   ##### hint: use the real JWT returend upon the successful login\n   #### Headers:\n   ```\n   Authorization: Bearer JWT\n   ```\n   #### Request Body: \n   ```json\n   {\n       \"title\": \"why should I learn ZIO?\",\n       \"body\": \"cuz [insert 5 million intelligent words here]\",\n       \"createdAt\": \"17-09-2022\"\n   }\n   ```\n---\n5) ### Get Note by ID\n   | Endpoint                            | HTTP Method | Content Type     | HTTP Success (Statuscode)    | HTTP Failure (Statuscode)               |\n   | ----------------------------------- | ----------- | ---------------- | ---------------------------- | --------------------------------------- |\n   | http://localhost:8080/api/notes/:id | GET         | application/json | Note in JSON format (200)    | Auth failed (401) / Note does not exist | \n   \n   ##### hint: use the real JWT returend upon the successful login\n   #### Headers:\n   ```\n   Authorization: Bearer JWT\n   ```\n   #### Typical Response: \n   ```json\n   {\n       \"id\": 5321604607032827422,\n       \"title\": \"why should I learn ZIO?\",\n       \"body\": \"cuz [insert 5 million intelligent words here]\",\n       \"createdAt\": \"17-09-2022\"\n   }\n   ```\n---\n6) ### Delete Note by ID\n   | Endpoint                            | HTTP Method | Content Type     | HTTP Success (Statuscode)    | HTTP Failure (Statuscode)               |\n   | ----------------------------------- | ----------- | ---------------- | ---------------------------- | --------------------------------------- |\n   | http://localhost:8080/api/notes/:id | DELETE      | application/json | Note has been deleted (200)  | Auth failed (401) / Note does not exist | \n   \n   ##### hint: use the real JWT returend upon the successful login\n   #### Headers:\n   ```\n   Authorization: Bearer JWT\n   ```\n---\n7) ### Update Note fully\n   | Endpoint                            | HTTP Method | Content Type     | HTTP Success (Statuscode)    | HTTP Failure (Statuscode)               |\n   | ----------------------------------- | ----------- | ---------------- | ---------------------------- | --------------------------------------- |\n   | http://localhost:8080/api/notes/:id | PUT         | application/json | Note has been updated (200)  | Auth failed (401) / Note does not exist | \n   \n   ##### hint: use the real JWT returend upon the successful login\n   #### Headers:\n   ```\n   Authorization: Bearer JWT\n   ```\n   #### Request Body: \n   ```json\n   {\n      \"id\": 7043231874327471104,\n      \"title\": \"why should I learn ZIO?!?!?!?!?!\",\n      \"body\": \"cuz [insert 5 million intelligent words here]\",\n      \"createdAt\": \"17-09-2022\"\n   }\n   ```\n---\n8) ### Search for a specific Note \n   | Endpoint                                             | HTTP Method | Content Type     | HTTP Success (Statuscode)        | HTTP Failure (Statuscode) |\n   | ---------------------------------------------------- | ----------- | ---------------- | -------------------------------- | ------------------------- |\n   | http://localhost:8080/api/notes/search?title={title} | GET         | application/json | Note array in JSON format (200)  | Auth failed (401)         | \n   \n   ##### hint: use the real JWT returend upon the successful login\n   #### Headers:\n   ```\n   Authorization: Bearer JWT\n   ```\n   #### Typical response: \n   ```json\n    [\n      {\n          \"id\": 7159997665991673534,\n          \"title\": \"I love Scala\",\n          \"body\": \"Scala rocks (most definitely)\",\n          \"createdAt\": \"09-16-2022\"\n      },\n      {\n          \"id\": 5746959445480553359,\n          \"title\": \"I kinda like Java\",\n          \"body\": \"Java rocks (kinda)\",\n          \"createdAt\": \"09-16-2022\"\n      },\n      {\n          \"id\": 3672367746746389626,\n          \"title\": \"I completely hate Python\",\n          \"body\": \"Python sucks (yep yep)\",\n          \"createdAt\": \"09-16-2022\"\n      }\n   ]\n   ```\n---\n9) ### Sort notes by title \n   | Endpoint                                       | HTTP Method | Content Type     | HTTP Success (Statuscode)        | HTTP Failure (Statuscode) |\n   | ---------------------------------------------- | ----------- | ---------------- | -------------------------------- | ------------------------- |\n   | http://localhost:8080/api/notes/sort?order=asc | GET         | application/json | Note array in JSON format (200)  | Auth failed (401)         | \n   \n   ##### hint: use the real JWT returend upon the successful login\n   #### Headers:\n   ```\n   Authorization: Bearer JWT\n   ```\n   #### Typical response: \n   ```json\n   [\n     {\n       \"id\" : 3672367746746389626,\n       \"title\" : \"I completely hate Python\",\n       \"body\" : \"Python sucks (yep yep)\",\n       \"createdAt\" : \"09-16-2022\"\n     },\n     {\n       \"id\" : 5746959445480553359,\n       \"title\" : \"I kinda like Java\",\n       \"body\" : \"Java rocks (kinda)\",\n       \"createdAt\" : \"09-16-2022\"\n     },\n     {\n       \"id\" : 7159997665991673534,\n       \"title\" : \"I love Scala\",\n       \"body\" : \"Scala rocks\",\n       \"createdAt\" : \"09-16-2022\"\n     },\n     {\n       \"id\" : 7043231874327471104,\n       \"title\" : \"why should I learn ZIO?\",\n       \"body\" : \"cuz [insert 5 million intelligent words here]\",\n       \"createdAt\" : \"17-09-2022\"\n     }\n   ]\n   ```\n---\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghurtchu%2Fdiary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghurtchu%2Fdiary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghurtchu%2Fdiary/lists"}