Giter Site home page Giter Site logo

namastecorp-assignment's Introduction

Project Name

Namastecorp assignment

Architecture

Here's a high-level diagram of the components in our application:

Application Architecture

Prerequisites

Before you begin, make sure your development environment includes the following:

  • Docker
  • Docker Compose

Installation

  1. Clone the repository:
git clone https://github.com/minhhieple97/namastecorp-assignment.git
  1. Create a .env file in the root of the project, following the example in .env.example, and fill in the necessary environment variables.

  2. Build and start the development containers with Docker Compose (Container may take up to 30 seconds to start up):

docker-compose up -d api_dev

This will build the Docker images and start the containers for the development environment.

  1. Access the Nest.js application at http://localhost:3000.

Usage

To use the API, follow these steps:

  1. Open your browser or a tool like Postman and make a POST request to http://localhost:3000/flights with the x-api-key header set to asjdfh23r9u23r9fj.
  2. In the request body, include a JSON object with an array of flight data:
{
  "flights": [
    {
      "from": "HN",
      "to": "HCM"
    },
    {
      "from": "HCM",
      "to": "SFO"
    },
    {
      "from": "SFO",
      "to": "GRU"
    },
    {
      "from": "GRU",
      "to": "SCL"
    },
    {
      "from": "SCL",
      "to": "LHR"
    },
    {
      "from": "LHR",
      "to": "CDG"
    },
    {
      "from": "CDG",
      "to": "SYD"
    },
    {
      "from": "SYD",
      "to": "JFK"
    }
  ]
}

To run the unit tests, run npm run test in the terminal. This will run all the unit tests and output the results to the console.

Migration

Need run all command bellow inside container

  1. Generate a migration file for initializing the database schema:
npm run migration:generate -- src/db/migrations/<fileName>

  1. Create a migration file:
npm run migration:create -- src/db/migrations/<fileName>

  1. Run migration file
npm run migration:run

Build image

  • Build image for specify environment
docker-compose build --no-cache --build-arg TARGET=<environment> <image_name>

Running in Production

To run the application in production, you should first build a Docker image:

docker-compose -f docker-compose.production.yml build --build-arg TARGET=production api_prod
docker-compose -f docker-compose.production.yml up -d

namastecorp-assignment's People

Contributors

minhhieple97 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.