topcoder-platform / u-bahn-api

Universal Identity API
1 stars 11 forks source link

U-Bahn API

Install software

Configuration

Configuration for the application is at config/default.js and config/production.js. The following parameters can be set in config files or in env variables:

For ES.DOCUMENTS configuration, you will find multiple other configurations below it. Each has default values that you can override using the environment variables

Local deployment

Setup your Elasticsearch instance and ensure that it is up and running.

  1. Follow Configuration section to update config values, like database, etc ..
  2. Goto UBahn-api, run npm i and npm run lint
  3. Run the migrations - npm run migrations up. This will create the database, the tables.
  4. Then run npm run insert-data and insert mock data into the database.
  5. You will then run npm run migrate-db-to-es to migrate the data to elasticsearch from the database
  6. Startup server node app.js or npm run start

Migrations

Migrations are located under the ./scripts/db/ folder. Run npm run migrations up and npm run migrations down to execute the migrations or remove the earlier ones

Import data from QLDB

Make sure QLDB_NAME, AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY are set in your environment

Run npm run migrate-qldb-to-pg to import data from qldb.

Import data from S3 to QLDB

Make sure BUCKET_NAME, QLDB_NAME, AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY are set in your environment

Run npm run import-s3-data to import data from s3 to qldb.

Local Deployment with Docker

Make sure all config values are right, and you can run on local successfully, then run below commands

  1. Navigate to the directory docker

  2. Rename the file sample.env to .env

  3. Set the required AUTH0 configurations, DB configurations and ElasticSearch host in the file .env

  4. Once that is done, run the following command

    docker-compose up
  5. When you are running the application for the first time, It will take some time initially to download the image and install the dependencies

You can also head into docker-pgsql-es folder and run docker-compose up -d to have docker instances of pgsql and elasticsearch to use with the api