This is the backend server for the job posting platform. It handles authentication, job posting, application management, contact management, and messaging functionality. It uses Express.js for API routes and MongoDB for data storage.
- User authentication (registration, login, JWT token-based)
- Job posting and job application management
- Contact management (add, remove, list contacts)
- Messaging system (chat functionality between users)
- Real-time updates with Socket.IO for messaging
- Node.js
- Express.js
- MongoDB
- JWT Authentication
- Socket.IO for real-time messaging
- Mongoose (MongoDB ODM)
-
Clone the repository:
git clone https://github.com/yourusername/job-platform-backend.git cd job-platform-backend
-
Install dependencies:
npm install
-
Set up environment variables:
Add the following variables:
JWT_SECRET=your_jwt_secret MONGO_URI=your_mongodb_connection_string *Start the server:
npm start The server will run on http://localhost:5000.
Request Body:
{ "name": "John Doe", "age": 25, "username": "johndoe", "email": "[email protected]", "password": "password123" } Response:
{ "token": "jwt_token_here", "user": { "id": "user_id", "username": "johndoe", "name": "John Doe" } } Error Response: 400: Missing required fields 409: User already exists 500: Server error
Request Body:
{ "email": "[email protected]", "password": "password123" } Response:
{ "token": "jwt_token_here", "user": { "id": "user_id", "username": "johndoe", "name": "John Doe" } } Error Response: 400: Missing required fields 401: Invalid credentials 500: Server error
Request Body:
{ "receiverId": "receiver_user_id" } Response:
{ "message": "Contact added successfully", "contact": { "userId": "sender_user_id", "contacts": [ { "contactId": "receiver_user_id" } ] } } Error Response: 400: Missing required field (receiverId) 500: Server error
Response:
{ "contacts": [ { "contactId": "contact_user_id", "name": "Contact Name", "email": "[email protected]" } ] } Error Response: 404: No contacts found 500: Server error
Request Body:
{ "receiverId": "contact_user_id", "action": "add" // or "remove" } Response:
{ "message": "Contact added successfully", "contact": { "userId": "sender_user_id", "contacts": [ { "contactId": "contact_user_id" } ] } } Error Response: 400: Missing required fields 500: Server error
Response:
[ { "_id": "job_id", "title": "Job Title", "description": "Job Description", "amount": 100, "location": "Job Location", "date": "Job Date", "time": "Job Time", "employer": { "username": "employer_username", "email": "[email protected]" } } ] Error Response: 500: Server error
Response:
{ "appliedJobs": [ { "_id": "job_id", "title": "Job Title", "status": "open" } ], "postedJobs": [ { "_id": "job_id", "title": "Job Title", "applicants": [ { "user": "applicant_user_id", "name": "Applicant Name" } ] } ] } Error Response: 500: Server error
Request Body:
{ "title": "Job Title", "description": "Job Description", "amount": 100, "location": "Location", "date": "Job Date", "time": "Job Time", "lat": 12.34, "lng": 56.78 } Response:
{ "_id": "job_id", "title": "Job Title", "description": "Job Description", "amount": 100, "location": "Location", "date": "Job Date", "time": "Job Time" } Error Response: 400: Missing required fields 500: Server error
Request Body:
{ "comments": "I am interested in this job." } Response:
{ "message": "Application submitted successfully" } Error Response: 400: Cannot apply to a closed job 500: Server error
Response:
{ "message": "Applicant accepted successfully" } Error Response: 500: Server error
Response:
{ "message": "Applicant rejected successfully" } Error Response: 500: Server error
Request Body:
{ "senderId": "sender_user_id", "receiverId": "receiver_user_id", "content": "Hello, I am interested in your job post." } Response:
{ "success": true, "message": "Message sent successfully", "data": { "senderId": "sender_user_id", "receiverId": "receiver_user_id", "content": "Hello, I am interested in your job post." } } Error Response: 500: Server error
Response:
[ { "senderId": "sender_user_id", "receiverId": "receiver_user_id", "content": "Hello", "timestamp": "timestamp_here" } ] Error Response: 500: Server error
If you would like to contribute to this project, please fork the repository, create a new branch, and submit a pull request with your changes. For anyfurther interaction mail me [email protected]