{"id":26269682,"url":"https://github.com/shahadathhs/barisathi-server","last_synced_at":"2026-04-12T09:37:12.550Z","repository":{"id":280219139,"uuid":"941329787","full_name":"shahadathhs/barisathi-server","owner":"shahadathhs","description":"This repository contains the backend server for the Bari Sathi project. It serves as the main API backend, handling authentication, listings, and bookings.","archived":false,"fork":false,"pushed_at":"2025-05-08T10:56:59.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T11:40:10.509Z","etag":null,"topics":["cors","expressjs","mongoose","nodejs","tyepscript","zod-validation"],"latest_commit_sha":null,"homepage":"https://barisathi-server.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/shahadathhs.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,"zenodo":null}},"created_at":"2025-03-02T03:02:58.000Z","updated_at":"2025-05-08T10:57:02.000Z","dependencies_parsed_at":"2025-03-02T04:19:25.700Z","dependency_job_id":"436109d5-62d5-49d2-8651-d4dc4af9deac","html_url":"https://github.com/shahadathhs/barisathi-server","commit_stats":null,"previous_names":["shahadathhs/barisathi-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shahadathhs/barisathi-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahadathhs%2Fbarisathi-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahadathhs%2Fbarisathi-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahadathhs%2Fbarisathi-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahadathhs%2Fbarisathi-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shahadathhs","download_url":"https://codeload.github.com/shahadathhs/barisathi-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahadathhs%2Fbarisathi-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31710792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T06:22:27.080Z","status":"ssl_error","status_checked_at":"2026-04-12T06:21:52.710Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cors","expressjs","mongoose","nodejs","tyepscript","zod-validation"],"created_at":"2025-03-14T05:15:47.261Z","updated_at":"2026-04-12T09:37:12.525Z","avatar_url":"https://github.com/shahadathhs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bari Sathi Server\n\nThis repository contains the backend server for the Bari Sathi project. It serves as the main API backend, handling authentication, listings, and bookings. The server is built using Node.js and Express and supports JWT-based authentication, user role management, and more.\n\n## Live Demo\n\n- **Live URL:** [https://barisathi-server.vercel.app/api](https://barisathi-server.vercel.app/api)\n\n## Repository Links\n\n- **Server Repository:** [github.com/shahadathhs/barisathi-server](https://github.com/shahadathhs/barisathi-server)\n- **Client Repository:** [github.com/shahadathhs/barisathi](https://github.com/shahadathhs/barisathi)\n\n## Table of Contents\n\n- [Features](#features)\n- [📦 Packages Used](#-packages-used)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n  - [Environment Configuration](#environment-configuration)\n- [Running Locally](#running-locally)\n- [API Endpoints](#api-endpoints)\n- [🗄️ Models \u0026 Schemas](#️-models--schemas)\n\n## Features\n\n- **Authentication:** User registration, login, profile updates, password changes, and role management.\n- **Listings Management:** CRUD operations for listings (create, read, update, delete).\n- **Bookings Management:** Create bookings, fetch booking details, update booking status, and delete bookings.\n- **Role-Based Access Control:** Different endpoints accessible based on user roles (ADMIN, LANDLORD, TENANT).\n- **Middleware Integration:** Includes API info logging, error handling, and request validation.\n\n## 📦 Packages Used\n\n### Dependencies\n\n| Package      | Version |\n| ------------ | ------- |\n| bcryptjs     | ^3.0.0  |\n| cors         | ^2.8.5  |\n| dotenv       | ^16.4.5 |\n| express      | ^4.21.1 |\n| jsonwebtoken | ^9.0.2  |\n| mongoose     | ^8.8.2  |\n| ms           | ^2.1.3  |\n| nodemon      | ^3.1.7  |\n| winston      | ^3.17.0 |\n| zod          | ^3.23.8 |\n\n### Dev Dependencies\n\n| Package                          | Version  |\n| -------------------------------- | -------- |\n| @eslint/js                       | ^9.15.0  |\n| @types/cors                      | ^2.8.17  |\n| @types/express                   | ^5.0.0   |\n| @types/jsonwebtoken              | ^9.0.8   |\n| @types/node                      | ^22.9.1  |\n| @typescript-eslint/eslint-plugin | ^8.15.0  |\n| @typescript-eslint/parser        | ^8.15.0  |\n| eslint                           | ^9.15.0  |\n| eslint-define-config             | ^2.1.0   |\n| eslint-plugin-import             | ^2.31.0  |\n| globals                          | ^15.12.0 |\n| prettier                         | ^3.3.3   |\n| ts-node-dev                      | ^2.0.0   |\n| tsc-alias                        | ^1.8.13  |\n| tsconfig-paths                   | ^4.2.0   |\n| typescript                       | ^5.7.3   |\n| typescript-eslint                | ^8.15.0  |\n\n## Getting Started\n\n### Prerequisites\n\n- **Node.js:** Ensure you have Node.js installed (version 14 or above is recommended).\n- **npm:** Comes bundled with Node.js.\n\n### Installation\n\n1. **Clone the Repository:**\n\n   ```bash\n   git clone https://github.com/shahadathhs/barisathi-server.git\n   cd barisathi-server\n   ```\n\n2. **Install Dependencies:**\n\n   ```bash\n   npm install\n   ```\n\n### Environment Configuration\n\nCreate a `.env` file in the root directory based on the provided example (`.env.example`). Here is a sample configuration:\n\n```dotenv\n# General\nPORT=8080\nNODE_ENV=development\n\n# Database\nDATABASE_URL=\u003cyour-mongo-uri\u003e\n\n# JWT\nJWT_SECRET=\u003cyour-jwt-secret\u003e\nJWT_EXPIRES_IN=1d\n```\n\nReplace placeholders with your actual values.\n\n## Running Locally\n\nTo run the server locally, follow these steps:\n\n1. **Ensure your `.env` file is properly configured.**\n\n2. **Install the dependencies:**\n   ```bash\n   npm install\n   ```\n\n3. **Start the Development Server:**\n\n   ```bash\n   npm run start:dev\n   ```\n\n   This command will start the server on the port specified in your `.env` file (default is 5000). The server supports hot reloading for a smoother development experience.\n\n4. **Access the Server:**\n\n   - Open your browser and navigate to `http://localhost:8080/` to see the welcome message.\n   - Access the root API route at `http://localhost:8080/api` for more details.\n\n## API Endpoints\n\n### Authentication Routes (`/api/auth`)\n\n| Method | Endpoint                    | Description                 | Auth                    |\n| ------ | --------------------------- | --------------------------- | ----------------------- |\n| POST   | `/api/auth/register`        | Register new user           | Public                  |\n| POST   | `/api/auth/login`           | Login user                  | Public                  |\n| PATCH  | `/api/auth/update-profile`  | Update own profile          | LANDLORD, TENANT, ADMIN |\n| PATCH  | `/api/auth/update-password` | Change own password         | Any authenticated       |\n| POST   | `/api/auth/:id/delete`      | Soft-delete user            | LANDLORD, TENANT        |\n| GET    | `/api/auth/getAll`          | List all users              | ADMIN                   |\n| PATCH  | `/api/auth/:id/role`        | Change a user’s role        | ADMIN                   |\n| PATCH  | `/api/auth/:id/active`      | Toggle user active/inactive | ADMIN                   |\n\n### Listing Routes (`/api/listings`)\n\n| Method | Endpoint                 | Description                         | Auth            |\n| ------ | ------------------------ | ----------------------------------- | --------------- |\n| POST   | `/api/listings/`         | Create a listing                    | LANDLORD        |\n| GET    | `/api/listings/`         | Get all listings                    | Public          |\n| GET    | `/api/listings/landlord` | Get listings for logged-in landlord | LANDLORD        |\n| GET    | `/api/listings/:id`      | Get listing details                 | Public          |\n| PATCH  | `/api/listings/:id`      | Update a listing                    | LANDLORD, ADMIN |\n| DELETE | `/api/listings/:id`      | Delete a listing                    | LANDLORD, ADMIN |\n\n### Booking Routes (`/api/bookings`)\n\n| Method | Endpoint                   | Description             | Auth                    |\n| ------ | -------------------------- | ----------------------- | ----------------------- |\n| POST   | `/api/bookings/`           | Create a booking        | TENANT                  |\n| GET    | `/api/bookings/`           | Get all bookings        | ADMIN                   |\n| GET    | `/api/bookings/tenant`     | Get tenant’s bookings   | TENANT                  |\n| GET    | `/api/bookings/landlord`   | Get landlord’s bookings | LANDLORD                |\n| GET    | `/api/bookings/:id`        | Get booking details     | ADMIN, LANDLORD, TENANT |\n| PATCH  | `/api/bookings/:id/status` | Update booking status   | LANDLORD, TENANT        |\n| DELETE | `/api/bookings/:id`        | Delete a booking        | ADMIN                   |\n\n## 🗄️ Models \u0026 Schemas\n\n### Mongoose Models\n\n- **User** (`src/modules/auth/auth.model.ts`)  \n  Fields: `name`, `email` (unique), `phone` (unique), `password` (hashed), `role` (enum), `isActive`, `isDeleted`, timestamps.  \n  Methods: `matchPassword()`, `updatePassword()`, `toProfileJSON()`, `isAdmin()`.\n\n- **Listing** (`src/modules/listing/listing.model.ts`)  \n  Fields: `location`, `description`, `rentAmount`, `bedrooms`, `images[]`, `amenities[]`, `landlord` (ref), timestamps.\n\n- **Booking** (`src/modules/booking/booking.model.ts`)  \n  Fields: `_id`, `listing` (ref), `landlord` (ref), `tenant` (ref), `tenantMessage`, `status` (enum), `checkInDate`, `checkOutDate`, timestamps.\n\n### Zod Validation Schemas\n\n- **AuthValidation** (`src/modules/auth/auth.validation.ts`)\n\n  - `registerUserZodSchema` (name, email, phone, password, role)\n  - `updateProfileZodSchema` (name, email, phone)\n\n- **ListingValidation** (`src/modules/listing/listing.validation.ts`)\n\n  - `createListingSchema` (location, description, rentAmount, bedrooms, images?, amenities?)\n  - `updateListingSchema` (optional fields for updates)\n\n- **BookingValidation** (`src/modules/booking/booking.validation.ts`)\n  - `createBookingSchema` (listing, checkInDate, checkOutDate, tenantMessage, landlord)\n  - `updateBookingSchema` (status enum)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahadathhs%2Fbarisathi-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahadathhs%2Fbarisathi-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahadathhs%2Fbarisathi-server/lists"}