{"id":21832710,"url":"https://github.com/winterrdog/odin-blog-api","last_synced_at":"2026-04-05T22:37:08.670Z","repository":{"id":232767823,"uuid":"785147603","full_name":"winterrdog/odin-blog-api","owner":"winterrdog","description":"An exercise by The Odin Project( TOP ) to create a blog. It has both a front \u0026 back end","archived":false,"fork":false,"pushed_at":"2025-07-16T10:03:17.000Z","size":1317,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-17T13:50:10.551Z","etag":null,"topics":["blog","blogging","js","micro-blog","typescript"],"latest_commit_sha":null,"homepage":"https://muchubatactics.github.io/odin-blog-api/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/winterrdog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-11T09:41:58.000Z","updated_at":"2025-07-16T10:03:14.000Z","dependencies_parsed_at":"2025-04-30T05:21:43.432Z","dependency_job_id":"a838fbd7-c15f-45b5-b60f-e9b6e5a84edf","html_url":"https://github.com/winterrdog/odin-blog-api","commit_stats":null,"previous_names":["winterrdog/odin-blog-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/winterrdog/odin-blog-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winterrdog%2Fodin-blog-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winterrdog%2Fodin-blog-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winterrdog%2Fodin-blog-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winterrdog%2Fodin-blog-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/winterrdog","download_url":"https://codeload.github.com/winterrdog/odin-blog-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/winterrdog%2Fodin-blog-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267408850,"owners_count":24082526,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["blog","blogging","js","micro-blog","typescript"],"created_at":"2024-11-27T19:25:04.475Z","updated_at":"2026-04-05T22:37:07.665Z","avatar_url":"https://github.com/winterrdog.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# odin-blog-api\n\nAn exercise by The Odin Project( TOP ) to create a blog. I only designed the backend as that's my speciality :), then [_@muchubatactics_](https://github.com/muchubatactics) did the frontend. The backend is a `REST`ful API built with `Node.js`, `React`( for the frontend ), `Express.js`, `MongoDB`, and `JWT` for authorization. It has `16+` endpoints for creating, reading, updating, and deleting users, posts, comments, and replies.\n\n**AUTHORS**: [_muchubatactics_](https://github.com/muchubatactics) \u0026 [_winterrdog_](https://github.com/winterrdog)\n\n## REQUIREMENTS\n\nMake sure you have the following installed:\n\n- `Postman` / `curl` - _for testing the API_\n- `Docker` - _for building the database(`mongodb`) and the application_\n- `Docker Compose` - _for deploying the application_. Use the new Go-based version, `docker compose` instead of the old Python-based version, `docker-compose` otherwise you will get an error unless you use some workarounds.\n\n## RUNNING BACKEND\n\n- To set up the environment variables, create a `.env` file in the root directory and copy the contents of `.env.example` into it. Then fill in the missing values.\n\n- To run the backend, run the following command:\n\n  ```bash\n  cd ./src\n  ./containerize.sh\n  ```\n\n- Stop the backend by running the following command:\n\n  ```bash\n  docker compose down\n  ```\n\n- In case you wanna run backend in production mode, run the following command:\n\n  ```bash\n  cd ./src\n  docker compose -f docker-compose.yml up\n  ```\n\n  Remember to set `MONGODB_URI` to your production database URI somewhere in the cloud in the `.env` file.\n\n- The backend will be available at `http://localhost:3000`.\n\n## VIEWING THE LOGS\n\n- To view logs, run the following command:\n\n  ```bash\n  docker logs --tail=300 -f blog_backend\n  ```\n\n- The container will also write logs to `./src/blog-app.log` external to the container.\n\n## API DOCUMENTATION\n\nThis backend has 3 features:\n\n- `Authentication` - _for creating, deleting, updating and logging in users_\n- `Posts` - _for creating, reading, updating and deleting posts_\n- `Comments` - _for creating, reading, updating and deleting comments_\n\nIt has `16+` endpoints i.e.:\n\n### User Endpoints\n\n- `POST /api/v1/users/sign-up` - _for registering a user_\n- `POST /api/v1/users/sign-in` - _for logging in a user_\n- `PATCH /api/v1/users/update` - _for updating a user details_\n- `DELETE /api/v1/users/delete` - _for deleting a user_\n- `PATCH /api/v1/users/log-out` - _for logging out a user_\n\n### Post Endpoints\n\n- `POST /api/v1/posts/` - _for creating a post_\n- `GET /api/v1/posts/user-posts` - _for getting a user's posts_\n- `GET /api/v1/posts/liked-posts` - _for getting a user's liked posts_\n- `GET /api/v1/posts/recently-viewed` - _for getting a user's 5 most recently viewed posts_\n- `GET /api/v1/posts/` - _for getting all posts_\n- `GET /api/v1/posts/:postId` - _for getting a post_\n- `PATCH /api/v1/posts/:postId` - _for updating a post_\n- `DELETE /api/v1/posts/:postId` - _for deleting a post_\n- `PATCH /api/v1/posts/:postId/likes` - _for adding a like_\n- `PATCH /api/v1/posts/:postId/dislikes` - _for adding a dislike_\n\n### Comment Endpoints\n\n- `POST /api/v1/post-comments/:postId/comments/` - _for creating a comment_\n- `GET /api/v1/post-comments/:postId/comments/` - _for getting all comments for a post_\n- `GET /api/v1/post-comments/:postId/comments/:commentId` - _for getting a comment_\n- `GET /api/v1/post-comments/user-comments` - _for getting a user's comments_\n- `GET /api/v1/post-comments/user-liked-comments` - _for getting a user's liked comments_\n- `PATCH /api/v1/post-comments/:postId/comments/:commentId` - _for updating a comment_\n- `DELETE /api/v1/post-comments/:postId/comments/:commentId` - _for deleting a comment_\n- `PATCH /api/v1/post-comments/:postId/comments/:commentId/likes` - _for adding a like_\n- `DELETE /api/v1/post-comments/:postId/comments/:commentId/likes` - _for removing a like_\n- `PATCH /api/v1/post-comments/:postId/comments/:commentId/dislikes` - _for adding a dislike_\n- `DELETE /api/v1/post-comments/:postId/comments/:commentId/dislikes` - _for removing a dislike_\n- `POST /api/v1/post-comments/:postId/comments/:commentId/replies` - _for creating a reply_\n- `PATCH /api/v1/post-comments/:postId/comments/:commentId/replies` - _for adding a reply_\n- `DELETE /api/v1/post-comments/:postId/comments/:commentId/replies/:replyId` - _for deleting a reply_\n\n### AUTHENTICATION\n\n- The API uses `JWT` for authentication. The JWT is required in the `Authorization` header for **all** requests except for `sign-up` and `sign-in` requests and for user actions that only require reading data from the server i.e `GET` requests.\n\n## SAMPLE REQUESTS\n\n- To test the API, you can use `Postman` or `curl`. Below are some sample requests:\n\n### User Requests\n\n#### Sign up a user\n\n```sh\ncurl -X POST -H \"Content-Type: application/json\" -d '{\n    \"name\": \"John Doe\",\n    \"pass\": \"password\",\n    \"role\": \"author\"\n}' http://localhost:3000/api/v1/users/sign-up\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 201 Created\n\n{\n    \"message\": \"User created successfully\",\n    \"token\": \"eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\"\n}\n```\n\n#### Sign in a user\n\n```sh\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"name\": \"John Doe\", \"pass\": \"password\"}' http://localhost:3000/api/v1/users/sign-in\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"User signed in successfully\",\n    \"token\": \"eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\"\n}\n```\n\n#### Update a user's details\n\n```sh\ncurl -X PATCH -H \"Content-Type: application/json\" -d '{\"name\": \"Jane Doe\", \"role\": \"reader\"}' http://localhost:3000/api/v1/users/update\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n  \"message\": \"User updated\",\n  \"user\": {\n    \"name\": \"Jane Doe\",\n    \"role\": \"reader\",\n    \"id\": \"6623cfc033d53b054fe9b0c3\",\n    \"dateCreated\": \"2024-04-20T14:22:56.517Z\",\n    \"dateUpdated\": \"2024-04-22T12:29:46.406Z\"\n  }\n}\n```\n\n#### Delete a user\n\n```sh\ncurl -X DELETE -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" http://localhost:3000/api/v1/users/delete\n```\n\nThe server will respond with:\n\n```json\n    HTTP/1.1 204 No Content\n```\n\n#### Log out a user\n\n```sh\ncurl -X PATCH -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" http://localhost:3000/api/v1/users/log-out\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 204 No Content\n\n```\n\n### Post Requests\n\n#### Create a post.\n\nOnly registered users can create posts. The JWT is required in the Authorization header.\n\n```sh\ncurl -X POST -H \"Content-Type: application/json\" -H \"\nAuthorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" -d '{\n    \"title\": \"My first post\",\n    \"body\": \"This is my first post. I hope you like it.\"\n}' http://localhost:3000/api/v1/posts/\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 201 Created\n\n{\n  \"message\": \"Post created successfully\",\n  \"post\": {\n    \"author\": \"John Doe\",\n    \"title\": \"My first post\",\n    \"body\": \"This is my first post. I hope you like it.\",\n    \"hidden\": false,\n    \"id\": \"662659aaa2e291b846358a06\",\n    \"dateCreated\": \"2024-04-22T12:35:54.030Z\",\n    \"dateUpdated\": \"2024-04-22T12:35:54.030Z\"\n  }\n}\n```\n\n#### Get all posts for a user\n\nMake sure the JWT is in the Authorization header since we rely on it to get the user's posts.\n\n```sh\ncurl -X GET\n    -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\"\n    http://localhost:3000/api/v1/posts/user-posts\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"User's posts retrieved successfully\",\n    \"posts\": [\n        {\n            \"author\": \"John Doe\",\n            \"title\": \"My first post\",\n            \"body\": \"This is my first post. I hope you like it.\",\n            \"hidden\": false,\n            \"id\": \"662659aaa2e291b846358a06\",\n            \"dateCreated\": \"2024-04-22T12:35:54.030Z\",\n            \"dateUpdated\": \"2024-04-22T12:35:54.030Z\"\n        }\n    ]\n}\n```\n\n#### Get all liked posts for a user\n\nMake sure the JWT is in the Authorization header since we rely on it to get the user's liked posts.\n\n```sh\ncurl -X GET\n    -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\"\n    http://localhost:3000/api/v1/posts/liked-posts\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"User's liked posts retrieved successfully\",\n    \"posts\": [\n        {\n            \"author\": \"John Doe\",\n            \"title\": \"My first post\",\n            \"body\": \"This is my first post. I hope you like it.\",\n            \"hidden\": false,\n            \"id\": \"662659aaa2e291b846358a06\",\n            \"dateCreated\": \"2024-04-22T12:35:54.030Z\",\n            \"dateUpdated\": \"2024-04-22T12:35:54.030Z\"\n        }\n    ]\n}\n```\n\n#### Get the 5 most recently viewed posts for a user\n\nMake sure the JWT is in the Authorization header since we rely on it to get the user's recently viewed posts.\n\n```sh\ncurl -X GET\n\n    -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\"\n    http://localhost:3000/api/v1/posts/recently-viewed\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"User's recently viewed posts retrieved successfully\",\n    \"posts\": [\n        {\n            \"author\": \"John Doe\",\n            \"title\": \"My first post\",\n            \"body\": \"This is my first post. I hope you like it.\",\n            \"hidden\": false,\n            \"id\": \"662659aaa2e291b846358a06\",\n            \"dateCreated\": \"2024-04-22T12:35:54.030Z\",\n            \"dateUpdated\": \"2024-04-22T12:35:54.030Z\"\n        }\n    ]\n}\n```\n\nIt will return a maximum of 5 posts. If the user has viewed less than 5 posts, it will return all the posts the user has viewed.\n\nFor the case when there's no post viewed by the user, the server will respond with a `404` status code and the following message:\n\n```json\nHTTP/1.1 404 Not Found\n\n{\n    message: \"no recently viewed posts found for user\",\n}\n```\n\n#### Get all posts\n\n```sh\ncurl -X GET http://localhost:3000/api/v1/posts/\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"Posts retrieved successfully\",\n    \"posts\": [\n        {\n            \"author\": \"John Doe\",\n            \"title\": \"My first post\",\n            \"body\": \"This is my first post. I hope you like it.\",\n            \"hidden\": false,\n            \"id\": \"662659aaa2e291b846358a06\",\n            \"dateCreated\": \"2024-04-22T12:35:54.030Z\",\n            \"dateUpdated\": \"2024-04-22T12:35:54.030Z\"\n        },\n        {\n            \"author\": \"Jane Doe\",\n            \"title\": \"My second post\",\n            \"body\": \"This is my second post. I hope you like it.\",\n            \"hidden\": false,\n            \"id\": \"662659aaa2e291b846358a07\",\n            \"dateCreated\": \"2024-04-22T12:35:54.030Z\",\n            \"dateUpdated\": \"2024-04-22T12:35:54.030Z\"\n        }\n    ]\n}\n```\n\n#### Get a post\n\n```sh\ncurl -X GET http://localhost:3000/api/v1/posts/662659aaa2e291b846358a06\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"Post retrieved successfully\",\n    \"post\": {\n        \"author\": \"John Doe\",\n        \"title\": \"My first post\",\n        \"body\": \"This is my first post. I hope you like it.\",\n        \"hidden\": false,\n        \"id\": \"662659aaa2e291b846358a06\",\n        \"dateCreated\": \"2024-04-22T12:35:54.030Z\",\n        \"dateUpdated\": \"2024-04-22T12:35:54.030Z\"\n    }\n}\n```\n\n#### Update a post\n\n```sh\ncurl -X PATCH -H \"Content-Type: application/json\" -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" -d '{\n    \"title\": \"My first post\",\n    \"body\": \"This is my first post. I hope you like it. I have updated it.\"\n}' http://localhost:3000/api/v1/posts/662659aaa2e291b846358a06\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"Post updated\",\n    \"post\": {\n        \"author\": \"John Doe\",\n        \"title\": \"My first post\",\n        \"body\": \"This is my first post. I hope you like it. I have updated it.\",\n        \"hidden\": false,\n        \"id\": \"662659aaa2e291b846358a06\",\n        \"dateCreated\": \"2024-04-22T12:35:54.030Z\",\n        \"dateUpdated\": \"2024-04-22T12:35:54.030Z\"\n    }\n}\n```\n\n#### Delete a post\n\n```sh\ncurl -X DELETE -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" http://localhost:3000/api/v1/posts/662659aaa2e291b846358a06\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 204 No Content\n```\n\n### Comment Requests\n\n#### Create a comment.\n\nOnly registered users can create comments. The JWT is required in the Authorization header.\n\n```sh\ncurl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" -d '{\n    \"body\": \"This is a great post. I love it.\"\n}' http://localhost:3000/api/v1/post-comments/662659aaa2e291b846358a07/comments/\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 201 Created\n\n{\n  \"message\": \"comment created successfully\",\n  \"comment\": {\n    \"body\": \"how does it work?\",\n    \"tldr\": \"work\",\n    \"user\": \"kaboom\",\n    \"post\": \"6623d00e33d53b054fe9b0c7\",\n    \"id\": \"66265bcda2e291b846358a17\",\n    \"dateCreated\": \"2024-04-22T12:45:01.875Z\",\n    \"dateUpdated\": \"2024-04-22T12:45:01.875Z\"\n  }\n}\n```\n\n#### Get all comments for a post\n\n```sh\ncurl -X GET http://localhost:3000/api/v1/post-comments/662659aaa2e291b846358a07/comments/\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"post comments fetched successfully\",\n    \"comments\": [\n        {\n            \"body\": \"This is a great post. I love it.\",\n            \"tldr\": \"great post\",\n            \"user\": \"John Doe\",\n            \"post\": \"662659aaa2e291b846358a07\",\n            \"id\": \"66265bcda2e291b846358a17\",\n            \"dateCreated\": \"2024-04-22T12:45:01.875Z\",\n            \"dateUpdated\": \"2024-04-22T12:45:01.875Z\"\n        }\n    ]\n}\n```\n\n#### Get all comments for a user\n\nMake sure the JWT is in the Authorization header since we rely on it to get the user's comments.\n\n```sh\ncurl -X GET\n    -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\"\n    http://localhost:3000/api/v1/post-comments/user-comments\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"user comments fetched successfully\",\n    \"comments\": [\n        {\n            \"body\": \"This is a great post. I love it.\",\n            \"tldr\": \"great post\",\n            \"user\": \"John Doe\",\n            \"post\": \"662659aaa2e291b846358a07\",\n            \"id\": \"66265bcda2e291b846358a17\",\n            \"dateCreated\": \"2024-04-22T12:45:01.875Z\",\n            \"dateUpdated\": \"2024-04-22T12:45:01.875Z\"\n        }\n    ]\n}\n```\n\n#### Get all liked comments for a user\n\nMake sure the JWT is in the Authorization header since we rely on it to get the user's liked comments.\n\n```sh\ncurl -X GET\n    -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\"\n    http://localhost:3000/api/v1/post-comments/user-liked-comments\n```\n\nOn success, the server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"user liked comments fetched successfully\",\n    \"comments\": [\n        {\n            \"body\": \"This is a great post. I love it.\",\n            \"tldr\": \"great post\",\n            \"user\": \"John Doe\",\n            \"post\": \"662659aaa2e291b846358a07\",\n            \"id\": \"66265bcda2e291b846358a17\",\n            \"dateCreated\": \"2024-04-22T12:45:01.875Z\",\n            \"dateUpdated\": \"2024-04-22T12:45:01.875Z\"\n        }\n    ]\n}\n```\n\nIn case no liked comments are found, the server will respond with:\n\n```json\nHTTP/1.1 404 Not Found\n\n{\n    \"message\": \"no comments were liked by the user\",\n}\n```\n\n#### Get a comment\n\n```sh\ncurl -X GET http://localhost:3000/api/v1/post-comments/662659aaa2e291b846358a07/comments/66265bcda2e291b846358a17\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"comment fetched successfully\",\n    \"comment\": {\n        \"body\": \"This is a great post. I love it.\",\n        \"tldr\": \"great post\",\n        \"user\": \"John Doe\",\n        \"post\": \"662659aaa2e291b846358a07\",\n        \"id\": \"66265bcda2e291b846358a17\",\n        \"dateCreated\": \"2024-04-22T12:45:01.875Z\",\n        \"dateUpdated\": \"2024-04-22T12:45:01.875Z\"\n    }\n}\n```\n\n#### Update a comment\n\n```sh\ncurl -X PATCH -H \"Content-Type: application/json\" -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" -d '{\n    \"body\": \"This is a great post. I love it. I have updated it.\"\n}' http://localhost:3000/api/v1/post-comments/662659aaa2e291b846358a07/comments/66265bcda2e291b846358a17\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"post comment updated successfully\",\n    \"comment\": {\n        \"body\": \"This is a great post. I love it. I have updated it.\",\n        \"tldr\": \"great post\",\n        \"user\": \"John Doe\",\n        \"post\": \"662659aaa2e291b846358a07\",\n        \"id\": \"66265bcda2e291b846358a17\",\n        \"dateCreated\": \"2024-04-22T12:45:01.875Z\",\n        \"dateUpdated\": \"2024-04-22T12:45:01.875Z\"\n    }\n}\n```\n\n#### Delete a comment\n\n```sh\ncurl -X DELETE -H \"Authorization: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" http://localhost:3000/api/v1/post-comments/662659aaa2e291b846358a07/comments/66265bcda2e291b846358a17\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 204 No Content\n```\n\n#### Add a like to a comment\n\n```sh\ncurl -X PATCH\n-H \"Authorization\n: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" http://localhost:3000/api/v1/post-comments/662659aaa2e291b846358a07/comments/66265bcda2e291b846358a17/likes\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"like added successfully\",\n    \"comment\": {\n        \"body\": \"This is a great post. I love it. I have updated it.\",\n        \"tldr\": \"great post\",\n        \"user\": \"John Doe\",\n        \"post\": \"662659aaa2e291b846358a07\",\n        \"id\": \"66265bcda2e291b846358a17\",\n        \"dateCreated\": \"2024-04-22T12:45:01.875Z\",\n        \"dateUpdated\": \"2024-04-22T12:45:01.875Z\",\n        \"likes\": 1,\n        \"dislikes\": 0\n    }\n}\n```\n\n#### Remove a like from a comment\n\n```sh\ncurl -X DELETE\n-H \"Authorization\n: Bearer eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InN1YiI6IjY2MjY1NWMxYTJlMjkxYjg0NjM1ODlmZSIsInJvbGUiOiJhdXRob3IifSwiaWF0IjoxNzEzNzg4MzUzLCJleHAiOjE3MTM5NjExNTN9.8oc3DOAR6SqaWUBynMZlAvHJr202cTXbtiq80EVyO5RSXMJrdGJ-aWdZF_lfR1p4\" http://localhost:3000/api/v1/post-comments/662659aaa2e291b846358a07/comments/66265bcda2e291b846358a17/likes\n```\n\nThe server will respond with:\n\n```json\nHTTP/1.1 200 OK\n\n{\n    \"message\": \"like removed successfully\",\n    \"comment\": {\n        \"body\": \"This is a great post. I love it. I have updated it.\",\n        \"tldr\": \"great post\",\n        \"user\": \"John Doe\",\n        \"post\": \"662659aaa2e291b846358a07\",\n        \"id\": \"66265bcda2e291b846358a17\",\n        \"dateCreated\": \"2024-04-22T12:45:01.875Z\",\n        \"dateUpdated\": \"2024-04-22T12:45:01.875Z\",\n        \"likes\": 0,\n        \"dislikes\": 0\n    }\n}\n```\n\n#### DISLIKES\n\nThey follow the same pattern as likes. The only difference is that they are for disliking a comment. The endpoints change from `likes` to `dislikes` but the method remains the same.\n\n#### REPLIES\n\nThey follow the same pattern as comments. The only difference is that they are nested under comments.\n\nLICENSE: [Unlicense](https://unlicense.org)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinterrdog%2Fodin-blog-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwinterrdog%2Fodin-blog-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwinterrdog%2Fodin-blog-api/lists"}