{"id":26235725,"url":"https://github.com/dxtaner/nodejs-booking-app","last_synced_at":"2025-03-13T03:17:34.435Z","repository":{"id":220116726,"uuid":"750800643","full_name":"dxtaner/nodejs-booking-app","owner":"dxtaner","description":"booking app","archived":false,"fork":false,"pushed_at":"2024-04-11T14:29:26.000Z","size":153,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T03:17:31.643Z","etag":null,"topics":["bcrypt","booking","expressjs","http-errors","jsonwebtoken","middleware","mongodb"],"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/dxtaner.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":"2024-01-31T10:49:39.000Z","updated_at":"2024-02-12T19:31:30.000Z","dependencies_parsed_at":"2025-03-13T03:17:33.291Z","dependency_job_id":null,"html_url":"https://github.com/dxtaner/nodejs-booking-app","commit_stats":null,"previous_names":["dxtaner/mern-booking-app","dxtaner/nodejs-booking-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxtaner%2Fnodejs-booking-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxtaner%2Fnodejs-booking-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxtaner%2Fnodejs-booking-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxtaner%2Fnodejs-booking-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dxtaner","download_url":"https://codeload.github.com/dxtaner/nodejs-booking-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243330305,"owners_count":20274039,"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":["bcrypt","booking","expressjs","http-errors","jsonwebtoken","middleware","mongodb"],"created_at":"2025-03-13T03:17:33.652Z","updated_at":"2025-03-13T03:17:34.419Z","avatar_url":"https://github.com/dxtaner.png","language":"JavaScript","readme":"Booking-App\n===========================\n\nPrerequisites\n-------------\n\nBefore running the server, make sure you have the following installed:\n\n*   Node.js\n*   MongoDB\n*   npm (Node Package Manager) or yarn\n\nInstallation\n------------\n\n1.  Clone this repository to your local machine:\n`git clone github.com/dxtaner/mern-booking-app.  Navigate into the project directory:\n`cd express-mongodb-boilerplate`5.  Install dependencies:\n`npm install` or `yarn install`\n\nConfiguration\n-------------\n\n1.  Create a `.env` file in the root directory of the project.\n2.  Add the following environment variables to `.env`:\n\nPORT=5000\nMONGODB\\_URI=\u003cyour-mongodb-uri\u003e\n\n4.  Replace `\u003cyour-mongodb-uri\u003e` with the connection URI for your MongoDB database.\n\nRunning the Server\n------------------\n\nTo start the server, run:\n\nnpm start\n\nor\n\nyarn start\n\nThe server will start running at `http://localhost:5000` (or the port specified in your `.env` file).\n\nUsage\n-----\n\n### Testing Error Handling\n\nTo test the error handling, you can visit `http://localhost:5000/test-error`, which will trigger a test error response.\n\n### Authentication Routes\n\n*   `/auth/signup`: Register a new user.\n*   `/auth/login`: Login with existing user credentials.\n\n### User Routes\n\n*   `/user/profile`: Get current user's profile.\n*   `/user/update`: Update current user's profile.\n\n### Hotel Routes\n\n*   `/hotel/create`: Create a new hotel.\n*   `/hotel/:id`: Get details of a specific hotel.\n*   `/hotel/update/:id`: Update details of a specific hotel.\n*   `/hotel/delete/:id`: Delete a specific hotel.\n\n### Room Routes\n\n*   `/room/create`: Create a new room for a hotel.\n*   `/room/:id`: Get details of a specific room.\n*   `/room/update/:id`: Update details of a specific room.\n*   `/room/delete/:id`: Delete a specific room.\n\n  Auth Routes Documentation\n\nAuth Routes Documentation\n=========================\n\nOverview\n--------\n\nThe authentication routes handle user registration and login processes.\n\nRoutes\n------\n\n*   **POST /register**: Register a new user.\n\nAccepts JSON payload containing user information.\n\nExample:\n\n    {\n      \"username\": \"example_user\",\n      \"password\": \"example_password\"\n    }\n\n*   **POST /login**: Log in an existing user.\n\nAccepts JSON payload containing user credentials.\n\nExample:\n\n    {\n      \"username\": \"example_user\",\n      \"password\": \"example_password\"\n    }\n\nUsage\n-----\n\nTo use these routes in your Express application, ensure you have properly set up the controller logic and middleware for authentication.\n\n    // Import necessary modules and controllers\n    const express = require(\"express\");\n    const router = express.Router();\n    const authController = require(\"../controllers/authController.js\");\n    \n    // Define routes\n    router.post(\"/register\", authController.registerUser);\n    router.post(\"/login\", authController.loginUser);\n    \n    module.exports = router;\n    \n\nController Logic\n----------------\n\nEnsure you have appropriate controller logic implemented for registering and logging in users. This logic should interact with your database or authentication service.\n\n    // controllers/authController.js\n    \n    // Import necessary modules\n    const User = require(\"../models/User\");\n    \n    // Controller function for registering a new user\n    exports.registerUser = async (req, res) =\u003e {\n      // Implement registration logic here\n    };\n    \n    // Controller function for logging in an existing user\n    exports.loginUser = async (req, res) =\u003e {\n      // Implement login logic here\n    };\n  User Routes Documentation\n\nUser Routes Documentation\n=========================\n\nOverview\n--------\n\nThe user routes handle operations related to user profiles, such as fetching user data, updating profiles, and deleting user accounts. Additionally, certain routes are restricted to authenticated users or administrators.\n\nRoutes\n------\n\n*   **GET /:userId**: Retrieve a specific user's profile.\n\nRequires authentication token.\n\nReturns the user's profile data.\n\n*   **GET /**: Retrieve all users (only accessible to administrators).\n\nRequires authentication token and admin privileges.\n\nReturns a list of all user profiles.\n\n*   **PUT /:userId**: Update a specific user's profile.\n\nRequires authentication token.\n\nReturns a response indicating success or failure.\n\n*   **DELETE /:userId**: Delete a specific user.\n\nRequires authentication token.\n\nReturns a response indicating success or failure.\n\nMiddleware\n----------\n\nThe following middleware functions are utilized to authenticate and authorize users accessing these routes:\n\n*   **authenticateToken**: Validates the authentication token provided in the request header.\n*   **verifyUser**: Verifies that the requesting user is the same as the user whose profile is being accessed or modified.\n*   **verifyAdmin**: Verifies that the requesting user has administrative privileges.\n\nUsage\n-----\n\nTo use these routes in your Express application, ensure you have the necessary controller logic and middleware set up.\n\nController Logic\n----------------\n\nEnsure you have appropriate controller logic implemented for handling user-related operations, such as fetching user data, updating profiles, and deleting accounts.\n\nHotel Routes Documentation\n==========================\n\nOverview\n--------\n\nThe hotel routes provide endpoints for managing hotel data, including creating, retrieving, updating, and deleting hotels. Additionally, there are endpoints for retrieving hotel statistics and room details.\n\nRoutes\n------\n\n*   **POST /**: Create a new hotel.\n\nRequires admin privileges.\n\n*   **GET /**: Get all hotels.\n*   **GET /:id**: Get a specific hotel by ID.\n*   **GET /countByCity**: Get count of hotels by city.\n*   **GET /countByType**: Get count of hotels by type.\n*   **GET /room/:id**: Get rooms of a specific hotel by hotel ID.\n*   **PUT /:id**: Update a specific hotel by ID.\n\nRequires admin privileges.\n\n*   **DELETE /:id**: Delete a specific hotel by ID.\n\nRequires admin privileges.\n\nMiddleware\n----------\n\nThe `verifyAdmin` middleware is used to ensure that only administrators have access to certain routes.\n\nController Functions\n--------------------\n\n*   `createHotel`: Controller function to create a new hotel.\n*   `getHotels`: Controller function to get all hotels.\n*   `getHotel`: Controller function to get a specific hotel by ID.\n*   `countByCity`: Controller function to get count of hotels by city.\n*   `countByType`: Controller function to get count of hotels by type.\n*   `getHotelRooms`: Controller function to get rooms of a specific hotel by hotel ID.\n*   `updateHotel`: Controller function to update a specific hotel by ID.\n*   `deleteHotel`: Controller function to delete a specific hotel by ID.\n\nUsage\n-----\n\nEnsure you have the necessary controller logic and middleware set up to handle requests to these routes.\n\nRoom Routes Documentation\n=========================\n\nOverview\n--------\n\nThe room routes provide endpoints for managing room data, including creating, retrieving, updating, and deleting rooms. Additionally, there's an endpoint for updating room availability.\n\nRoutes\n------\n\n*   **POST /:hotelid**: Create a new room for a specific hotel.\n\nRequires admin privileges.\n\n*   **GET /**: Get all rooms.\n*   **GET /:id**: Get a specific room by ID.\n*   **PUT /availability/:id**: Update availability of a specific room by ID.\n*   **PUT /:id**: Update a specific room by ID.\n\nRequires admin privileges.\n\n*   **DELETE /:id/:hotelid**: Delete a specific room by ID and hotel ID.\n\nRequires admin privileges.\n\nMiddleware\n----------\n\nThe `verifyAdmin` middleware is used to ensure that only administrators have access to certain routes.\n\nController Functions\n--------------------\n\n*   `createRoom`: Controller function to create a new room.\n*   `getRooms`: Controller function to get all rooms.\n*   `getRoom`: Controller function to get a specific room by ID.\n*   `updateRoomAvailability`: Controller function to update availability of a specific room by ID.\n*   `updateRoom`: Controller function to update a specific room by ID.\n*   `deleteRoom`: Controller function to delete a specific room by ID and hotel ID.\n\nUsage\n-----\n\nEnsure you have the necessary controller logic and middleware set up to handle requests to these routes.\n\nSecurity\n--------\n\nSome routes require admin privileges for access. Ensure that proper authentication and authorization mechanisms are in place.\n\nError Handling\n--------------\n\nImplement error handling to deal with various scenarios such as invalid requests, database errors, or unauthorized access.\n\nFeedback and Contributions\n--------------------------\n\nFeedback and contributions to improve these routes and documentation are welcome. Feel free to open issues or pull requests in the repository.\n\nError Handling\n--------------\n\nError handling middleware is implemented to handle any errors that occur during the execution of the routes. If an error occurs, the server responds with an appropriate error message and status code.\n\nContributing\n------------\n\nFeel free to contribute to this project by submitting issues or pull requests.\n\nLicense\n-------\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxtaner%2Fnodejs-booking-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdxtaner%2Fnodejs-booking-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxtaner%2Fnodejs-booking-app/lists"}