File Name : apartments.js
File Path : /server/routes/apartments.js
This route is used to handle user's apartment related queries. For example: creating an apartment, updating apartment details, fetching apartments, fetching filtered apartments, delete apartment etc.
Get Apartments
GET
/api/apartments
200 404
Copy
{
success : true ,
message : 'user apartments' ,
data : apartmentObjArray : [
{
userId
address
gpsLoc
availableFrom
houseSize
spaceFor
monthlyRent
oneTimeDeposit
occupancyType
amenities
pictures
description
}
. . .
. . .
]
}
or
{
success : true ,
message : 'no apartments available' ,
data : []
}
Copy {
success : false ,
message : 'error while finding apartments for the user' ,
}
Create Apartment (Flat)
POST
/api/apartments
Request Body
200
Copy {
success : true ,
message : 'apartment created successfully' ,
data : {
userId
address
gpsLoc
availableFrom
houseSize
spaceFor
monthlyRent
oneTimeDeposit
occupancyType
amenities
pictures
description
}
}
Update Apartment
PUT
/api/apartments/?id=${_id}
200 304 404
Copy {
userId
address
gpsLoc
availableFrom
houseSize
spaceFor
monthlyRent
oneTimeDeposit
occupancyType
amenities
pictures
description
}
Copy Error occured while updating the apartment details
Copy Error occured while searching for the Apartment
Get filtered Apartments
GET
/api/apartments/filterdApartments
200
Copy {
success : true ,
message : 'filtered apartments' ,
data : filteredApartments
}
or
{
success : true ,
message : 'no apartments with this filter options available' ,
data : []
}
Delete Apartment
GET
/api/apartments/deleteApartment/?id=${id}
200
Copy {
success : true ,
message : Apartment deleted
}
or
{
success : false ,
message : 'unable to delete apartment ,id provided didnt match ' ,
}