{"id":19270732,"url":"https://github.com/mdsejan/co-work-booker","last_synced_at":"2026-04-18T04:33:43.877Z","repository":{"id":243985720,"uuid":"813952085","full_name":"mdsejan/co-work-booker","owner":"mdsejan","description":"CoWorkBooker is a web application designed to manage room reservations for co-working spaces. It provides a streamlined booking process for both administrators and users, ensuring efficient management of meeting rooms and time slots.","archived":false,"fork":false,"pushed_at":"2024-10-11T20:15:29.000Z","size":242,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T13:44:48.163Z","etag":null,"topics":["expressjs","jwt","mongoose","typescript","zod-validation"],"latest_commit_sha":null,"homepage":"https://co-work-booker.vercel.app/","language":"TypeScript","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/mdsejan.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-06-12T04:07:50.000Z","updated_at":"2024-10-11T20:15:33.000Z","dependencies_parsed_at":"2024-11-09T20:39:17.162Z","dependency_job_id":null,"html_url":"https://github.com/mdsejan/co-work-booker","commit_stats":null,"previous_names":["mdsejan/co-work-booker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mdsejan/co-work-booker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsejan%2Fco-work-booker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsejan%2Fco-work-booker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsejan%2Fco-work-booker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsejan%2Fco-work-booker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdsejan","download_url":"https://codeload.github.com/mdsejan/co-work-booker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdsejan%2Fco-work-booker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31957031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["expressjs","jwt","mongoose","typescript","zod-validation"],"created_at":"2024-11-09T20:26:57.548Z","updated_at":"2026-04-18T04:33:43.832Z","avatar_url":"https://github.com/mdsejan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CoWorkBooker\n\n### Live URL: \u0026nbsp; \u0026nbsp; [co-work-booker.vercel.app](https://co-work-booker.vercel.app/)\n\n## Description:\n\nCoWorkBooker is a web application designed to manage room reservations for co-working spaces. It provides a streamlined booking process for both administrators and users, ensuring efficient management of meeting rooms and time slots.\n\n### Admin Actions:\n\nAdministrators have comprehensive control over the co-working space inventory:\n\n- Create, update, and delete rooms with details such as name, number, floor, capacity, price per slot, and amenities.\n- Manage time slots for each room, setting dates, start times, and end times to ensure availability.\n\n### User Interactions:\n\nUsers can effortlessly book rooms for their meetings:\n\n- Select available time slots on desired dates.\n- Input booking details including room selection and preferred slots.\n- Automatically calculate total costs based on slots chosen and prices per slot.\n- Receive real-time updates on room and slot availability to avoid conflicts.\n\n### Validation and Error Handling:\n\nCoWorkBooker implements robust mechanisms for seamless user experiences:\n\n- Informative error messages for booking conflicts and validation errors.\n- Ensure smooth interactions and accurate data handling.\n\n## Features\n\n- **User Management**: Enable users to sign up, log in, and manage their accounts securely.\n- **Room Management**: Allow admins to add, update, delete, and view co-working rooms.\n- **Slot Management**: Enable admins to create, update, and delete time slots for room bookings.\n- **Booking Management**: Facilitate users in creating, viewing, and canceling bookings.\n- **Availability Check**: Provide endpoints to check slot availability for specific dates.\n- **Error Handling**: Implement robust error handling middleware for consistent and informative responses.\n- **Authentication \u0026 Authorization**: Secure API endpoints using JWT-based authentication and role-based authorization.\n- **Data Validation**: Ensure data integrity and consistency with Zod for input validation.\n\n## Technology Stack\n\n- **TypeScript**: Provides type safety and enhanced code quality.\n- **Express.js**: Fast, minimalist web framework for Node.js, ideal for building RESTful APIs.\n- **Mongoose**: Elegant MongoDB object modeling for Node.js, simplifying interactions with MongoDB.\n- **JWT (JSON Web Tokens)**: Securely transfer claims between parties for authentication purposes.\n- **Zod**: TypeScript-first schema declaration and validation library, ensuring data consistency and preventing runtime errors.\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js (v14 or higher)\n- npm (v6 or higher)\n- MongoDB (v4 or higher)\n\n### Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/mdsejan/co-work-booker.git\n   ```\n\n2. Navigate to the project directory:\n\n   ```bash\n   cd CoWorkBooker\n   ```\n\n3. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n### Configuration\n\n1. Create a `.env` file in the root directory.\n2. Add the following environment variables to the `.env` file:\n\n   ```plaintext\n   PORT=5000\n   DATABASE_URL=\u003cmongodb-uri\u003e\n   BCRYPT_SALT_ROUNDS=\u003csalt\u003e\n   JWT_SECRET=\u003cjwt-secret\u003e\n   ```\n\n### Running the Application\n\nStart the server:\n\n```bash\nnpm run start:dev\n```\n\nThe server will start running at `http://localhost:5000`.\n\n## API Endpoints\n\n1. **User Sign Up**\n\n   - **Route:** `{domain}/api/auth/signup` `POST`\n\n2. **User Login**\n\n   - **Route:** `{domain}/api/auth/login` `POST`\n\n3. **Create Room (Only Accessible by Admin)**\n\n   - **Route:** `{domain}/api/rooms` `POST`\n\n4. **Get a Room**\n\n   - **Route:** `{domain}/api/rooms/:id` `GET`\n\n5. **Get All Rooms**\n\n   - **Route:** `{domain}/api/rooms` `GET`\n\n6. **Update Room (Only Accessible by Admin)**\n\n   - **Route:** `{domain}/api/rooms/:id` `PUT`\n\n7. **Delete a Room (Soft Delete, Only Accessible by Admin)**\n\n   - **Route:** `{domain}/api/rooms/:id` `DELETE`\n\n8. **Create Slot (Only Accessible by Admin)**\n\n   - **Route:** `{domain}/api/slots` `POST`\n\n9. **Get available slots**\n\n   - **Route:** `{domain}/api/slots/availability` `GET`\n   - **Route:** `{domain}/api/slots/availability?date=2024-06-15` `GET`\n   - **Route:** `{domain}/api/slots/availability?roomId=60d9c4e4f3b4b544b8b8d1c5` `GET`\n   - **Route:** `{domain}/api/slots/availability?date=2024-06-15\u0026roomId=60d9c4e4f3b4b544b8b8d1c5` `GET`\n\n10. **Create a Booking (Only Accessible by Authenticated User)**\n\n- **Route:** `{domain}/api/bookings` `POST`\n\n11. **Get All Bookings (Only Accessible by Admin)**\n\n- **Route:** `{domain}/api/bookings` `GET`\n\n12. **Get User's Bookings (Only Accessible by Authenticated User)**\n\n- **Route:** `{domain}/api/my-bookings` `GET`\n\n13. **Update Booking (Only Accessible by Admin)**\n\n- **Route:** `{domain}/api/bookings/:id` `PUT`\n\n14. **Delete Booking (Soft Delete, Only Accessible by Admin)**\n\n- **Route:** `{domain}/api/bookings/:id` `DELETE`\n\n1.  **get Available Dates of Slots**\n\n- **Route:** `{domain}/api/slots/dates/:id` `GET`\n\n## API Endpoints Detailed\n\n### User Routes\n\n1. **User Sign Up**\n\n- _*Route:*_ `/api/auth/signup` (POST)\n- **Request Body:**\n\n```json\n{\n  \"name\": \"Programming Hero\",\n  \"email\": \"web@programming-hero.com\",\n  \"password\": \"ph-password\",\n  \"phone\": \"1234567890\",\n  \"role\": \"admin\", //role can be user or admin\n  \"address\": \"123 Main Street, City, Country\"\n}\n```\n\n- **Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"User registered successfully\",\n  \"data\": {\n    \"_id\": \"60629b8e8cfcd926384b6e5e\",\n    \"name\": \"Programming Hero\",\n    \"email\": \"web@programming-hero.com\",\n    \"phone\": \"1234567890\",\n    \"role\": \"admin\",\n    \"address\": \"123 Main Street, City, Country\"\n  }\n}\n```\n\n**2\\. User Login**\n\n- _*Route:*_ `/api/auth/login` (POST)\n- **Request Body:**\n\n```json\n{\n  \"email\": \"web@programming-hero.com\",\n  \"password\": \"ph-password\"\n}\n```\n\n- Response:\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"User logged in successfully\",\n  \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2MDYyOWI4ZThjZmNkOTI2Mzg0YjZlNWUiLCJuYW1lIjoiUHJvZ3JhbW1pbmcgSGVyb3MiLCJlbWFpbCI6IndlYkBwcm9ncmFtbWluZy1oZXJvLmNvbSIsInBob25lIjoiMTIzNDU2Nzg5MCIsInJvbGUiOiJhZG1pbiIsImFkZHJlc3MiOiIxMjMgTWFpbiBTdHJlZXQsIENpdHksIENvdW50cnkiLCJpYXQiOjE2MjQ1MTY2MTksImV4cCI6MTYyNDUyMDYxOX0.kWrEphO6lE9P5tvzrNBwx0sNogNuXpdyG-YoN9fB1W8\",\n  \"data\": {\n    \"_id\": \"60629b8e8cfcd926384b6e5e\",\n    \"name\": \"Programming Hero\",\n    \"email\": \"web@programming-hero.com\",\n    \"phone\": \"1234567890\",\n    \"role\": \"admin\",\n    \"address\": \"123 Main Street, City, Country\"\n  }\n}\n```\n\n###\n\n### Room Routes\n\n**3\\. Create Room (Only Accessible by Admin)**\n\n- _*Route:*_ `/api/rooms` (POST)\n- **Request Headers:**\n\n```plain\nAuthorization:\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmF\ntZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n\nYou must include \"Bearer\" at the beginning of the token! Do not copy and apply directly from the module. If you blindly follow the modules, you will be a copy master, not a developer.\n```\n\n- _*Request Body:*_\n\n```json\n{\n  \"name\": \"Conference Room\",\n  \"roomNo\": 201,\n  \"floorNo\": 1,\n  \"capacity\": 20,\n  \"pricePerSlot\": 100,\n  \"amenities\": [\"Projector\", \"Whiteboard\"]\n}\n```\n\n- _*Response:*_\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Room added successfully\",\n  \"data\": {\n    \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n    \"name\": \"Conference Room\",\n    \"roomNo\": 201,\n    \"floorNo\": 1,\n    \"capacity\": 20,\n    \"pricePerSlot\": 100,\n    \"amenities\": [\"Projector\", \"Whiteboard\"],\n    \"isDeleted\": false\n  }\n}\n```\n\n**4\\. Get a Room**\n\n- _*Route:*_ `/api/rooms/:id` (GET)\n- _*Response:*_\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Room retrieved successfully\",\n  \"data\": {\n    \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n    \"name\": \"Conference Room\",\n    \"roomNo\": 201,\n    \"floorNo\": 1,\n    \"capacity\": 20,\n    \"pricePerSlot\": 100,\n    \"amenities\": [\"Projector\", \"Whiteboard\"],\n    \"isDeleted\": false\n  }\n}\n```\n\n**5\\. Get All Rooms**\n\n- _*Route:*_ `/api/rooms` (GET)\n- **Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Rooms retrieved successfully\",\n  \"data\": [\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n      \"name\": \"Conference Room\",\n      \"roomNo\": 201,\n      \"floorNo\": 1,\n      \"capacity\": 20,\n      \"pricePerSlot\": 100,\n      \"amenities\": [\"Projector\", \"Whiteboard\"],\n      \"isDeleted\": false\n    },\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c6\",\n      \"name\": \"Meeting Room\",\n      \"roomNo\": 301,\n      \"floorNo\": 2,\n      \"capacity\": 10,\n      \"pricePerSlot\": 200,\n      \"amenities\": [\"Whiteboard\"],\n      \"isDeleted\": false\n    }\n    // Other available rooms\n  ]\n}\n```\n\n**6\\. Update Room (Only Accessible by Admin)**\n\n- _*Route:*_ `/api/rooms/:id` (PUT)\n- **Request Headers:**\n\n```plain\nAuthorization:\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmF\ntZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n\nYou must include \"Bearer\" at the beginning of the token! Do not copy and apply directly from the module. If you blindly follow the modules, you will be a copy master, not a developer.\n```\n\n- **Request Body:**\n\n```json\n{\n  \"pricePerSlot\": 200 //we can update any field dynamically, (e.g., name, roomNo, floorNo, capacity, pricePerSlot, amenities)..\n}\n```\n\n- **Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Room updated successfully\",\n  \"data\": {\n    \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n    \"name\": \"Conference Room\",\n    \"roomNo\": 201,\n    \"floorNo\": 1,\n    \"capacity\": 20,\n    \"pricePerSlot\": 200,\n    \"amenities\": [\"Projector\", \"Whiteboard\"],\n    \"isDeleted\": false\n  }\n}\n```\n\n**7\\. Delete a Room (Soft Delete, Only Accessible by Admin)**\n\n- _*Route:*_ `/api/rooms/:id` (DELETE)\n- **Request Headers:**\n\n```plain\nAuthorization:\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmF\ntZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n\nYou must include \"Bearer\" at the beginning of the token! Do not copy and apply directly from the module. If you blindly follow the modules, you will be a copy master, not a developer.\n```\n\n- **Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Room deleted successfully\",\n  \"data\": {\n    \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n    \"name\": \"Conference Room\",\n    \"roomNo\": 201,\n    \"floorNo\": 1,\n    \"capacity\": 20,\n    \"pricePerSlot\": 200,\n    \"amenities\": [\"Projector\", \"Whiteboard\"],\n    \"isDeleted\": true\n  }\n}\n```\n\n###\n\n### Slot Routes\n\n8\\. **Create Slot (Only Accessible by Admin)**\n\n- _*Route:*_ `/api/slots`(**POST**)\n\n**Request Headers:**\n\n```javascript\nAuthorization:\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmF\ntZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n\nYou must include \"Bearer\" at the beginning of the token! Do not copy and apply directly from the module. If you blindly follow the modules, you will be a copy master, not a developer.\n```\n\n**Request Body:**\n\n```json\n{\n  \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n  \"date\": \"2024-06-15\",\n  \"startTime\": \"09:00\",\n  \"endTime\": \"14:00\"\n}\n```\n\n**Response Body:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Slots created successfully\",\n  \"data\": [\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c6\",\n      \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n      \"date\": \"2024-06-15\",\n      \"startTime\": \"09:00\",\n      \"endTime\": \"10:00\",\n      \"isBooked\": false\n    },\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c7\",\n      \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n      \"date\": \"2024-06-15\",\n      \"startTime\": \"10:00\",\n      \"endTime\": \"11:00\",\n      \"isBooked\": false\n    },\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c8\",\n      \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n      \"date\": \"2024-06-15\",\n      \"startTime\": \"11:00\",\n      \"endTime\": \"12:00\",\n      \"isBooked\": false\n    },\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c9\",\n      \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n      \"date\": \"2024-06-15\",\n      \"startTime\": \"12:00\",\n      \"endTime\": \"13:00\",\n      \"isBooked\": false\n    },\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1ca\",\n      \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n      \"date\": \"2024-06-15\",\n      \"startTime\": \"13:00\",\n      \"endTime\": \"14:00\",\n      \"isBooked\": false\n    }\n  ]\n}\n```\n\n**9\\. Get available slots**\n\n**Route:** `/api/slots/availability`(**GET**)\n\n**Query Parameters:**\n\n- `date`: The specific date for which available slots are requested (format: YYYY-MM-DD).\n- `roomId`: ID of the room for which available slots are requested.\n\n\u003e Special Remarks\n\nIf we hit `/api/slots/availability` without any query params then we should get all the slots that are not booked ( isBooked: false)\n\n**Request endpoint example**\n\n`/api/slots/availability?date=2024-06-15\u0026roomId=60d9c4e4f3b4b544b8b8d1c5`\n\nor\n\n`/api/slots/availability`\n\n**Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Available slots retrieved successfully\",\n  \"data\": [\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c6\",\n      \"room\": {\n        \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n        \"name\": \"Conference Room\",\n        \"roomNo\": 201,\n        \"floorNo\": 1,\n        \"capacity\": 20,\n        \"pricePerSlot\": 100,\n        \"amenities\": [\"Projector\", \"Whiteboard\"],\n        \"isDeleted\": false\n      },\n      \"date\": \"2024-06-15\",\n      \"startTime\": \"09:00\",\n      \"endTime\": \"10:00\",\n      \"isBooked\": false\n    },\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c7\",\n      \"room\": {\n        \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n        \"name\": \"Conference Room\",\n        \"roomNo\": 201,\n        \"floorNo\": 1,\n        \"capacity\": 20,\n        \"pricePerSlot\": 100,\n        \"amenities\": [\"Projector\", \"Whiteboard\"],\n        \"isDeleted\": false\n      },\n      \"date\": \"2024-06-15\",\n      \"startTime\": \"10:00\",\n      \"endTime\": \"11:00\",\n      \"isBooked\": false\n    }\n  ]\n}\n```\n\n###\n\n### Booking Routes\n\n**10\\. Create a Booking (Only Accessible by Authenticated User)**\n\n- _*Route:*_ `/api/bookings` (POST)\n- **Request Headers:**\n\n```javascript\nAuthorization:\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmF\ntZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n\nYou must include \"Bearer\" at the beginning of the token! Do not copy and apply directly from the module. If you blindly follow the modules, you will be a copy master, not a developer.\n```\n\n- **Request Body:**\n\n```json\n{\n  \"date\": \"2024-06-15\",\n  \"slots\": [\"60d9c4e4f3b4b544b8b8d1c6\", \"60d9c4e4f3b4b544b8b8d1c7\"],\n  \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n  \"user\": \"60d9c4e4f3b4b544b8b8d1c4\"\n}\n```\n\n- **Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Booking created successfully\",\n  \"data\": {\n    \"_id\": \"60d9c4e4f3b4b544b8b8d1c9\",\n    \"date\": \"2024-06-15\",\n    \"slots\": [\n      {\n        \"_id\": \"60d9c4e4f3b4b544b8b8d1c6\",\n        \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n        \"date\": \"2024-06-15\",\n        \"startTime\": \"09:00\",\n        \"endTime\": \"10:00\",\n        \"isBooked\": true\n      },\n      {\n        \"_id\": \"60d9c4e4f3b4b544b8b8d1c7\",\n        \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n        \"date\": \"2024-06-15\",\n        \"startTime\": \"10:00\",\n        \"endTime\": \"11:00\",\n        \"isBooked\": true\n      }\n    ],\n    \"room\": {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n      \"name\": \"Conference Room\",\n      \"roomNo\": 201,\n      \"floorNo\": 1,\n      \"capacity\": 20,\n      \"pricePerSlot\": 100,\n      \"amenities\": [\"Projector\", \"Whiteboard\"],\n      \"isDeleted\": false\n    },\n    \"user\": {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c4\",\n      \"name\": \"John Doe\",\n      \"email\": \"john.doe@example.com\",\n      \"phone\": \"1234567890\",\n      \"address\": \"123 Main St, Anytown, USA\",\n      \"role\": \"user\"\n    },\n    \"totalAmount\": 200,\n    \"isConfirmed\": \"unconfirmed\",\n    \"isDeleted\": false\n  }\n}\n```\n\n**11\\. Get All Bookings (Only Accessible by Admin)**\n\n- _*Route:*_ `/api/bookings` (GET)\n- **Request Headers:**\n\n```javascript\nAuthorization:\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmF\ntZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n\nYou must include \"Bearer\" at the beginning of the token! Do not copy and apply directly from the module. If you blindly follow the modules, you will be a copy master, not a developer.\n```\n\n- **Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"All bookings retrieved successfully\",\n  \"data\": [\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1c9\",\n      \"date\": \"2024-06-15\",\n      \"slots\": [\n        {\n          \"_id\": \"60d9c4e4f3b4b544b8b8d1c6\",\n          \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n          \"date\": \"2024-06-15\",\n          \"startTime\": \"09:00\",\n          \"endTime\": \"10:00\",\n          \"isBooked\": true\n        },\n        {\n          \"_id\": \"60d9c4e4f3b4b544b8b8d1c7\",\n          \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n          \"date\": \"2024-06-15\",\n          \"startTime\": \"10:00\",\n          \"endTime\": \"11:00\",\n          \"isBooked\": true\n        }\n      ],\n      \"room\": {\n        \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n        \"name\": \"Conference Room\",\n        \"roomNo\": 201,\n        \"floorNo\": 1,\n        \"capacity\": 20,\n        \"pricePerSlot\": 100,\n        \"amenities\": [\"Projector\", \"Whiteboard\"],\n        \"isDeleted\": false\n      },\n      \"user\": {\n        \"_id\": \"60d9c4e4f3b4b544b8b8d1c4\",\n        \"name\": \"John Doe\",\n        \"email\": \"john.doe@example.com\",\n        \"phone\": \"1234567890\",\n        \"address\": \"123 Main St, Anytown, USA\",\n        \"role\": \"user\"\n      },\n      \"totalAmount\": 200,\n      \"isConfirmed\": \"unconfirmed\",\n      \"isDeleted\": false\n    }\n    // other bookings ( If any )\n  ]\n}\n```\n\n**12\\. Get User's Bookings (Only Accessible by Authenticated User)**\n\n- _*Route:*_ `/api/my-bookings`(**GET**)\n- **Request Headers:**\n\n```javascript\nAuthorization:\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmF\ntZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n\nYou must include \"Bearer\" at the beginning of the token!\n```\n\n- **Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"User bookings retrieved successfully\",\n  \"data\": [\n    {\n      \"_id\": \"60d9c4e4f3b4b544b8b8d1ca\",\n      \"date\": \"2024-06-15\",\n      \"slots\": [\n        {\n          \"_id\": \"60d9c4e4f3b4b544b8b8d1c6\",\n          \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n          \"date\": \"2024-06-15\",\n          \"startTime\": \"09:00\",\n          \"endTime\": \"10:00\",\n          \"isBooked\": true\n        },\n        {\n          \"_id\": \"60d9c4e4f3b4b544b8b8d1c7\",\n          \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n          \"date\": \"2024-06-15\",\n          \"startTime\": \"10:00\",\n          \"endTime\": \"11:00\",\n          \"isBooked\": true\n        }\n      ],\n      \"room\": {\n        \"_id\": \"60d9c4e4f3b4b544b8b8d1c5\",\n        \"name\": \"Conference Room\",\n        \"roomNo\": 201,\n        \"floorNo\": 1,\n        \"capacity\": 20,\n        \"pricePerSlot\": 100,\n        \"amenities\": [\"Projector\", \"Whiteboard\"],\n        \"isDeleted\": false\n      },\n      \"totalAmount\": 200,\n      \"isConfirmed\": \"unconfirmed\",\n      \"isDeleted\": false\n    }\n  ]\n}\n```\n\n**13\\. Update Booking (Only Accessible by Admin)**\n\n- _*Route:*_ `/api/bookings/:id` (PUT)\n- **Request Headers:**\n\n```javascript\nAuthorization:\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmF\ntZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n\nYou must include \"Bearer\" at the beginning of the token! Do not copy and apply directly from the module. If you blindly follow the modules, you will be a copy master, not a developer.\n```\n\n- **Request Body:**\n\n```json\n{\n  \"isConfirmed\": \"confirmed\"\n}\n```\n\n**Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Booking updated successfully\",\n  \"data\": {\n    \"_id\": \"60d9c4e4f3b4b544b8b8d1ca\",\n    \"date\": \"2024-06-15\",\n    \"slots\": [\"60d9c4e4f3b4b544b8b8d1c6\", \"60d9c4e4f3b4b544b8b8d1c7\"],\n    \"totalAmount\": 200,\n    \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n    \"user\": \"60d9c4e4f3b4b544b8b8d1c4\",\n    \"isConfirmed\": \"confirmed\",\n    \"isDeleted\": false\n  }\n}\n```\n\n**14\\. Delete Booking (Soft Delete, Only Accessible by Admin)**\n\n- _*Route:*_ `/api/bookings/:id` (DELETE)\n- **Request Headers:**\n\n```javascript\nAuthorization:\nBearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmF\ntZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n\nYou must include \"Bearer\" at the beginning of the token! Do not copy and apply directly from the module. If you blindly follow the modules, you will be a copy master, not a developer.\n```\n\n- **Response:**\n\n```json\n{\n  \"success\": true,\n  \"statusCode\": 200,\n  \"message\": \"Booking deleted successfully\",\n  \"data\": {\n    \"_id\": \"60d9c4e4f3b4b544b8b8d1ca\",\n    \"date\": \"2024-06-15\",\n    \"slots\": [\"60d9c4e4f3b4b544b8b8d1c6\", \"60d9c4e4f3b4b544b8b8d1c7\"],\n    \"totalAmount\": 200,\n    \"room\": \"60d9c4e4f3b4b544b8b8d1c5\",\n    \"user\": \"60d9c4e4f3b4b544b8b8d1c4\",\n    \"isConfirmed\": \"confirmed\",\n    \"isDeleted\": true\n  }\n}\n```\n\n## Others\n\n### **1\\. No Data Found:**\n\nWhen retrieving data, if the database collection is empty or no matching data is found, return the message: \"No data found.\"\n\n```json\n{\n  \"success\": false,\n  \"statusCode\": 404,\n  \"message\": \"No Data Found\",\n  \"data\": []\n}\n```\n\n### **2\\. Error Handling:**\n\nImplement proper error handling throughout the application. Use global error handling `middleware` to catch and handle errors, providing appropriate error responses with error messages.\n\n**Error Response Object Should include the following properties:**\n\n- success → false\n- message → Error Type → Validation Error, Cast Error, Duplicate Entry\n- errorMessages\n- stack\n\n**Sample Error Response**\n\n```json\n   {\n    \"success\": false,\n    \"message\": \"E11000 duplicate key error collection: univerity-management.students index: email_1 dup key: { email: \\\\\"user2@gmail.com\\\\\" }\",\n    \"errorMessages\": [\n        {\n            \"path\": \"\",\n            \"message\": \"E11000 duplicate key error collection: univerity-management.students index: email_1 dup key: { email: \\\\\"user2@gmail.com\\\\\" }\"\n        }\n    ],\n    \"stack\": \"MongoServerError: E11000 duplicate key error collection: univerity-management.students index: email_1 dup key: { email: \\\\\"user2@gmail.com\\\\\" }\\\\n    at H:\\\\\\\\next-level-development\\\\\\\\university-management-auth-service\\\\\\\\node_modules\\\\\\\\mongodb\\\\\\\\src\\\\\\\\operations\\\\\\\\insert.ts:85:25\\\\n    at H:\\\\\\\\next-level-development\\\\\\\\university-management-auth-service\\\\\\\\node_modules\\\\\\\\mongodb\\\\\\\\src\\\\\\\\cmap\\\\\\\\connection_pool.ts:574:11\\\\n    at H:\\\\\\\\next-level-development\\\\\\\\university-writeOrBuffer (node:internal/streams/writable:391:12)\"\n}\n```\n\n###\n\n### **3\\. Not Found Route:**\n\nImplement a global \"Not Found\" handler for unmatched routes. When a route is not found, respond with a generic message: \"Not Found.”\n\n```json\n{\n  \"success\": false,\n  \"statusCode\": 404,\n  \"message\": \"Not Found\"\n}\n```\n\n### **4\\. Authentication Middleware:**\n\nImplement an Authentication Middleware to authenticate your application. Ensures that only user and admin can access their own accessible routes.\n\n```json\n{\n  \"success\": false,\n  \"statusCode\": 401,\n  \"message\": \"You have no access to this route\"\n}\n```\n\n### **5\\. Zod Validation:**\n\nThe API employs Zod for input validation, ensuring data consistency. When validation fails, a 400 Bad Request status code is returned, accompanied by detailed error messages specifying the erroneous fields and reasons.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsejan%2Fco-work-booker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdsejan%2Fco-work-booker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdsejan%2Fco-work-booker/lists"}