{"id":19109275,"url":"https://github.com/obrm/bootcamper-api","last_synced_at":"2025-04-30T19:35:56.161Z","repository":{"id":208475254,"uuid":"610338092","full_name":"obrm/bootcamper-api","owner":"obrm","description":"This Node.js, Express.js, and MongoDB RESTful API offers authentication, CRUD operations, pagination, filtering, sorting, geocoding, and image uploading. Manage bootcamps, courses, reviews, and users based on different access levels. Search for bootcamps within a radius, and upload bootcamp images.","archived":false,"fork":false,"pushed_at":"2024-02-19T14:38:04.000Z","size":227,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T08:32:54.164Z","etag":null,"topics":["bcryptjs","cookie-parser","cors","express","express-fileupload","express-mongo-sanitize","express-rate-limit","helmet","hpp","jwt","mongoose","node-geocoder","nodemailer","slugify","xss-clean"],"latest_commit_sha":null,"homepage":"","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/obrm.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-03-06T15:16:33.000Z","updated_at":"2024-07-10T07:15:43.000Z","dependencies_parsed_at":"2023-11-21T17:48:34.536Z","dependency_job_id":"a8c03e34-dcaa-4757-b15a-56568307931e","html_url":"https://github.com/obrm/bootcamper-api","commit_stats":null,"previous_names":["obrm/bootcamper-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obrm%2Fbootcamper-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obrm%2Fbootcamper-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obrm%2Fbootcamper-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obrm%2Fbootcamper-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obrm","download_url":"https://codeload.github.com/obrm/bootcamper-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251770040,"owners_count":21641016,"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":["bcryptjs","cookie-parser","cors","express","express-fileupload","express-mongo-sanitize","express-rate-limit","helmet","hpp","jwt","mongoose","node-geocoder","nodemailer","slugify","xss-clean"],"created_at":"2024-11-09T04:19:46.828Z","updated_at":"2025-04-30T19:35:56.142Z","avatar_url":"https://github.com/obrm.png","language":"JavaScript","readme":"# Node.js RESTful API\n\nThis RESTful API is built with Node.js, Express.js, and MongoDB, featuring various functionalities, including user authentication, CRUD operations, pagination, filtering, sorting, and geocoding. \n\nIt allows image uploading, searching for bootcamps by distance, and advanced filtering. Security measures include middleware for error handling, and authentication. \n\nThis API offers a rich set of endpoints to manage bootcamps, courses, reviews, and users. For instance, the API allows creating, retrieving, updating, and deleting bootcamps, courses, reviews, and users based on different access levels. The API offers a wide range of access levels, including public, private for authenticated users and secured for publishers and admins. The API supports pagination, filtering, and sorting for bootcamps, courses, and reviews. Additionally, the API provides functionality to search for bootcamps within a certain radius, as well as to upload bootcamp images.\n\n## Getting Started\nTo get started, you'll need Node.js installed on your local machine and a MongoDB Atlas account. You'll also need a config.env file with the required environment variables.\n\n### Environment Variables\nCreate a config.env file in the config folder and add the following environment variables:\n\n```\nNODE_ENV=development\nPORT=5000\n\nMONGO_URI=your_mongodb_connection_string\n\nGEOCODER_PROVIDER=your_geocoder_provider\nGEOCODER_API_KEY=your_geocoder_api_key\n\nFILE_UPLOAD_PATH= ./public/uploads\nUPLOADS_FOLDER= /uploads\nMAX_FILE_SIZE=1000000\n\nJWT_SECRET=your_jwt_secret\nJWT_EXPIRE=30d\nJWT_COOKIE_EXPIRE=30\n\nSMTP_HOST=sandbox.smtp.mailtrap.io\nSMTP_PORT=2525\nSMTP_EMAIL=your_smtp_email\nSMTP_PASSWORD=your_smtp_password\nFROM_EMAIL=noreply@bootcamper.com\nFROM_NAME=Bootcamper\n```\n\n\n## Dependencies\n\n#### Node.js\n* nodemon (dev dependency)\n  \n#### Express.js\n\n* express\n* cookie-parser\n* express-fileupload\n\n#### Security\n* express-mongo-sanitize\n* express-rate-limit\n* cors\n* helmet\n* hpp\n* xss-clean\n\n\n#### MongoDB\n\n* mongoose\n\n#### Auth\n\n* bcryptjs\n* jsonwebtoken\n  \n#### Geo Coding\n\n* node-geocoder\n  \n#### File Upload\n\n* express-fileupload\n  \n#### Utils\n\n* morgan\n* dotenv\n* slugify\n* nodemailer\n* colors (dev dependency)\n\n### Installing Dependencies\nInstall the required dependencies by running the following command:\n\n```bash\nnpm install\n```\n\n### Starting the Server\nStart the server by running:\n\n```bash\nnpm run dev\n```\n\n## API Endpoints\nThe API provides the following endpoints:\n\n### Authentication\n* User registration: `POST /api/v1/auth/register` (public)\n* User login: `POST /api/v1/auth/login` (public)\n* User logout: `GET /api/v1/auth/logout` (private - requires authentication)\n* Get current logged-in user: `GET /api/v1/auth/current-user` (private - requires authentication)\n* Forgot password: `POST /api/v1/auth/forgot-password` (public)\n* Reset password: `PUT /api/v1/auth/reset-password/:resettoken` (public)\n* Update details: `PUT /api/v1/auth/update-details` (private - requires authentication)\n* Update password: `PUT /api/v1/auth/update-password` (private - requires authentication)\n\n### Bootcamps\n\n* Get all bootcamps: `GET /api/v1/bootcamps` (public - with pagination and filtering)\n* Get single bootcamp: `GET /api/v1/bootcamps/:id` (public)\n* Create bootcamp: `POST /api/v1/bootcamps` (private - publisher/admin)\n* Update bootcamp: `PUT /api/v1/bootcamps/:id` (private - publisher/admin)\n* Delete bootcamp: `DELETE /api/v1/bootcamps/:id` (private - publisher/admin)\n* Get bootcamps within a radius: `GET /api/v1/bootcamps/radius/:zipcode/:distance` (public)\n* Upload bootcamp image: `PUT /api/v1/bootcamps/:id/image` (private - publisher/admin)\n\n### Courses\n\n* Get all courses: `GET /api/v1/courses` (public)\n* Get courses for a specific bootcamp: `GET /api/v1/bootcamps/:bootcampId/courses` (public)\n* Get single course: `GET /api/v1/courses/:id` (public)\n* Create course: `POST /api/v1/bootcamps/:bootcampId/courses` (private - publisher/admin)\n* Update course: `PUT /api/v1/courses/:id` (private - publisher/admin)\n* Delete course: `DELETE /api/v1/courses/:id` (private - publisher/admin)\n### Reviews\n\n* Get all reviews: `GET /api/v1/reviews` (public)\n* Get a single review by ID: `GET /api/v1/reviews/:id` (public)\n* Create a new review for a bootcamp: `POST /api/v1/bootcamps/:bootcampId/reviews` (private - requires authentication)\n* Update a review: `PUT /api/v1/reviews/:id` (private - requires authentication)\n* Delete a review: `DELETE /api/v1/reviews/:id` (private - requires authentication)\n\n### Users\n\n* Get all users: `GET /api/v1/users` (private - admin)\n* Get a single user: `GET /api/v1/users/:id` (private - admin)\n* Create a user: `POST /api/v1/users` (private - admin)\n* Update a user: `PUT /api/v1/users/:id` (private - admin)\n* Delete a user: `DELETE /api/v1/users/:id` (private - admin)\n\n\n## Features\n\n* User authentication and authorization\n* Password reset functionality (with email sending)\n* CRUD operations on resources\n* Pagination, filtering, and sorting of results\n* Middleware for error handling\n* Geocoding of addresses\n\n## Pagination, Filtering, and Sorting\nThe API supports pagination, filtering, and sorting for bootcamps, courses, and reviews.\n\n### Pagination\n\nSpecify the page number and limit per page: GET /api/v1/bootcamps?page=1\u0026limit=10\n\n### Filtering\n\nFilter results by specific fields: GET /api/v1/bootcamps?housing=true\nUse comparison operators to filter results: GET /api/v1/bootcamps?averageCost[lte]=10000\n\n### Sorting\n\nSort results by one or more fields: GET /api/v1/bootcamps?sort=name,averageCost\nSort results in descending order: GET /api/v1/bootcamps?sort=-averageCost\n\n## Middleware\n\nThis project utilizes various middleware for tasks such as error handling, authentication, and authorization:\n\n* `middleware/advancedResults.js`: for advanced filtering, sorting, and pagination\n* `middleware/asyncHandler.js`: for handling async/await functions in Express routes\n* `middleware/authMiddleware.js`: for protecting routes and authorizing user roles\n* `middleware/errorHandler.js`: for handling errors and sending appropriate responses\n\n\n* `utils/ErrorResponse.js`: for creating custom error responses\n* `utils/sendEmail.js`: for sending password reset emails\n* `utils/sendTokenResponse.js`: for setting JWT tokens and sending as response\n* `utils/geoCoder.js`: for converting addresses to coordinates using Node-geocoder\n\n## Seeder\n\nThe `seeder.js` file is used to import or delete data from the MongoDB database. It reads JSON files for bootcamps, courses, users, and reviews, and inserts them into their respective collections in the database using Mongoose.\n\nTo import data into the database, run the command `node seeder.js -i` in the terminal. To delete all data from the database, run `node seeder.js -d`.\n\n## License\nThis project is licensed under the MIT License.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobrm%2Fbootcamper-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobrm%2Fbootcamper-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobrm%2Fbootcamper-api/lists"}