Skip to content

chsjr1996/tours-nest-api

Repository files navigation

Build Status Coveralls github branch Docker Cloud Build Status Doc License MIT



Tours API

Repository Banner

A tour API built with NestJS and using some good development practices like: automated tests with coverage follow up and CI tool, docker automated builds and Swagger Documentation.

More is coming...


Topics

Back to the top


Features / ToDo

  • Docker environments (production and development)
  • Swagger Docs
  • Use Routing Controllers and Typescript!
  • Write tests and use some CI tool
  • Manage users, tours, reviews and bookings
  • Queues
  • Redis cache layer
  • Web Socket
  • GraphQL
  • Get (and keep) 100% code coverage
  • PostGIS (The challenge)

...

Back to the top


Requirements

  • NodeJS
  • PostgreSQL

or

  • Docker
  • docker-compose

Back to the top


Installation (development)

  • git clone https://github.com/chsjr1996/tours-nest-api.git
  • npm install
  • Create a copy of file .env.example with name .env and fill it
  • npm run typeorm -- migration:run - needed to create database tables
  • npm run start:dev - for run and watch modifications

If you have docker and docker-compose, you can use this command:

  • docker-compose up -d

See Docker instructions section.

Back to the top


Deploy (production)

  • Copy docker-compose.yaml with name docker-compose.prod.yaml
  • Modify app > entrypoint and use ./.docker/entrypoint-prod.sh file
  • (IMPORTANT) Modify passwords, ports, and others sensitives envs
  • Run with docker-compose -f docker-compose.prod.yaml up -d

You can use docker hub image too:

  • docker pull sourcevortex/tours-nest-api

In this case you need to have a running PostgreSQL instance and adjust the .env file.

See more in:

Docker Ports

  • 3000 application
  • 5432 PostgreSQL
  • 8080 pgAdmin4

Back to the top


Docker instructions

If you are using docker then you need run typeorm inside of APP container using exec docker command, like this:

  • docker exec -it tours-nest-api bash
  • npm run typeorm -- migration:run

Docker Tips

  • docker-compose down Stop and destroy containers
  • docker-compose stop Only stop containers
  • docker-compose start Start stopped containers
  • docker-compose restart Restart all containers

If you are using the production file (docker-compose.prod.yaml) then you need specify this after of docker-compose, e.g.:

  • docker-compose -f docker-compose.prod.yaml down

Back to the top


API Documentation

You can access the API Documentation in http://localhost:3000/api (or in other defined APP Port). The /api endpoint will display a documentation built with Swagger, if you want the OAS data then access the /api-json endpoint. (1)

Notes

  1. The OAS (OpenAPI Specification) is a language-agnostic interface to RESTful. You can use the OAS output in Insomnia Designer, only copy /api-json result and paste in 'Design' tab.

Back to the top


Related projects

Tours Admin

The Admin panel to manage this API (e.g.: create tours, remover users, ...). This app is built with Angular (11), in SPA mode and follow best development practices.

Tours Mobile

Flutter APP to user navigation (booking, register, pay, ...), coming soon...

Tours Site

Site (Angular Universal SSR) to user navigation (booking, register, pay, ...), coming soon...

Back to the top


References

This repository is based on some articles and videos. I used them as study object, then here has some differences because I merged several concepts and did some adjusts.

Notes

  1. This repository is inspired on udemy course Node.js, Express, MongoDB & More: The Complete Bootcamp 2020, originally built with vanilla Javascript and MongoDB.

Back to the top


Under development

If you see any error or want a new feature, please open a issue!

Back to the top