2.0.0 • Published 8 months ago
ms-rating v2.0.0
Rating microservice
Setting Up the Local Environment
- Set up Node using NVM:
nvm install v18.20.4
nvm alias default v18.20.4
- 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
- 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 functionassertEnvConfig(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. TheassertEnvConfig(config)
function is called in theindex.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 portdatabaseUrl
- To setup a connection to the databaseheaderTokenMicroservice
- To be able to communicate with other servicesnpmToken
- To log in to npm with the private user who is owner of the privatevertt
packages.
- Verify the NPM access and install dependecies by running
npm ci
- 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
, whereCREDENTIALS_NAME
is the name of your pem file,LOCAL_PORT
is your local port to be mapped with theREMOTE_PORT
,MYSQL_HOST
is the hostname of the MySQL server you wanna connect to,SSH_USER
andSSH_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
- Navigate to the directory where your key pair credentials (*.pem file) from AWS is located and run this command in terminal:
- Connecting to local database
- Use local credentials for
databaseUrl
env var
- Use local credentials for
- Start the service with
npm run start-local
2.0.0
8 months ago