Discuss.FOLIO.org is no longer used. This is a static snapshot of the website as of February 14, 2023.

How does a raml-module-builder based module read params from OKAPI environment varialbles and local config files?

zhang
17 May '21

I am developing a module based on raml-module-builder,dependencies and plugin configs are copied from mod-notify module.I have designed my raml file and now is trying to implement the generated interfaces.Would anyone be so kind to answer the following questions:

  1. Could I read OKAPI environment variables in my own coding assumes the module is already registed on OKAPI?
  2. How do I config module to read params from a local config file and how could I get these param in coding?
    Thank you so much.
peter
19 May '21

Hellow @zhang. There is a little bit about the Okapi environment variables in the Guide and Reference document. There are probably examples in other modules that you can use to see how this works.

In answer to your second question, I don’t think you are going to want to read parameters from a local configuration file. Doing so runs counter to how Okapi modules are multi-tenant and should be getting their settings from the Okapi environment variable mechanism described above. Perhaps you can describe what you were trying to do and we can make sure it is the aligned with the best practices for Okapi modules.

zhang
20 May '21

Thanks a lot for your reply.
I check some backend mods and find “env” property in LanuchDescriptor,is it the right way to pass specified environment variable to the module?
If I need to read env variables from Okapi, make http request to /_/env path should do the trick.
Please tell me If I got it right.
Just for my curiosity, does Okapi have the mechanism to notify mods when env variable changed?

greenhillee
25 May '21

Okapi can’t notify mods when env variable changed, only these parameters are reloaded when the module is redeployed