Allow serving/testing multiple configs
Closed this issue · 3 comments
tamj0rd2 commented
Maybe there could be a .ncdcrc
config file:
const USE_SCHEMA_FILES = !!process.env.USE_SCHEMA_FILES
module.exports = {
"Book Service": {
configPath: "./src/books/config.yml",
tsconfigPath: "./src/books/tsconfig.json",
schemaPath: USE_SCHEMA_FILES && "./json-schemas/books",
port: 4000,
realAPI: "https://books-api.example.com"
},
"Film Service": {
configPath: "./src/films/config.yml",
tsconfigPath: "./src/films/tsconfig.json",
schemaPath: USE_SCHEMA_FILES && "./json-schemas/films",
port: 4001,
realAPI: "https://films-api.example.com"
},
}
Serve example:
$npx ncdc serve .ncdcrc
--schemaPath
would override for any non-explicit in the config file--watch
controls ncdc as a whole--tsconfigPath
would override for any non-explicit in the config file--force
controls ncdc as a whole--verbose
controls ncdc as a whole
Test example:
$npx ncdc test .ncdcrc
--schemaPath
would override for any non-explicit schemaPath in the config file--tsconfigPath
would override for any non-explicit tsconfigPath in the config file--force
controls ncdc as a whole--verbose
controls ncdc as a whole
Generate example:
$npx ncdc generate .ncdcrc
--schemaPath
would override for any non-explicit schemaPath in the config file--tsconfigPath
would override for any non-explicit tsconfigPath in the config file--force
controls ncdc as a whole--verbose
controls ncdc as a whole
Considerations:
- What happens when a schemaPath is used for one config but not for another?
- Not sure how doable this would be with multiple tsconfig json files. Cases where all configs have the same tsconfig and cases where configs have different tsconfigs would need testing.
- Doing this doesn't make sense if I do intend to switch to Open API specification (#169)
tamj0rd2 commented
This might help: https://github.com/yargs/yargs/blob/master/docs/advanced.md#configuration
I've also implemented something that allows multiple configPaths for generate mode to work: #231
tamj0rd2 commented
Duplicate