Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Last bits of rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Nov 13, 2017
1 parent 15f3e5a commit 555830c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 37 deletions.
11 changes: 3 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@
"ecmaVersion": 8,
"sourceType": "module"
},
"extends": [
"eslint:recommended",
"prettier"
],
"plugins": [
"prettier"
],
"extends": ["eslint:recommended", "prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error", {"singleQuote": true, "printWidth": 120}]
"prettier/prettier": ["error", { "singleQuote": true, "printWidth": 120 }]
}
}
2 changes: 1 addition & 1 deletion .release.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"baseDir": "tmp",
"files": "",
"pkgFiles": [],
"beforeStageCommand": "!cat index.yml ../README.md > index.md"
"beforeStageCommand": "cat index.yml ../README.md > index.md"
}
}
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ This is where dyson comes in. Get a full fake server for your application up and

* Easy configuration, extensive options
* Dynamic responses
* Responses can use request data (e.g. to simulate different login scenarios based on username):
* Response templates or properties can be functions based on request (`req.*`):
* Request path
* GET/POST parameters
* Cookies
* Respond with different status code for specific requests (e.g. 404 for `?id=999`)
* Includes random data generators
* Supports to proxy non-configured endpoints to actual services
* Supports GET, POST, PUT, DELETE, PATCH (and OPTIONS)
* Supports CORS
* Supports delayed responses
* Proxy non-configured endpoints to actual services
* CORS
* GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
* Delayed responses
* Includes random data generators
* Includes dummy image generator
* Use any external or local image service (included)
* Supports base64 encoded image strings
* Supports required parameter validation
* Required parameter validation

## Endpoint Configuration

Expand All @@ -65,10 +65,10 @@ The `path` string is the usual argument provided to [Express](http://expressjs.c

The `template` object may contain properties of the following types:

* function: the function will be invoked with arguments _(params, query, body, cookies, headers)_
* string, boolean, number, array: returned as-is
* object: will be recursively iterated
* promise: if the function is a promise, it will be replaced with the resolving value
* 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 resolved (and replaced with the resolved value).

Note: the `template` can also be a _function_ returning the actual data. The template function itself is also invoked with arguments _(params, query, body, cookies, headers)_.

Expand Down
18 changes: 9 additions & 9 deletions dummy/get/dummy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = {
path: '/dummy/:id?',
proxy: false,
template: {
id: function(params) {
return params.id || 1;
},
name: 'Lars',
status: 'OK'
}
path: '/dummy/:id?',
proxy: false,
template: {
id: function(params) {
return params.id || 1;
},
name: 'Lars',
status: 'OK'
}
};
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@
"lint": "eslint lib test",
"format": "prettier --write \"{lib,test}/**/*.js\""
},
"repository": {
"type": "git",
"url": "https://github.com/webpro/dyson"
},
"engines": {
"node": ">=6"
},
"dependencies": {
"body-parser": "1.17.2",
"cookie-parser": "1.4.3",
"cors": "2.8.4",
"express": "4.15.3",
"express": "4.16.2",
"lodash": "4.17.4",
"request": "2.81.0",
"require-directory": "2.1.1",
Expand All @@ -51,13 +58,6 @@
"sinon": "4.1.2",
"supertest": "3.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/webpro/dyson"
},
"engines": {
"node": ">=6"
},
"ava": {
"babel": {
"presets": [
Expand Down

0 comments on commit 555830c

Please sign in to comment.