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!