Real Estate Rest API in Node.js + Typescrypt + Express.js + MongoDB as a proof of concept.
- GraphQL - A fun query language for APIs.
- Docker - To easily run the project with just one command.
- Jest - To keep the project bug-free.
- Swagger - To easily test the API with an awesome UI.
- Docker v19.03.0+
- Node.js v14+
- NPM v6.X+
This application runs on a docker compose with his own MongoDB database
Just make sure docker is running (if you don't have it installed, take a look on the official documentation https://docs.docker.com/get-docker/).
Run this command at the root of the project:
Linux/Mac/Windows
docker-compose up -d
The API will run on http://localhost:3021/api/
The database is automatically seeded with test data
So you are ready to test it with an example request of apartments 20KM nearest to the center of Madrid.
Example request:
GET http://localhost:3021/api/apartments/?country=Spain&nearest=20&latitude=40.41829&longitude=-3.70358
When the application is running, you can explore and test the API with Swagger UI.
You can try it at http://localhost:3021/api/swagger
If you find that working with Rest is boring, this application has a GraphQL endpoint ready to work with the apartments data.
You can try it at http://localhost:3021/api/graphql
Example query:
query {
apartmentMany {
name
description
price
address
city
country
rooms
}
}
You can run Jest tests to make sure everything it's working fine, just run at the root of the project:
Linux/Mac/Windows
cd ./real-estate-service
npm install
npm run test
If you want to run it without Docker, you first need a MongoDB instance running.
Create a .env
file in 'real-estate-service' folder based on the env.example
with this command:
Linux/Mac
cd real-estate-service
cp .env.example .env
Windows
cd real-estate-service
xcopy /I .env.example .env*
Set up the .env
file with your MongoDB credentials and custom ports.
Finally run:
Linux/Mac/Windows
npm install
npm run dev