{"id":20617854,"url":"https://github.com/joozef315/blogshub-api","last_synced_at":"2026-04-08T16:01:40.118Z","repository":{"id":226677913,"uuid":"769359629","full_name":"JooZef315/BlogsHub-API","owner":"JooZef315","description":"API for a blogs app using Express and MongoDB ","archived":false,"fork":false,"pushed_at":"2024-09-22T18:10:17.000Z","size":1397,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T19:44:12.990Z","etag":null,"topics":["api","blog","express","jwt","mongodb","mongoose","multer","nodejs","typescript","zod"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JooZef315.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}},"created_at":"2024-03-08T22:12:07.000Z","updated_at":"2024-09-22T18:10:21.000Z","dependencies_parsed_at":"2024-06-10T17:30:34.481Z","dependency_job_id":"1ef4d225-ab26-4b8f-9086-374808f295c3","html_url":"https://github.com/JooZef315/BlogsHub-API","commit_stats":null,"previous_names":["joozef315/blogshub-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JooZef315/BlogsHub-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JooZef315%2FBlogsHub-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JooZef315%2FBlogsHub-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JooZef315%2FBlogsHub-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JooZef315%2FBlogsHub-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JooZef315","download_url":"https://codeload.github.com/JooZef315/BlogsHub-API/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JooZef315%2FBlogsHub-API/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31562697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","blog","express","jwt","mongodb","mongoose","multer","nodejs","typescript","zod"],"created_at":"2024-11-16T12:06:16.600Z","updated_at":"2026-04-08T16:01:40.101Z","avatar_url":"https://github.com/JooZef315.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BlogsHub\n\n## Express API for Blogs App\n\nThis Express API serves as the backend for a blogs application, providing endpoints for managing blog posts, users, authentication, and more. It utilizes TypeScript for type safety, Mongoose as an ORM for MongoDB database management, Zod for input validation, Multer for file uploads, Nodemailer and MailerSend for password reset functionality with rate limiting, and JWT with refresh tokens for authentication, including roles-based authorization. In development mode, it uses Nodemon for automatic server restarts.\n\n## Features\n\n- **User Authentication and Management**:\n  - Users can sign up and sign in.\n  - Users can reset passwords.\n  - Users can **follow** other users.\n- **Blog Post Management**:\n  - Each user can add, edit, and delete their own blog posts.\n  - Each blog post has a cover image, likes, and comments.\n  - Users can comment on any blog post.\n  - Users can **like/unlike** blogs.\n- **Comments with Replies**:\n  - Comments can have **Replies** (nested comments).\n- **Authorization and Roles**:\n  - JWT with refresh tokens is used for authentication.\n  - Roles-based authorization is implemented, with admin privileges to delete any blog, comment, or user.\n- **File Uploads**:\n  - Users can upload profile images for their profiles using Multer.\n  - Users can upload cover images for their blog posts using Multer.\n- **Email Functionality**:\n  - Nodemailer and MailerSend are used for password reset functionality with **rate limiting**.\n\n## Technologies Used\n\n- **Docker**\n- **Express.js**\n- **TypeScript**\n- **MongoDB**\n- **Mongoose**\n- **JWT (JSON Web Tokens)**\n- **Zod**\n- **Multer**\n- **Nodemailer**\n- **Rate Limiting**\n- **Nodemon**\n- **MailerSend**\n- **Uploadcare**\n\n## Configuration\n\nAdd `.env` file and fill in the necessary environment variables.\n\n```\nENVIRONMENT =\nPORT =\nDATABASE_URI =\n\nACCESS_TOKEN_SECRET =\nREFRESH_TOKEN_SECRET =\n\nEMAIL_HOST =\nEMAIL_PORT =\nEMAIL_USERNAME =\nEMAIL_PASSWORD =\nEMAIL_FROM =\n\nUPLOADCARE_SECRET =\n```\n\n## Installation \u0026 Usage\n\n1. Clone the repository:\n\n   ```\n   git clone https://github.com/JooZef315/BlogsHub-API\n   ```\n\n2. Navigate to the project directory:\n\n   ```\n   cd \u003cproject-directory\u003e\n   ```\n\n3. Install dependencies:\n\n   ```\n   npm install\n   ```\n\n4. To start the server in development mode with nodemon, run:\n\n   ```\n   npm run dev\n   ```\n\n### Or using Docker\n\nTo start the server in development mode with Docker, run:\n\n```\ndocker build -t blogshub-image .\n```\n\n```\ndocker run -d --name blogshub-container -v ${PWD}:/app -p \u003cPORT_NUM\u003e:\u003cPORT_NUM\u003e --env-file .env blogshub-image\n```\n\n## API Endpoints\n\nDetailed documentation for API endpoints can be found in the [API Documentation](#api-documentation) section below.\n\n## API Documentation\n\n### Authentication\n\n1. **Register a new user**\n\n   - **Description**: Register a new user.\n   - **Method**: POST\n   - **Route**: /api/v1/users/\n   - **Access**: Public\n   - **Output**: Success message\n\n2. **Authenticate a user**\n\n   - **Description**: Authenticate a user and get JWT token.\n   - **Method**: POST\n   - **Route**: /api/v1/auth/login\n   - **Access**: Public\n   - **Output**: JWT token\n\n3. **Logout a user**\n\n   - **Description**: Logout a user.\n   - **Method**: POST\n   - **Route**: /api/v1/auth/logout\n   - **Access**: Private\n   - **Output**: Success message\n\n4. **Refresh the access token**\n\n   - **Description**: Refresh the access token.\n   - **Method**: GET\n   - **Route**: /api/v1/auth/refresh\n   - **Access**: Private\n   - **Output**: Access token\n\n5. **Send an email to reset password**\n\n   - **Description**: Send an email to reset password.\n   - **Method**: GET\n   - **Route**: /api/v1/auth/forget-password\n   - **Access**: Public\n   - **Query Parameters**:\n   - email (string): User email\n   - **Output**: Success message\n\n6. **Reset password**\n\n   - **Description**: Reset password.\n   - **Method**: PUT\n   - **Route**: /api/v1/auth/reset-password\n   - **Access**: Public\n\n### Users\n\n1. **Get all Users**\n\n   - **Description**: get all users.\n   - **Method**: GET\n   - **Route**: /api/v1/users\n   - **Access**: Private (admins)\n   - **Output**: users\n\n2. **Get a user**\n\n   - **Description**: get a user.\n   - **Method**: GET\n   - **Route**: /api/v1/users/:id\n   - **Access**: Private\n   - **Parameters**:\n     - id (string): User ID.\n   - **Query Parameters**:\n     - full (boolean): Optional. to fully populate the user.\n   - **Output**: user\n\n3. **Update a user**\n\n   - **Description**: get a user.\n   - **Method**: PUT\n   - **Route**: /api/v1/users/:id\n   - **Access**: Private\n   - **Parameters**:\n     - id (string): User ID.\n   - **Output**: Success message\n\n4. **Delete a user**\n\n   - **Description**: Delete a user.\n   - **Method**: DELETE\n   - **Route**: /api/v1/users/:id\n   - **Access**: Private\n   - **Parameters**:\n     - id (string): User ID.\n   - **Output**: Success message\n\n5. **Follow/unfollow a user**\n\n   - **Description**: Follow/unfollow a user.\n   - **Method**: POST\n   - **Route**: /api/v1/users/:id/follow\n   - **Access**: Private\n   - **Parameters**:\n     - id (string): User ID.\n   - **Output**: Success message\n\n6. **Change user/ admin roles**\n\n   - **Description**: change user/ admin roles.\n   - **Method**: PUT\n   - **Route**: /api/v1/users/:id/admin\n   - **Access**: Private (admins)\n   - **Parameters**:\n     - id (string): User ID.\n   - **Output**: Success message\n\n### Blogs\n\n1. **Get all Blogs**\n\n   - **Description**: get all blogs.\n   - **Method**: GET\n   - **Route**: /api/v1/blogs\n   - **Access**: Public\n   - **Query Parameters**:\n     - authorid (string): Optional. to filter by the user.\n     - tag (boolean): Optional. to filter by tags.\n     - page (number): Optional. for pagination.\n   - **Output**: blogs\n\n2. **Create new Blog**\n\n   - **Description**: create new blog.\n   - **Method**: POST\n   - **Route**: /api/v1/blogs\n   - **Access**: Private\n   - **Output**: blog\n\n3. **Get a Blog**\n\n   - **Description**: get a blog.\n   - **Method**: GET\n   - **Route**: /api/v1/blogs/:bid\n   - **Access**: Public\n   - **Parameters**:\n     - bid (string): Blog ID.\n   - **Output**: blog\n\n4. **Update a blog**\n\n   - **Description**: Update a blog.\n   - **Method**: PUT\n   - **Route**: /api/v1/blogs/:bid\n   - **Access**: Private\n   - **Parameters**:\n     - bid (string): Blog ID.\n   - **Output**: Success message\n\n5. **Delete a blog**\n\n   - **Description**: Delete a blog.\n   - **Method**: DELETE\n   - **Route**: /api/v1/blogs/:bid\n   - **Access**: Private\n   - **Parameters**:\n     - bid (string): Blog ID.\n   - **Output**: Success message\n\n6. **Get followed Blogs**\n\n   - **Description**: get blogs from users you follow.\n   - **Method**: GET\n   - **Route**: /api/v1/blogs/followed-blogs\n   - **Access**: Private\n   - **Query Parameters**:\n     - page (number): Optional. for pagination.\n   - **Output**: blogs\n\n7. **Like/unlike a blog**\n\n   - **Description**: like/unlike a blog.\n   - **Method**: POST\n   - **Route**: /api/v1/blogs/:bid/like\n   - **Access**: Private\n   - **Parameters**:\n     - bid (string): Blog ID.\n   - **Output**: Success message\n\n8. **Get all comments for a blog**\n\n   - **Description**: get all comments for a blog.\n   - **Method**: GET\n   - **Route**: /api/v1/blogs/:bid/comments\n   - **Access**: Private\n   - **Parameters**:\n     - bid (string): Blog ID.\n   - **Query Parameters**:\n     - nested (boolean): Optional. to get the comments nested.\n   - **Output**: comments\n\n9. **create new comment**\n\n   - **Description**: create new comment.\n   - **Method**: POST\n   - **Route**: /api/v1/blogs/:bid/comments\n   - **Access**: Private\n   - **Parameters**:\n     - bid (string): Blog ID.\n   - **Output**: new comments\n\n10. **get a single comment**\n\n    - **Description**: create new comment.\n    - **Method**: GET\n    - **Route**: /api/v1/blogs/:bid/comments/:cid\n    - **Access**: Private\n    - **Parameters**:\n      - bid (string): Blog ID.\n      - cid (string): Comment ID.\n    - **Output**: new comments\n\n11. **updata a comment**\n\n    - **Description**: updata a comment.\n    - **Method**: PUT\n    - **Route**: /api/v1/blogs/:bid/comments\n    - **Access**: Private\n    - **Parameters**:\n      - bid (string): Blog ID.\n      - cid (string): Comment ID.\n    - **Output**: Success message\n\n12. **Delete a comment**\n\n    - **Description**: updata a comment.\n    - **Method**: DELETE\n    - **Route**: /api/v1/blogs/:bid/comments/:cid\n    - **Access**: Private\n    - **Parameters**:\n      - bid (string): Blog ID.\n      - cid (string): Comment ID.\n    - **Output**: Success message\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoozef315%2Fblogshub-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoozef315%2Fblogshub-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoozef315%2Fblogshub-api/lists"}