The backend for DevHub, a collaborative developer platform where users can showcase projects, participate in coding challenges, and collaborate with other developers.
- User Authentication: Secure user login and registration using JWT.
- Project Management: CRUD operations for user projects.
- Comment System: Users can comment on projects.
- MongoDB Integration: Data persistence with Mongoose.
- Validation and Error Handling: Robust request validation and centralized error handling.
- Node.js: Runtime environment.
- Express.js: Backend framework.
- TypeScript: For type safety and better developer experience.
- MongoDB: NoSQL database.
- Mongoose: ODM for MongoDB.
- Swagger UI: API documentation.
- Jest: For testing the backend logic.
-
Clone the repository:
git clone https://github.com/Skipper-116/devhub-backend.git cd devhub-backend
-
Install dependencies:
npm install
npm install -g nodemon
-
Set up environment variables: Create a
.env
file in the root directory and configure the following:cp .env.example .env
-
Start the development server:
nodemon
POST /api/v1/auth/register
: Register a new user.POST /api/v1/auth/login
: Log in a user and return a JWT.
GET /api/v1/projects
: Fetch all projects.POST /api/v1/projects
: Create a new project.GET /api/v1/projects/:id
: Fetch a single project by ID.PUT /api/v1/projects/:id
: Update a project by ID.DELETE /api/v1/projects/:id
: Delete a project by ID.
POST /api/v1/projects/:projectId/comments
: Add a comment to a project.GET /api/v1/projects/:projectId/comments
: Get comments for a project.
Run tests using Jest:
npm test
src/
├── config/ # Database and environment configurations
├── controllers/ # Route handlers
├── middlewares/ # Middleware for authentication, validation, etc.
├── models/ # Mongoose models
├── routes/ # API routes
├── utils/ # Helper functions
├── tests/ # All Tests
├── server.ts # Entry point of the application
- Deploy the backend on platforms like Render, Railway, or Cyclic.
- Set up a hosting platform account.
- Connect the GitHub repository.
- Add environment variables in the hosting platform.
- Deploy and access the backend via the provided URL.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.