Comments (6)
Agreed, good idea. Any chance you could submit a PR? Not sure when I have time for this.—
Sent from Mailbox
On Sat, May 31, 2014 at 10:09 PM, Terin Stock [email protected]
wrote:
It would be nice if
collection
could be a function, allowing the same file to render a collection and an individual member.Reply to this email directly or view it on GitHub:
#25
from dyson.
Looking into this, I'm not sure if it makes sense to implement the requested feature. I don't think collection()
is supposed to return the actual data.
Perhaps something like the following would work (i.e. reuse template for both endpoints)?
var g = require('dyson-generators');
var dummy = {
path: '/dummy/:id',
template: {
id: function(params) {
return params.id || g.id();
},
status: 'OK'
}
};
var dummies = {
path: '/dummy/',
collection: true,
template: dummy.template
};
module.exports = [dummy, dummies];
Otherwise, what is your specific use case?
from dyson.
It depends on the specific type of API you're mocking, sending back the initial collection data is fairly common.
But yes, I'll send a pull.
from dyson.
So I guess you mean just this (i.e. _.result()
):
collection: function(params) {
return conditionPerhapsUsingParams ? true : false;
}
That should be easy.
from dyson.
@terinjokes I missed your "pull" part, I implemented/released something that hopefully matches your needs. Can we close this?
from dyson.
Released in v0.3.1.
from dyson.
Related Issues (20)
- Default options not working HOT 7
- How to set options.strict to false HOT 2
- Hi. It is possible to use with webpack-dev-server hooks? HOT 1
- Objects being mutated within template function HOT 3
- Demo site is down HOT 3
- Explicit versions prevent fixing npm vulnerabilities HOT 2
- Query Params HOT 2
- Request is not proxied when form-data is used
- Add support for TypeScript files
- json file and js file in same folder causes problems HOT 2
- Maximum call stack size exceeded HOT 1
- How do I simulate a file upload? HOT 3
- dyson dependencies fail npm security audit HOT 3
- Return return express server instead of express HOT 2
- Sending custom status clears body HOT 5
- Documentation on what params are returned HOT 9
- Recording Mocks HOT 4
- 404 not found HOT 2
- Content-Type is converted to lowercase HOT 1
- Dyson dependencies fail npm security audit - lodash needs updating HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dyson.