Meds.com
Meds.com
Setup Backend Service
Setup Backend Service

Setup Backend Service

Use Patient Service as example

  • Use gh CLI tool by Github (highly recommended and will use this method for this tutorial) you could also use HTTPS or SSH options, our organization is at https://github.com/meds-com
  • Clone the Patient Service repository
  • gh repo clone meds-com/patient-service

  • Make sure you have npm installed (i.e., node.js) installed and are using the proper version
    • Use nvm to manage npm versions. Read more about this in one of the answers of this stackExchange post .
    • To enable key generation for authentication, make sure the admin, doctor and default entries for secrets are not empty.
  • Install gulp and nodemon in the global scope to build and start your projects later npm i -g gulp nodemon
  • Create ~/.npmrc with the right credential (ask mentor or a team member for the registry url and authToken) to obtain access modules in the @bluechew scope
  • Ask your mentor or a team member to create the Google service accounts for you with the right permissions attached, and save them as the keys/*-develop-key.json file under your dev root folder and the project folder.
    • Example: ~/development/keys/bluechew-develop-key.json and ~/development/PatientService/keys/bluechew-develop-key.json. This file will be required for you to run the cloud-sql-proxy command.
    • Note for Windows user: add this to the .npmrc file in order to run npm scripts without further modificationsnpm config set script-shell "C:\Program Files\Git\bin\bash.exe"=truescript-shell=C:\Program Files\Git\bin\bash.exemodify the bash.exe file path based on the actual location
  • Ask your mentor or a team member to create the credentials for MySQL database (i.e. bluechew-develop:bluechew2), you will need it to interact with the data via cloud-sql-proxy. Refer to the first section(Start the Cloud SQL Auth Proxy ) for more info on how cloud-sql-proxy works;
    • Example: command cloud-sql-proxy --credentials-file=/path/to/bluechew-develop-key.json "bluechew-develop:us-central1:bluechew2?port=3308" will use your Google Service Account file to proxy the bluechew2 database in the bluechew-develop project in us-central1 region locally on port 3308.
  • By now you should have the key (service account ), added an user account (User Account ) and secret permission enabled (medical-service-env-local ), if not request from your mentor or a team member.
  • Install npm modules
  • $ npm i

  • For local development, please copy the config/init.config.dev.local.json as src/config/init.config.json.
  • The following steps are marked as [Optional] since they are a legacy way to set up local credentials. Currently we manage our secrets remotely and they are not needed anymore.
  • [Optional] Generate reference config file /envs/environments.dev.json as a copy of /envs/environments.example.json.
  • [Optional] Update the reference config /envs/environments.dev.json
    • Specify the necessary credentials (SQL, intercom etc...) and make sure you are using credential from a development project and not from a production gcloud project.
  • [Optional] Rename and copy the reference config from envs/ to src/config/
  • cp -rf envs/environments.dev.json src/config/environments.json

  • Build Gulp
  • $ gulp

  • Watch for Development
  • $ gulp watch

    $ npm run dev

  • Open your browser on http://localhost:5000
  • Newer versions of macOS may have the port 5000 occupied by Airplay service, if that happens, prepend PORT=WXYZ to the npm command, for example: PORT=8888 npm run dev, then you can access the service at http://localhost:8888

Last updated: @February 17, 2026