Hi @evtimDev,
I’m not sure if I’m understanding you 100%, so forgive me if not.
I don’t think you’ll be able to do that, because of the callback’s that form part of the configuation.
This is what I do - hopefully it’s of some use to you.
I have a configuration.js file that lives in the src
dir of my project. It makes use of the dotenv
and convict
packages for loading in all my environment variables:
const path = require("path");
require("dotenv").config({ path: path.join(__dirname, "../.env") });
const convict = require("convict");
const config = convict({
env: {
doc: "The application environment",
format: ["development", "staging", "production"],
default: "development",
env: "NODE_ENV"
},
AWS: {
sesVerifiedDomain: "example.com",
sesUri: "https://email.eu-west-1.amazonaws.com",
s3ImageBucket: {
doc: "S3 bucket for images",
format: String,
default: "mybucket"
},
accessKeyId: {
doc: "AWS Access Key ID",
format: String,
default: "",
env: "AWS_ACCESS_KEY_ID"
},
secretAccessKey: {
doc: "AWS Secret Access Key",
format: String,
default: "",
env: "AWS_SECRET_ACCESS_KEY"
},
region: {
doc: "AWS Region",
format: String,
default: "",
env: "AWS_REGION"
},
...
}
});
config.loadFile(path.join(__dirname, "../config/" + config.get("env") + ".json"));
module.exports = config.getProperties();
Then, in my server.js file, I load in my config file as per the below and use the config in my app setup:
const config = require("./src/configuration");
const parseApi = new ParseServer({
...,
databaseURI: config.parse.dbUri,
serverURL: `${config.parse.serverUrl}/parse`,
publicServerURL: `${config.parse.serverUrl}/parse`,
masterKey: config.parse.masterKey,
appId: config.parse.appId,
...,
emailAdapter: {
module: "parse-server-api-mail-adapter",
options: {
// The email address from which emails are sent.
sender: config.mail.fromAddress,
...,
I hope this is at least somewhat helpful!?