{"id":17712604,"url":"https://github.com/mlsakiit/devblogs-backend","last_synced_at":"2025-07-29T00:06:11.802Z","repository":{"id":257909359,"uuid":"871928923","full_name":"MLSAKIIT/devblogs-backend","owner":"MLSAKIIT","description":"DevBlogs : A blogging website made for developers by developers. This repository contains the backend for the project","archived":false,"fork":false,"pushed_at":"2024-10-31T20:32:53.000Z","size":111,"stargazers_count":3,"open_issues_count":2,"forks_count":14,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T14:58:05.385Z","etag":null,"topics":["authentication","backend","beginner-friendly","express","expressjs","full-stack","hacktoberfest","hacktoberfest2024","jwt","jwt-authentication","mongodb","mongoose","mvc","mvc-architecture","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/MLSAKIIT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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-10-13T10:45:54.000Z","updated_at":"2024-10-31T20:23:45.000Z","dependencies_parsed_at":"2024-10-25T10:19:56.009Z","dependency_job_id":"fe4bd651-cc37-44f6-9a68-d276eae59240","html_url":"https://github.com/MLSAKIIT/devblogs-backend","commit_stats":null,"previous_names":["mlsakiit/devblogs-backend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MLSAKIIT%2Fdevblogs-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MLSAKIIT%2Fdevblogs-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MLSAKIIT%2Fdevblogs-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MLSAKIIT%2Fdevblogs-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MLSAKIIT","download_url":"https://codeload.github.com/MLSAKIIT/devblogs-backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252964358,"owners_count":21832673,"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":["authentication","backend","beginner-friendly","express","expressjs","full-stack","hacktoberfest","hacktoberfest2024","jwt","jwt-authentication","mongodb","mongoose","mvc","mvc-architecture","nodejs"],"created_at":"2024-10-25T09:05:43.420Z","updated_at":"2025-05-07T22:29:04.772Z","avatar_url":"https://github.com/MLSAKIIT.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DevBlogs Backend\n\n## Overview\n\nThis is the backend API for DevBlogs, a Full Stack Blogging site for Developers by Developers. It's part of the MLSA HACKTOBER 2024: WEBDEV project.\n\n## Tech Stack\n\n- Express.js as the web application framework\n- MongoDB for database management\n- Mongoose for MongoDB object modeling\n- JSON Web Tokens (JWT) for authentication\n- Swagger for API documentation\n\n## Features\n\n1. User authentication and authorization\n2. Blog post creation and retrieval\n3. Pagination for blog posts\n4. Request body validation\n5. Rate limiting\n6. CORS protection\n7. API documentation with Swagger\n\n## Prerequisites\n\n- Node.js\n- npm or yarn\n- MongoDB\n\n## Getting Started\n\n1. Clone the repository to your local machine.\n2. Navigate to the backend directory of the project.\n3. Install the required dependencies:\n   ```\n   npm install\n   ```\n   or\n   ```\n   yarn install\n   ```\n4. Set up your environment variables:\n   - Create a `.env` file in the backend directory.\n   - Add necessary variables such as `MONGODB_URI` and `JWT_SECRET`.\n5. Start the server:\n   ```\n   npm run dev\n   ```\n   or\n   ```\n   yarn dev\n   ```\n6. The backend should now be running, typically on http://localhost:3000.\n7. Access the Swagger documentation at http://localhost:3000/api-docs.\n\n## Installation with Docker\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/MLSAKIIT/devblogs-backend.git\n   ```\n\n2. Navigate to the project directory:\n   ```bash\n   cd devblogs-backend\n   ```\n\n3. Configure your .env file:\n\n   *Before running Docker, ensure you have correctly set up your environment variables.*\n\n4. Run the following command to start the application:\n   ```bash\n   docker compose up -d   \n   ```\n\n## Folder Structure\n\n```\n.\n└── src/\n    ├── controllers/\n    │   ├── auth.js\n    │   └── blog.js\n    ├── index.js\n    ├── middlewares/\n    │   ├── errorHandler.js\n    │   └── verifyTokenMiddleware.js\n    ├── models/\n    │   ├── Blogs.js\n    │   └── User.js\n    ├── routes/\n    │   ├── auth.js\n    │   ├── blog.js\n    │   └── verify.js\n    ├── utils/\n    │   ├── jwtHelper.js\n    │   └── rateLimit.js\n    └── validators/\n        ├── login.js\n        └── register.js\n```\n\n## API Routes\n\n- `/register`: User registration\n- `/login`: User login\n- `/verify`: Verify JWT token\n- `/change-password`: Change user password\n- `/get-blogs`: Retrieve blog posts (with pagination)\n- `/create-blog`: Create a new blog post (protected route)\n- `/get-featured-blog`: Retrieve featured blog posts\n\nFor detailed API documentation, refer to the Swagger UI at `/api-docs` when the server is running.\n\n## Contributing\n\nWe welcome contributions to improve this project! Here's how you can contribute:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## Issues \u0026 Features\n- User authentication with hashed passwords.\n- Input validation with `joi`.\n- Rate limiting and CORS protection.\n- Route protection using middleware.\n- Swagger for API documentation.\n- Error handling middleware.\n  \nCheck the main project documentation for a list of current issues and tasks for the backend.\n\n## References\n\n- Mongoose with Express:\n  - https://www.youtube.com/watch?v=_7UQPve99r4\n  - https://www.mongodb.com/resources/languages/express-mongodb-rest-api-tutorial\n- Authentication (JWT):\n  - https://www.geeksforgeeks.org/how-to-implement-jwt-authentication-in-express-js-app/\n  - https://www.youtube.com/watch?v=mbsmsi7l3r4\n- Route protection through middleware:\n  - https://expressjs.com/en/guide/writing-middleware.html\n  - https://dvmhn07.medium.com/jwt-authentication-in-node-js-a-practical-guide-c8ab1b432a49\n- Dynamic routes in Express:\n  - https://sourcebae.com/blog/how-dynamic-routing-works-in-express-js/\n  - https://www.scaler.com/topics/expressjs-tutorial/express-query-params/\n- Express rate limiting:\n  - https://www.npmjs.com/package/express-rate-limit\n  - https://blog.appsignal.com/2024/04/03/how-to-implement-rate-limiting-in-express-for-nodejs.html\n- Validation using JOI:\n  - https://www.npmjs.com/package/express-joi-validation\n  - https://abbaslanbay.medium.com/introduction-to-joi-validation-in-node-js-express-c33eba38f4ae\n- Pagination:\n  - https://javascript.works-hub.com/learn/how-to-create-a-paginated-api-with-mongodb-and-node-js-6e1e3\n  - https://www.geeksforgeeks.org/how-to-paginate-with-mongoose-in-node-js/\n- Express CORS:\n  - https://dev.to/speaklouder/how-to-configure-cors-in-nodejs-with-express-11h\n- Error Handling in Express:\n  - https://expressjs.com/en/guide/error-handling.html\n  - https://www.turing.com/kb/how-to-master-express-js-error-handling\n- Middlewares:\n  - https://www.geeksforgeeks.org/middleware-in-express-js/\n- Swagger Documentation:\n  - https://swagger.io/docs/specification/about/\n  - https://www.npmjs.com/package/swagger-ui-express\n  - https://www.npmjs.com/package/swagger-jsdoc","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlsakiit%2Fdevblogs-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlsakiit%2Fdevblogs-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlsakiit%2Fdevblogs-backend/lists"}