2.0.0 • Published 1 year 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-filesdirectory on the same level as this directory
- The
env-filesdirectory should contain files with env variables for all services - Some of the services have a package
@vertt/assert-env-configinstalled. 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.tsfile. 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 privateverttpackages.
- 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_NAMEis the name of your pem file,LOCAL_PORTis your local port to be mapped with theREMOTE_PORT,MYSQL_HOSTis the hostname of the MySQL server you wanna connect to,SSH_USERandSSH_HOSTare 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
databaseUrlenv var should have the following format:mysql://REMOTE_DB_USERNAME:REMOTE_DB_PASSWORD@localhost:LOCAL_PORT/REMOTE_DATABASE_NAME - Note that the
LOCAL_PORTin 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
databaseUrlenv var
- Use local credentials for
- Start the service with
npm run start-local
2.0.0
1 year ago