2.0.0 • Published 8 months ago

ms-rating v2.0.0

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

Rating microservice

Setting Up the Local Environment

  1. Set up Node using NVM:
   nvm install v18.20.4
   nvm alias default v18.20.4
  1. Configure access to the npmjs registry:
    • Request access from admin to the Vertt private NPM registry.
    • Log in to the npmjs registry: npm login
    • Verify your authorization: npm whoami --registry https://registry.npmjs.org/

Starting the service locally

  1. Make sure there is a env-files directory on the same level as this directory
  • The env-files directory should contain files with env variables for all services
  • Some of the services have a package @vertt/assert-env-config installed. If used, the function assertEnvConfig(config) from the package checks whether all env variables are initialized. If this condition is not met, it throws an error and the service is unreachable. The assertEnvConfig(config) function is called in the index.ts file. If you want to start the service without initializing all env variables, just remove this function from the code.
  • Mandatory environment variables are:
    • PORT - To initialize a unique port
    • databaseUrl - To setup a connection to the database
    • headerTokenMicroservice - To be able to communicate with other services
    • npmToken - To log in to npm with the private user who is owner of the private vertt packages.
  1. Verify the NPM access and install dependecies by running npm ci
  2. Database connection
  • Connecting to DEV database
    • Navigate to the directory where your key pair credentials (*.pem file) from AWS is located and run this command in terminal: ssh -i ./CREDENTIALS_NAME.pem -L LOCAL_PORT:MYSQL_HOST:REMOTE_PORT SSH_USER@SSH_HOST, where CREDENTIALS_NAME is the name of your pem file, LOCAL_PORT is your local port to be mapped with the REMOTE_PORT, MYSQL_HOST is the hostname of the MySQL server you wanna connect to, SSH_USER and SSH_HOST are the username and the hostname of the SSH server to tunnel via. Make sure to keep this connection active while your service is running.
    • Your databaseUrl env var should have the following format: mysql://REMOTE_DB_USERNAME:REMOTE_DB_PASSWORD@localhost:LOCAL_PORT/REMOTE_DATABASE_NAME
    • Note that the LOCAL_PORT in the two previous commands should be the same
  • Connecting to local database
    • Use local credentials for databaseUrl env var
  1. Start the service with npm run start-local