I’ve been running parse server through express for quite a while. Taking a look at the README.md, it would appear that asome features can be loaded through environment variables. I attempted to fire up my parse server environment with a readOnlyMasterKey. Taking a look at Options/Definitions.js, the documentation implies that I can accomplish this by indicating the PARSE_SERVER_READ_ONLY_MASTER_KEY environment variables. But this doesn’t seem to work.

Taking a look at the source code, it would appear that “env” field in Options/Definitions.js is just truly utilized by the CLI parse server startup strategy. I’ve figured out how to load the environment variables on an express based parse server, much the same as it is done with the CLI.

const ParseServerOptions = require("parse-server/lib/Options/Definitions").ParseServerOptions;

const DefinitionDefaults = Object.keys(ParseServerOptions).reduce(
  (memo, key) => {
    const def = ParseServerOptions[key];
    let envVar = def.env;
    if(envVar) {
      let envValue = process.env[envVar];
      if(envValue) {
        memo[key] = envValue;
      }
    }
    return memo;
  },
  {}
); 

const api = new ParseServer(DefinitionDefaults);

Tested with parse-server 3.10.0 and express 4.17.1