Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
When developing client-side applications, often either static JSON files, or an actual server, backend, datastore, or API, is used. Sometimes static files are too static, and sometimes an actual server is not available, not accessible, or too tedious to set up.
This is where dyson comes in. Get a full fake server for your application up and running in minutes.
Installation notes
Demo
Overview
Dynamic responses, based on
Request path
GET/POST parameters
Query parameters
Cookies
HTTP Methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
Dynamic HTTP status codes
CORS
Proxy (e.g. fallback to actual services)
Delayed responses
Required parameter validation
Includes random data generators
Includes dummy image generator
Use any external or local image service (included)
The path string is the usual argument provided to Express, as in app.get(path, callback);.
The template object may contain properties of the following types:
A Function will be invoked with arguments (params, query, body, cookies, headers).
Primitives of type String, Boolean, Number, Array are returned as-is
An Object will be recursively iterated.
A Promise will be replaced with its resolved value.
Note: the template itself can also be a function returning the actual data. The template function itself is also invoked with arguments (params, query, body, cookies, headers).
cache: true means that multiple requests to the same path will result in the same response
delay: n will delay the response with n milliseconds (or between [n, m] milliseconds)
proxy: false means that requests to this file can be skipped and sent to the configured proxy
size: fn is the number of objects in the collection
collection: true will return a collection
callback: fn
the provided default function is doing the hard work (can be overridden)
used as middleware in Express
must set res.body and call next() to render response
render: fn
the default function to render the response (basically res.send(200, res.body);)
used as middleware in Express
Fake data generators
You can use anything to generate data. Here are some suggestions:
Faker.js
Chance.js
dyson-generators
Just install the generator(s) in your project to use them in your templates:
npm install dyson-generators --save-dev
Containers
Containers can help if you need to send along some meta data, or wrap the response data in a specific way. Just use the container object, and return the data where you want it. Functions in the container object are invoked with arguments (params, query, data):
Would result in a 404 when requesting /feature/999.
Images
In addition to configured endpoints, dyson registers a dummy image service at /image. E.g. requesting /image/300x200 serves an image with given dimensions.
This service is a proxy to Dynamic Dummy Image Generator by Russell Heimlich.
JSONP
Override the render method of the Express middleware in the endpoint definition. In the example below, depending on the existence of the callback parameter, either raw JSON response is returned or it is wrapped with the provided callback:
If you want to run dyson over SSL you have to provide a (authority-signed or self-signed) certificate into the options.https the same way it's required for NodeJS built-in https module. Example:
Note: if running SSL on port 443, it will require sudo privileges.
GraphQL
If you want dyson to support GraphQL endpoints, you can build your own logic with the render override, or use dyson-graphql. Example:
npm install dyson-graphql --save-dev
const dysonGraphQl = require('dyson-graphql');
const schema = `
type User {
id: Int!
name: String!
}
type Query {
currentUser: User!
}
type Mutation {
createUser(name: String!): User!
updateUser(id: Int!, name: String!): User!
}
`;
module.exports = {
path: '/graphql',
method: 'POST',
render: dysonGraphQl(schema)
.query('currentUser', { id: 987, name: 'Jane Smart' })
.mutation('createUser', ({ name }) => ({ id: 456, name }))
.mutation('updateUser', ({ id, name }) => {
if (id < 1000) {
return { id, name };
}
throw new Error("Can't update user");
})
.build()
};
Custom middleware
If you need some custom middleware before or after the endpoints are registered, dyson can be initialized programmatically.
Then you can use the Express server instance (appBefore or appAfter in the example below) to install middleware before or after the dyson services are registered. An example:
You can also install dyson globally to start it from anywhere:
npm install -g dyson
Project
You can put your configuration files anywhere. The HTTP method is based on:
The method property in the configuration itself.
The folder, or an ancestor folder, containing the configuration is an HTTP method. For example mocks/post/sub/endpoint.js will be an endpoint listening to POST requests.
Defaults to GET.
dyson [dir]
This starts the services configured in [dir] at localhost:3000.
You can also provide an alternative port number by just adding it as a second argument (e.g. dyson path/ 8181).
Demo
For a demo project, see webpro/dyson-demo.
This demo was also installed with Heroku to dyson-demo.herokuapp.com.
Project Configuration
Optionally, you can put a dyson.json file next to the configuration folders (inside [dir]). It enables to configure some behavior of dyson:
Setting multiRequest to false disables the combined requests feature.
Setting bodyParserJsonLimit or bodyParserUrlencodedLimit to 1mb increases the limit to 1mb from the bodyParser's default of 100kb.
By default, the proxy is set to false
Watch/auto-restart
If you want to automatically restart dyson when you change your configuration objects, you can add nodemon as a devDependency. Say your configuration files are in the ./api folder, you can put this in your package.json:
No homepage URL was recorded for webpro/dyson in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
Does webpro/dyson have any tags?
TopGit's last sync did not record any GitHub topics for webpro/dyson. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How many stars does webpro/dyson have?
webpro/dyson has 832 GitHub stars — refresh the page for the live number, or check github.com/webpro/dyson. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is webpro/dyson open source?
TopGit's metadata for webpro/dyson does not record a license. Most public repositories on GitHub ARE open source, but the exact terms vary — verify by opening the LICENSE file directly.
Is webpro/dyson still maintained?
TopGit's metadata for webpro/dyson does not include a recent push date. Check the commit history on the GitHub repository page for the most authoritative activity timeline.
Where do I read more about webpro/dyson?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/webpro/dyson is the definitive source.
Read full README in the tab above.
Is dyson worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of dyson.