A robust Node.js/Express.js backend API for a developer collaboration platform, built with TypeScript, MongoDB, and modern development practices.
- User Registration & Login: Secure user authentication with JWT tokens
- Email Verification: Email-based account verification system
- Password Management: Secure password hashing with bcrypt
- Profile Management: User profile CRUD operations with avatar support
- Session Management: JWT-based session handling
- Project CRUD: Create, read, update, and delete projects
- Collaboration System: Add/remove project collaborators
- Project Ownership: Secure project access control
- Activity Tracking: Project activity logging (prepared for future use)
- Task CRUD: Comprehensive task management system
- Priority Levels: Low, medium, high priority support
- Assignment System: Assign tasks to team members
- Due Date Tracking: Task deadline management
- Status Management: Track task completion status
- Real-time Chat: Project-based chat system
- Comment System: Task and project commenting
- Collaboration Requests: Send and manage collaboration invitations
- Notification System: User notifications for various events
- Discussion Forums: Topic-based discussion system
- Pre-defined Topics: Default topics for common developer subjects
- Community Engagement: Public discussion participation
- TypeScript: Full TypeScript support with strict type checking
- MongoDB Integration: Mongoose ODM with MongoDB
- File Upload: Cloudinary integration for image storage
- Email Services: Nodemailer-based email functionality
- Input Validation: Zod schema validation
- Middleware System: Authentication and validation middleware
- Error Handling: Comprehensive error handling and logging
dev-server/
โโโ src/
โ โโโ app/ # Express app configuration
โ โโโ controllers/ # Business logic controllers
โ โโโ middleware/ # Custom middleware functions
โ โโโ models/ # MongoDB/Mongoose models
โ โโโ routes/ # API route definitions
โ โโโ schemas/ # Zod validation schemas
โ โโโ types/ # TypeScript type definitions
โ โโโ utils/ # Utility functions
โ โโโ app.ts # Express app setup
โ โโโ server.ts # Server entry point
โโโ tests/ # Test suite (Jest + Supertest)
โโโ dist/ # Compiled JavaScript output
โโโ package.json # Dependencies and scripts
โโโ tsconfig.json # TypeScript configuration
โโโ README.md # This file
- Runtime: Node.js
- Framework: Express.js 5.x
- Language: TypeScript 5.x
- Database: MongoDB with Mongoose ODM
- Authentication: JWT (JSON Web Tokens)
- Validation: Zod schema validation
- File Storage: Cloudinary
- Email: Nodemailer
- Testing: Jest + Supertest
- Development: Nodemon + ts-node-dev
- Node.js 18+
- MongoDB instance (local or cloud)
- Cloudinary account (for file uploads)
- Gmail account (for email services)
-
Clone the repository
git clone <repository-url> cd devcollab/dev-server
-
Install dependencies
npm install
-
Environment Configuration
cp env.example .env
Fill in your environment variables:
PORT=5000 MONGO_URI=mongodb://localhost:27017/devcollab JWT_SECRET=your-super-secret-jwt-key EMAIL_USER=your-gmail@gmail.com EMAIL_APP_PASSWORD=your-gmail-app-password CLOUDINARY_CLOUD_NAME=your-cloud-name CLOUDINARY_API_KEY=your-api-key CLOUDINARY_API_SECRET=your-api-secret
-
Database Setup
- Ensure MongoDB is running
- The application will automatically create collections
-
Start Development Server
npm run dev
npm run dev- Start development server with hot reloadnpm run build- Build TypeScript to JavaScriptnpm start- Start production servernpm test- Run test suitenpm run test:watch- Run tests in watch modenpm run test:coverage- Generate test coverage report
http://localhost:5000/v1/api
All protected routes require a valid JWT token in the Authorization header:
Authorization: Bearer <your-jwt-token>
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /register |
User registration | No |
| POST | /login |
User login | No |
| GET | /verify-email/:token |
Email verification | No |
| POST | /resend-verification |
Resend verification email | No |
| GET | /profile |
Get current user profile | Yes |
| GET | /users/:id |
Get user by ID | Yes |
| PUT | /users/:id |
Update user profile | Yes |
| DELETE | /users/:id |
Delete user account | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | / |
Get user's projects | Yes |
| GET | /:projectId |
Get project by ID | Yes |
| POST | /create |
Create new project | Yes |
| PUT | /update/:projectId |
Update project | Yes |
| DELETE | /:projectId |
Delete project | Yes |
| DELETE | /:projectId/:collaboratorId |
Remove collaborator | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | / |
Get user's tasks | Yes |
| GET | /:taskId |
Get task by ID | Yes |
| POST | /create |
Create new task | Yes |
| PUT | /update/:taskId |
Update task | Yes |
| DELETE | /:taskId |
Delete task | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /:commentId |
Get comment by ID | Yes |
| POST | /create |
Create new comment | Yes |
| PUT | /update/:commentId |
Update comment | Yes |
| DELETE | /:commentId |
Delete comment | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | / |
Get all discussions | No |
| GET | /:discussionId |
Get discussion by ID | No |
| POST | /create |
Create new discussion | Yes |
| PUT | /update/:discussionId |
Update discussion | Yes |
| DELETE | /:discussionId |
Delete discussion | Yes |
| POST | /:discussionId/topic |
Add new topic | Yes |
| POST | /:discussionId/discussion |
Add discussion text | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | / |
Get user notifications | Yes |
| PUT | /:notificationId/read |
Mark as read | Yes |
| DELETE | /:notificationId |
Delete notification | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /send |
Send message | Yes |
| GET | /conversation/:userId |
Get conversation | Yes |
| GET | /conversations |
Get all conversations | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /request |
Send collaboration request | Yes |
| GET | /requests |
Get collaboration requests | Yes |
| PUT | /accept/:requestId |
Accept request | Yes |
| PUT | /reject/:requestId |
Reject request | Yes |
interface IUser {
name: string;
image?: string;
email: string;
password: string;
isVerified: boolean;
verificationToken?: string;
verificationExpires?: Date;
projects?: ObjectId[];
createdAt: Date;
updatedAt: Date;
}interface IProject {
title: string;
description: string;
owner: ObjectId;
collaborators: ObjectId[];
createdAt: Date;
updatedAt: Date;
}interface ITask {
title: string;
description: string;
assignees?: ObjectId[];
project: ObjectId;
createdBy: ObjectId;
dueDate?: Date;
priority: 'low' | 'medium' | 'high';
comments: ObjectId[];
createdAt: Date;
updatedAt: Date;
}interface IDiscussion {
name: string;
description: string;
topics: string[];
discussion: string[];
createdAt: Date;
updatedAt: Date;
}- JWT Authentication: Secure token-based authentication
- Password Hashing: Bcrypt password encryption
- Input Validation: Zod schema validation for all inputs
- CORS Protection: Configurable CORS settings
- Rate Limiting: Built-in Express rate limiting
- SQL Injection Protection: MongoDB with parameterized queries
- XSS Protection: Input sanitization and validation
The project includes a comprehensive test suite:
- Unit Tests: Individual function testing
- Integration Tests: API endpoint testing
- Test Coverage: Jest coverage reporting
- Test Utilities: Helper functions for test data creation
- Database Testing: Isolated test database environment
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Generate coverage report
npm run test:coveragenpm run build
npm start- Set
NODE_ENV=production - Use strong JWT secrets
- Configure production MongoDB URI
- Set up production email services
- Configure production Cloudinary settings
The project can be containerized using Docker:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 5000
CMD ["npm", "start"]- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the ISC License.
For support and questions:
- Create an issue in the repository
- Check the troubleshooting guide
- Review the API documentation
- Real-time WebSocket support
- Advanced search and filtering
- File sharing system
- Project templates
- Advanced analytics
- Mobile app support
- Third-party integrations
- Advanced permission system
DevCollab - Empowering developers to collaborate effectively! ๐