stubby4node icon indicating copy to clipboard operation
stubby4node copied to clipboard

Adding support for global --latency

Open codeorganic opened this issue 9 years ago • 6 comments

closes issue #41

Please code review @mrak

codeorganic avatar Aug 02 '15 02:08 codeorganic

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: ...

mrak avatar Aug 06 '15 16:08 mrak

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.

codeorganic avatar Aug 06 '15 16:08 codeorganic

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
    }
  }
});

mrak avatar Aug 20 '15 18:08 mrak

Your idea makes a lot of sense and better structured

codeorganic avatar Aug 20 '15 19:08 codeorganic

@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).

elishaterada avatar Aug 20 '15 20:08 elishaterada

Can this be re-reviewed? Functionality would be greatly appreciated

kreempuff avatar Mar 17 '16 16:03 kreempuff