Setting environment variables in arrays
Hi there.
I'm currently trying to set up my hapi server to handle different config files while still beeing able to adjust a port number through environment variables.
I've published a gist, hopefully someone has little time to spare to look into it.
My problem is, running NODE_ENV=test PORT=3333 yarn start results in the server running on localhost:8080, neither localhost:1234 nor localhost:3333 is used. Removing the port from the yml results in hapi choosing a random port. I'm guessing i need to adjust the default schema.
I've already tried changing the connections-array to:
connections:{
0:{
port: {
doc: "Port binding",
format: "int",
default: 1234,
env: "PORT"
}
}
}
With no success though. The tests I've looked at don't cover this case as well. Help much appreciated, thanks in advance.
With an environment variable, how would you specify multiple ports? Alternatively, if your array has multiple objects, would setting the environment variable PORT to 3333 set that value for all objects in the array?