json-server
Advanced tools
Comparing version 0.7.19 to 0.7.20
{ | ||
"name": "json-server", | ||
"version": "0.7.19", | ||
"version": "0.7.20", | ||
"description": "Serves JSON files through REST routes.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -41,2 +41,8 @@ # JSON Server [![](https://travis-ci.org/typicode/json-server.svg)](https://travis-ci.org/typicode/json-server) [![](https://badge.fury.io/js/json-server.svg)](http://badge.fury.io/js/json-server) [![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/typicode/json-server?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
## Install | ||
```bash | ||
$ npm install -g json-server | ||
``` | ||
## Routes | ||
@@ -50,3 +56,2 @@ | ||
GET /posts/1/comments | ||
GET /posts?title=json-server&author=typicode | ||
POST /posts | ||
@@ -58,2 +63,9 @@ PUT /posts/1 | ||
To filter resources (use `.` to access deep properties) | ||
``` | ||
GET /posts?title=json-server&author=typicode | ||
GET /comments?author.name=typicode | ||
``` | ||
To slice resources, add `_start` and `_end` or `_limit` (an `X-Total-Count` header is included in the response). | ||
@@ -97,8 +109,2 @@ | ||
## Install | ||
```bash | ||
$ npm install -g json-server | ||
``` | ||
## Extras | ||
@@ -129,8 +135,6 @@ | ||
### JS file support | ||
### Generate random data | ||
You can create data programmatically. | ||
Using JS instead of a JSON file, you can create data programmatically. | ||
__Tip__ use modules like [faker](https://github.com/Marak/faker.js) or [casual](https://github.com/boo1ean/casual). | ||
```javascript | ||
@@ -152,2 +156,4 @@ // index.js | ||
__Tip__ use modules like [faker](https://github.com/Marak/faker.js), [casual](https://github.com/boo1ean/casual) or [chance](https://github.com/victorquinn/chancejs). | ||
### Add routes | ||
@@ -218,4 +224,4 @@ | ||
'/api/': '/', | ||
'/blog/:resource/:id/show: '/:resource/:id' | ||
}) | ||
'/blog/:resource/:id/show': '/:resource/:id' | ||
})) | ||
``` | ||
@@ -222,0 +228,0 @@ |
@@ -63,3 +63,3 @@ var uuid = require('node-uuid') | ||
for (var i = 0; i < value.length; i++) { | ||
if (deepQuery(value[i], q)) { | ||
if (_.deepQuery(value[i], q)) { | ||
return true | ||
@@ -70,3 +70,3 @@ } | ||
for (var k in value) { | ||
if (deepQuery(value[k], q)) { | ||
if (_.deepQuery(value[k], q)) { | ||
return true | ||
@@ -73,0 +73,0 @@ } |
@@ -110,2 +110,10 @@ var request = require('supertest') | ||
it('should respond with json and make a deep full-text search', function (done) { | ||
request(server) | ||
.get('/deep?q=1') | ||
.expect('Content-Type', /json/) | ||
.expect(db.deep) | ||
.expect(200, done) | ||
}) | ||
it('should return an empty array when nothing is matched', function (done) { | ||
@@ -112,0 +120,0 @@ request(server) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40400
966
255