Mini App Portal Api
Use the folloing steps to run this project
npm install
use npm install to install all the project dependancies there is one dependancy for @ras/auth library to install that Ask your supervisor to give access to https://dev.azure.com/ssed-mdg/mdg-common/_packaging?_a=package&feed=mdg-private-feed%40Release&package=%40rakuten-ssed%2Fras-auth&version=1.0.0&protocolType=Npm
once you have the access follow the following instructions
https://dev.azure.com/ssed-mdg/mdg-common/_packaging?_a=connect&feed=mdg-private-feed%40Release Click NPM then follow the steps to setup your .npmrc in the root of this repository
The Rakuten private dependency repository does not contain all of the npm packages; therefore when following the steps to create the .npmrc file, add the text @rakuten-ssed:
in front of registry
on the first line.
@rakuten-ssed:registry=https://example.com
Then run npm install
Load config file from DEV
This config file can either be obtained from your supervisor or directly from DEV
To get it directly: https://miniapps-portal-api-dev-japaneast-wa.scm.azurewebsites.net/DebugConsole/?shell=powershell Navigate: site > wwwroot > config > values > config.json
Take this file and paste it in config/values/localConfig.json in this project.
Edit the following values to point to your local instead of dev:
database_host=localhost
database_port=3306
database_user=map_admin
database_password=db-password
database_database=miniapps
database_dialect='mariadb'
Create a .env file in the root of the project that contains:
CONFIG_OVERRIDE=localConfig.json
Or use the default config.json values. They should work locally if you add these secret values to your .env file:
#RAS keys
appApiSettings_subscriptionKey = {secret value}
userApiSettings_subscriptionKey = {secret value}
projectApiSettings_authHeaderValue = {secret value}
authSwitchSettings0_aud = {secret value}
authSwitchSettings1_aud = {secret value}
azureAdSettings_clientID = {secret value}
#Optional
sendGrid_apiKey = {secret value}
This configuration is needed to access remote services needed for the local development server.
Setup local database
Install docker if not otherwise installed
In the root of this repository run npm run start_local_db
. This will start your local db in a docker instance.
Migrations
Navigate to sequelize-create-or-modify-tables
directory in the jenkins-job repo here
Run the migrations by running the command npm run migrate
Setup local Storage
Set up local storage by running the below command.
npm run start_local_storage
This will run a MinIO server on http://localhost:9000/ and files will save to ~/minio/Data
Run locally
Once everything is setup properly
run npm run devStart
to start this project running in development mode. Whenever code changes the server will reload.
Set up testing using VSCode
Download the JavaScript Debugger extension in VSCode.
In the 'Run and Debug' panel, select create a launch.json file
and select Node.js
Replace the default configurations array in the launch.json file with the following
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229
},
{
"name": "Debug Jest Tests",
"type": "node",
"runtimeVersion": "17.1.0",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand",
"--coverage"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
In order to customize the behavior of the jest test runner, add or remove desired options to the runtimeArgs array in the launch request configuration.
To Run the tests, select Debug Jest Test
in the Run and Debug
window and press F5 or the Start Debugging
button.
To run Jaeger locally run:
docker run -d \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 14268:14268 \
-p 14250:14250 \
-p 16686:16686 \
-p 5778:5778 \
--name jaeger jaegertracing/all-in-one:1.22
You can then check the server on http://localhost:16686/
Updating SendGrid Mail Templates
Updates to SendGrid Mail Templates are done in the MAP SendGrid account which can be accessed here: https://app.sendgrid.com/
Please ask the PDM grant you access to the MAP Account to edit the templates.
Templates can only have one active version at a time so as to not affect higher environments, any updates to a template should be made as follows:
- Duplicate the Template which you would like to update.
- Edit the version in the duplicated template with the template updates.
- Update the template-id in the helm charts with the duplicated templates id.
- Test the template in lower environments before rolling out to upper environments.
- Be sure to delete the old template after the updates have been rolled out to all environments.