Skip to content

Real Estate Rest API in Node.js + Typescrypt + Express.js + MongoDB as a proof of concept.

Notifications You must be signed in to change notification settings

caribbeanwebdev/real-estate-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS TypeScript Express.js MongoDB GraphQL Swagger Docker Jest

😎 Read me

Real Estate Rest API in Node.js + Typescrypt + Express.js + MongoDB as a proof of concept.

🌟 Extra features

  • 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.

🎯 Prerequisites

  • Docker v19.03.0+
  • Node.js v14+
  • NPM v6.X+

🚀 Installation

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

📖 Exploring the API

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

🤔 Why not GraphQL?

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
  }
}

🔍 Running Tests

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

👨‍💻 Developing locally

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

About

Real Estate Rest API in Node.js + Typescrypt + Express.js + MongoDB as a proof of concept.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages