stubby4node
stubby4node copied to clipboard
Adding support for global --latency
closes issue #41
Please code review @mrak
I've also been thinking about some sort of "template" request/response that can fill in the defaults for all missing values in configured endpoints. This would be identified in some fashion in the supplied yaml file
- request: ...
response: ...
...
defaults:
request: ...
response: ...
Good idea having it templated and built into stubby4node. However, it would then make the YAML files not portable to other stubby systems.
Currently, we have a this but it is just a simple script that replaces varaibles and seperate from stubby4node.
Having the defaults passed as a separate argument would preserve the array structure in the data file and be backward-compatible from the API standpoint.
Everything within the defaults would be a simple Object.assign(endpoint, defaults)
(or more intelligent deep merge) for each configured endpoint while parsing through the data
parameter
stubby --data data.yaml --defaults <<EOF
response:
latency: 800
EOF
var stubby = new require('stubby').Stubby();
stubby.start({
data: [...],
defaults: {
response: {
latency: 800
}
}
});
Your idea makes a lot of sense and better structured
@mrak this sounds like a really good idea. This will help with DRY especially in header which typically looks identical across all calls (e.g. authentication token).
Can this be re-reviewed? Functionality would be greatly appreciated