Is there any way json-server supports config files with predefined settings?
So I can run json-server something like that:
json-server --config <myfile-name-here>
No but it's something that I'd like/plan to add.
It would of be great. It could be just a simple .config text file that will contain strings as params on each line - something similar like mongodb does or just .json file.
It's possible now (v0.8.9), thanks to a new feature introduced in yargs.
Simply create a json-server.json file:
{
"port": 4000
}
And json-server will read it. You can also point to another config file if you want
json-server -c some_other_file db.json
is it possible to pass a .js file instead of .json?
in order to do dynamic configuration, lets say a const variable for the port property.
It's better to add how to use config file in the document, I spent about an hour searching for how to propertly use the config file.
Also there is no instruction about what are the options in the config file, and why can't we indicate the db.json in the config file?
Most helpful comment
It's better to add how to use config file in the document, I spent about an hour searching for how to propertly use the config file.
Also there is no instruction about what are the options in the config file, and why can't we indicate the db.json in the config file?