A RESTful API for managing job applications built with Node.js, Express, and MongoDB. This API allows users to track their job applications with features like authentication, CRUD operations, and security measures.
- User Authentication: Secure registration and login with JWT
- Job Management: Create, read, update, and delete job applications
- Security: Rate limiting, CORS, Helmet protection
- User-specific Data: Each user can only access their own jobs
- Input Validation: Mongoose schema validation
- Error Handling: Comprehensive error handling middleware
- Node.js (v14 or higher)
- MongoDB database
- npm or yarn package manager
- Clone the repository:
git clone https://github.com/yourusername/jobs-api.git
cd jobs-api- Install dependencies:
npm install- Create a
.envfile in the root directory:
PORT=3000
DB_URL=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
EXPIREIN=30d- Start the server:
npm startPOST /api/v1/auth/register
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123"
}POST /api/v1/auth/login
Content-Type: application/json
{
"email": "john@example.com",
"password": "password123"
}POST /api/v1/jobs
Authorization: Bearer <your_token>
Content-Type: application/json
{
"company": "Tech Company",
"position": "Software Engineer",
"status": "pending"
}GET /api/v1/jobs
Authorization: Bearer <your_token>GET /api/v1/jobs/:id
Authorization: Bearer <your_token>PATCH /api/v1/jobs/:id
Authorization: Bearer <your_token>
Content-Type: application/json
{
"company": "Updated Company",
"position": "Senior Developer",
"status": "interview"
}DELETE /api/v1/jobs/:id
Authorization: Bearer <your_token>{
name: String (required, 3-50 chars),
email: String (required, unique, valid email),
password: String (required, min 6 chars, hashed)
}{
company: String (required, max 50 chars),
position: String (required, max 100 chars),
status: String (enum: ['pending', 'interview', 'declined'], default: 'pending'),
createdBy: ObjectId (reference to User),
timestamps: true
}- Helmet: Sets various HTTP headers for security
- CORS: Enables Cross-Origin Resource Sharing
- Rate Limiting: Limits requests to 100 per 15 minutes
- JWT Authentication: Secure token-based authentication
- Password Hashing: Uses bcrypt for password encryption
├── controllers/
│ ├── auth.controller.js
│ └── jobs.controller.js
├── database/
│ └── connect.js
├── errors/
│ ├── bad-request.js
│ ├── custom-error.js
│ ├── notFoundError.js
│ ├── unAuthError.js
│ └── index.js
├── middleware/
│ ├── asyncWrapper.js
│ ├── authentication.js
│ ├── errorHandler.js
│ └── notFoundHandler.js
├── models/
│ ├── jobs.module.js
│ └── user.module.js
├── routers/
│ ├── auth.router.js
│ └── jobs.router.js
├── .env
├── server.js
└── package.json
200- OK201- Created400- Bad Request401- Unauthorized404- Not Found500- Internal Server Error
All errors follow this format:
{
"msg": "Error message description"
}- express
- mongoose
- bcrypt
- jsonwebtoken
- dotenv
- helmet
- cors
- express-rate-limit
- http-status-codes
7amok4a
Contributions, issues, and feature requests are welcome!
Give a ⭐️ if this project helped you!