Real Estate Site Backend Developer Documentation This Documentation never open for user
- Aşağıdaki maddeleri uygularken hata alırsanız lütfen @icelal_kskn'e ulaşın
- Değişiklik yapmak isterseniz projeyi forklayarak başlayın
- Projeyi klonlayın
git clone https://github.com/icelal-kskn/Horse_Property_Backend.git
- Gerekli bağımlılıkları indirin
npm install
- Ana dizinde yeni bir env dosyası oluşturun (yeni dosya oluşturup .env yapmanız yeterlidir)
- Aşağıdaki dosyayı env dosyasına yapıştırın sonrasında çalıştırın
JWT_SECRET= this_must_keep_secret_xd
PORT= 1806
DB_HOST= mongodb+srv://testuser:[email protected]/?retryWrites=true&w=majority&appName=HorseCluster
- Projeyi Çalıştırın
- Nodemon ile çalıştırmak için yukarıdakini kullanın
- Normal çalıştırmak için aşağıdakini kullanın
npm run server
npm start
MongoDB Database
- Email: [email protected]
- Password: oluşturdumtestiçin
- A structure that directs the user to categories (for sale, for rent, land, etc.) so that they know what to do at the first login.
- Search bar and filtering options (price, square meter, location, etc.).
- It should be possible to search, list, view price analysis without registration and login.
- Login requirement to write comments and add to favorites.
- The “price/m²” for each property should be automatically calculated and displayed to the user.
- Map-based search or suggestion based on location.
- User can add properties to favorites or compare multiple properties.
-The agent can see how many people have favorited the properties they have added.
-Agents can add, edit, remove properties by managing their own portfolio.
- Can edit or delete comments on the platform.
- Can block agents who violate the rules.
/api
POST /property/
Description: Creates a new property listing.
Request Body:
Field | Type | Required | Description | Constraints |
---|---|---|---|---|
title |
string |
Yes | The title of the property. | Min: 5, Max: 100 characters |
description |
string |
Yes | A detailed description of the property. | Min: 20, Max: 1000 characters |
price |
number |
Yes | The price of the property. | Must be >= 0 |
type |
string |
Yes | Type of the property. | Must be one of apartment , house , villa , land |
status |
string |
Yes | Sale status of the property. | Must be one of for-sale , for-rent |
location |
object |
Yes | Location details of the property. | Contains city , district , address , and optional coordinates (lat/lng) |
features |
object |
No | Additional features of the property. | Includes rooms , bathrooms , size , floor , heating , age |
images |
array |
No | Array of image URLs. | Each must be a valid URI |
Response:
201 Created
: Property successfully created.400 Bad Request
: Validation error.
GET /
Description: Fetches all properties with optional filters, sorting, and pagination.
Access: Public.
Query Parameters (Optional):
Parameter | Type | Description |
---|---|---|
type |
string |
Filter by property type (apartment , house , etc.). |
status |
string |
Filter by status (for-sale , for-rent ). |
city |
string |
Filter by city name (case insensitive). |
district |
string |
Filter by district name (case insensitive). |
minPrice |
number |
Minimum price filter. |
maxPrice |
number |
Maximum price filter. |
minSize |
number |
Minimum size filter (e.g., in square meters). |
maxSize |
number |
Maximum size filter. |
rooms |
number |
Filter by number of rooms. |
page |
number |
Pagination: Page number (default: 1). |
limit |
number |
Pagination: Items per page (default: 10). |
sort |
string |
Sort by field (e.g., price , createdAt ). Prefix - for descending order. |
Response:
200 OK
: Returns a list of properties and pagination details.500 Server Error
: Error while fetching properties.
GET /:id
Description: Fetches a specific property by its ID.
Access: Public.
Response:
200 OK
: Returns the property details, including the owner's information.404 Not Found
: Property not found.500 Server Error
: Error while fetching the property.
PUT /:id
Description: Updates an existing property listing.
Access: Private (requires JWT token in Authorization
header).
Request Body: Partial or complete updates are allowed (fields follow the same structure as the Create a Property endpoint).
Response:
200 OK
: Returns the updated property object.401 Unauthorized
: User does not own the property.404 Not Found
: Property not found.500 Server Error
: Error while updating the property.
DELETE /:id
Description: Deletes a specific property by its ID.
Access: Private (requires JWT token in Authorization
header).
Response:
200 OK
: Confirms property deletion.401 Unauthorized
: User does not own the property.404 Not Found
: Property not found.500 Server Error
: Error while deleting the property.
POST /user/register/
Description: Registers a new user.
Request Body:
Field | Type | Required | Description | Constraints |
---|---|---|---|---|
email |
string |
Yes | User's email address. | Must be a valid email |
password |
string |
Yes | User's password. | Min: 6, Max: 30 characters |
fullName |
string |
Yes | Full name of the user. | Min: 2, Max: 50 characters |
phone |
string |
No | User's phone number. | Must match the pattern +123456789 |
userType |
string |
No | Type of user (role). | One of regular , agent , admin |
Response:
201 Created
: User successfully registered.400 Bad Request
: Validation error.
POST /login
Description: Logs in an existing user.
Request Body:
Field | Type | Required | Description | Constraints |
---|---|---|---|---|
email |
string |
Yes | User's email address. | Must be a valid email |
password |
string |
Yes | User's password. | Must match registered password |
Response:
200 OK
: JWT token is returned.400 Bad Request
: Invalid credentials.
GET /profile
Description: Retrieves the logged-in user's profile.
Access: Private (requires JWT token in Authorization
header).
Response:
200 OK
: Returns user details excluding the password.500 Server Error
: Error while fetching user details.
PUT /profile
Description: Updates the logged-in user's profile.
Access: Private (requires JWT token in Authorization
header).
Request Body:
Field | Type | Required | Description | Constraints |
---|---|---|---|---|
fullName |
string |
No | Updated full name of the user. | Min: 2 characters |
phone |
string |
No | Updated phone number. | Must match pattern +123456789 |
Response:
200 OK
: Returns updated user details.500 Server Error
: Error while updating user.
DELETE /profile
Description: Deletes the logged-in user's profile.
Access: Private (requires JWT token in Authorization
header).
Response:
200 OK
: Confirms user deletion.500 Server Error
: Error while deleting user.
- All endpoints expect request bodies in JSON format.
- Ensure that required fields are properly provided to avoid validation errors.
- Optional fields, if present, must meet their respective constraints.