{"id":18743874,"url":"https://github.com/devmarkson/jobs-api","last_synced_at":"2025-11-21T23:30:14.335Z","repository":{"id":189762945,"uuid":"680943233","full_name":"DevMarkson/Jobs-API","owner":"DevMarkson","description":"The Jobs API provides endpoints for efficient management of job listings. With features like user registration, authentication, and CRUD operations on job postings. Built on Node.js, Express, and MongoDB, it offers user-friendly documentation through Swagger UI, catering to job seekers.","archived":false,"fork":false,"pushed_at":"2023-08-22T14:56:24.000Z","size":157,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-28T19:46:41.522Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jobs-api1-7075a68fc0ac.herokuapp.com/api-docs/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevMarkson.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-20T22:40:47.000Z","updated_at":"2024-08-15T00:09:55.000Z","dependencies_parsed_at":"2024-08-02T20:31:42.964Z","dependency_job_id":null,"html_url":"https://github.com/DevMarkson/Jobs-API","commit_stats":null,"previous_names":["markson17/jobs-api","devmarkson/jobs-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FJobs-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FJobs-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FJobs-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevMarkson%2FJobs-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevMarkson","download_url":"https://codeload.github.com/DevMarkson/Jobs-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239627300,"owners_count":19670844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T16:12:50.632Z","updated_at":"2025-11-21T23:30:14.269Z","avatar_url":"https://github.com/DevMarkson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jobs API\n\nThis README provides an overview of the **Jobs API** along with instructions on how to use it. The API allows users to register, log in, create, update, retrieve, and delete job listings. It also provides Swagger documentation for easy reference.\n\n## Table of Contents\n\n- [Swagger Documentation](#swagger-documentation)\n- [Prerequisites](#prerequisites)\n- [Getting Started](#getting-started)\n- [Database Connection](#database-connection)\n- [Middleware](#middleware)\n- [Models](#models)\n- [Controllers](#controllers)\n- [API Endpoints](#api-endpoints)\n- [Authentication](#authentication)\n- [Swagger YAML](#swagger-yaml)\n\n\n## Swagger Documentation\n\nYou can access the Swagger documentation for this API at `https://jobs-api1-7075a68fc0ac.herokuapp.com/api-docs/`. The Swagger UI provides detailed information about the API endpoints, request schemas, and example requests and responses.\n![Swagger Documentation of Jobs API](swagger-docs.png)\n\n## Prerequisites\n\nBefore you can use the **Jobs API**, make sure you have the following installed:\n\n- Node.js (v14 or higher)\n- MongoDB\n- Git\n\n## Getting Started\n\n1. Clone the repository to your local machine:\n\n   ```bash\n   git clone \u003crepository-url\u003e\n   ```\n\n2. Install the dependencies:\n\n   ```bash\n   npm install\n   ```\n\n3. Set up environment variables by creating a  folder `config` and create a `config.env` file in the config folder. Use this format\n  ```\n  # MongoDB connection URI\n  MONGO_URI=your_mongodb_uri_here\n\n  # JWT secret key for token generation\n  JWT_SECRET=your_secret_key_here\n\n  # JWT token expiration time (e.g., 1d for 1 day, 1h for 1 hour)\n  JWT_LIFETIME=1d\n\n  # Port for the server to listen on\n  PORT=3000\n  ```\n\n4. Start the server:\n\n   ```bash\n   npm start\n   ```\n\nThe API should now be running on `http://localhost:\u003cport\u003e`. The default port is 3000.\n\n## Database Connection\n\nThe API connects to a MongoDB database using Mongoose. The database connection is managed in the `db/connect.js` file.\n\n## Middleware\n\nThe API includes several middleware functions for security and request handling:\n\n- `helmet`: Provides security-related HTTP headers.\n- `cors`: Enables Cross-Origin Resource Sharing.\n- `xss-clean`: Protects against cross-site scripting (XSS) attacks.\n- `express-rate-limit`: Implements rate limiting to prevent abuse of the API.\n- `authentication`: Middleware to verify JWT tokens and authenticate users.\n- `not-found`: Handles requests for non-existent routes.\n- `error-handler`: Centralized error handling and response formatting.\n\n## Models\n\nThe API uses two mongoose models:\n\n### User Model\n\n- Stores user information including name, email, and hashed password.\n- Provides methods for creating JWT tokens and comparing passwords.\n\n### Job Model\n\n- Stores job listings with details like company name, position, and status.\n- Associated with a user through the `createdBy` field.\n\n## Controllers\n\nThe API controllers handle request processing:\n\n### Auth Controller\n\n- `register`: Handles user registration.\n- `login`: Handles user login.\n\n### Jobs Controller\n\n- `getAllJobs`: Retrieves all job listings for the authenticated user.\n- `getJob`: Retrieves a single job listing by its ID.\n- `createJob`: Creates a new job listing.\n- `updateJob`: Updates a job listing by its ID.\n- `deleteJob`: Deletes a job listing by its ID.\n\n## API Endpoints\n\n### Authentication\n\n- **POST /api/v1/auth/register**\n  - Register a new user.\n  - Example Request Body:\n\n    ```json\n    {\n      \"name\": \"Favour\",\n      \"email\": \"favour01@gmail.com\",\n      \"password\": \"yourpassword\"\n    }\n    ```\n\n- **POST /api/v1/auth/login**\n  - Log in an existing user.\n  - Example Request Body:\n\n    ```json\n    {\n      \"email\": \"favour01@example.com\",\n      \"password\": \"yourpassword\"\n    }\n    ```\n\n### Jobs\n\n- **POST /api/v1/jobs**\n  - Create a new job listing (requires authentication).\n  - Example Request Body:\n\n    ```json\n    {\n      \"company\": \"Microsoft\",\n      \"position\": \"Software engineer intern\"\n    }\n    ```\n\n- **GET /api/v1/jobs**\n  - Retrieve all job listings for the authenticated user.\n\n- **GET /api/v1/jobs/{id}**\n  - Retrieve a single job listing by its ID (requires authentication).\n\n- **PATCH /api/v1/jobs/{id}**\n  - Update a job listing by its ID (requires authentication).\n  - Example Request Body:\n\n    ```json\n    {\n      \"company\": \"Microsoft\",\n      \"position\": \"Data scientist intern\"\n    }\n    ```\n\n- **DELETE /api/v1/jobs/{id}**\n  - Delete a job listing by its ID (requires authentication).\n\n## Authentication\n\nThe API uses JSON Web Tokens (JWT) for authentication. When a user registers or logs in, a JWT token is provided in the response. To authenticate for protected routes (jobs-related endpoints), include this token in the `Authorization` header of your requests with the format: `Bearer \u003ctoken\u003e`.\n\n## Swagger YAML\n\nThe Swagger documentation is defined in the `swagger.yaml` file. It provides detailed information about the API endpoints, request and response schemas, and example data.\n\nFeel free to explore and interact with the API using the provided Swagger documentation or by making HTTP requests as described in the API endpoints section.\n\n## Special Thanks\n\nI would like to express my heartfelt gratitude to [FreeCodeCamp](https://www.youtube.com/@freecodecamp) and [John Smilga](https://www.youtube.com/codingaddict) for providing exceptional educational resources. This project would not have been possible without their insightful tutorials and guidance. Their dedication to sharing knowledge and empowering learners like me is truly commendable.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmarkson%2Fjobs-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevmarkson%2Fjobs-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevmarkson%2Fjobs-api/lists"}