json-server 0.16.3 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # JSON Server [![](https://travis-ci.org/typicode/json-server.svg?branch=master)](https://travis-ci.org/typicode/json-server) [![](https://badge.fury.io/js/json-server.svg)](http://badge.fury.io/js/json-server)
1
+ # JSON Server [![Node.js CI](https://github.com/typicode/json-server/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/typicode/json-server/actions/workflows/node.js.yml)
2
2
 
3
3
  Get a full fake REST API with __zero coding__ in __less than 30 seconds__ (seriously)
4
4
 
@@ -10,7 +10,8 @@ Created with <3 for front-end developers who need a quick back-end for prototypi
10
10
 
11
11
  See also:
12
12
  * :dog: [husky - Git hooks made easy](https://github.com/typicode/husky)
13
- * :hotel: [hotel - developer tool with local .localhost domain and https out of the box](https://github.com/typicode/hotel)
13
+ * :owl: [lowdb - local JSON database](https://github.com/typicode/lowdb)
14
+ * :x: :heavy_check_mark: [xv - the most minimalist test runner](https://github.com/typicode/xv)
14
15
 
15
16
  <p>&nbsp;</p>
16
17
 
@@ -24,16 +25,50 @@ See also:
24
25
  </a>
25
26
  </p>
26
27
 
28
+ <p>&nbsp;</p>
29
+
27
30
  <p align="center">
28
31
  <a href="https://mockend.com/" target="_blank">
29
- <img src="https://i.imgur.com/Gwaqv3q.png" height="70px">
32
+ <img src="https://jsonplaceholder.typicode.com/mockend.svg" height="70px">
30
33
  </a>
31
34
  </p>
32
35
 
33
36
  <p>&nbsp;</p>
34
37
 
38
+ <p align="center">
39
+ <a href="https://www.deta.sh/?ref=typicode" target="_blank">
40
+ <img src="https://jsonplaceholder.typicode.com/deta.svg" height="70px">
41
+ </a>
42
+ </p>
43
+
44
+ <p>&nbsp;</p>
45
+
46
+ <p align="center">
47
+ <a href="https://uibakery.io/?utm_source=json_server&utm_medium=sponsor&utm_campaign=github" target="_blank">
48
+ <img src="https://jsonplaceholder.typicode.com/ui_bakery.jpg" height="70px">
49
+ </a>
50
+ </p>
51
+
52
+ <p>&nbsp;</p>
53
+
54
+ <p>&nbsp;</p>
55
+
56
+ ---
57
+
58
+ From generating an API to importing a CSV into postgres, Retool’s range of 20+ developer utilities is a go-to resource when building apps. [Check it out now](https://retool.com/utilities/)
59
+
60
+ ---
61
+
62
+ <p>&nbsp;</p>
63
+
64
+ <p>&nbsp;</p>
65
+
35
66
  [Become a sponsor and have your company logo here](https://github.com/users/typicode/sponsorship)
36
67
 
68
+ ## Sponsor
69
+
70
+ __Please help me build OSS__ 👉 [GitHub Sponsors](https://github.com/sponsors/typicode) :heart:
71
+
37
72
  ## Table of contents
38
73
 
39
74
  <!-- toc -->
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
6
 
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-server",
3
- "version": "0.16.3",
3
+ "version": "0.17.0",
4
4
  "description": "Get a full fake REST API with zero coding in less than 30 seconds",
5
5
  "main": "./lib/server/index.js",
6
6
  "bin": "./lib/cli/bin.js",
@@ -9,7 +9,7 @@
9
9
  "public"
10
10
  ],
11
11
  "scripts": {
12
- "_postinstall": "husky install",
12
+ "prepare": "husky install",
13
13
  "test": "npm run build && cross-env NODE_ENV=test jest && npm run lint",
14
14
  "start": "babel-node -- src/cli/bin db.json -r routes.json",
15
15
  "lint": "eslint . --ignore-path .gitignore",
@@ -17,30 +17,29 @@
17
17
  "build": "babel src -d lib",
18
18
  "toc": "markdown-toc -i README.md",
19
19
  "postversion": "git push && git push --tags",
20
- "prepublish": "npm test && npm run build && pkg-ok && pinst --disable",
21
- "postpublish": "pinst --enable"
20
+ "prepublish": "npm test && npm run build"
22
21
  },
23
22
  "dependencies": {
24
23
  "body-parser": "^1.19.0",
25
- "chalk": "^4.1.0",
24
+ "chalk": "^4.1.2",
26
25
  "compression": "^1.7.4",
27
26
  "connect-pause": "^0.1.1",
28
27
  "cors": "^2.8.5",
29
28
  "errorhandler": "^1.5.1",
30
29
  "express": "^4.17.1",
31
- "express-urlrewrite": "^1.3.0",
30
+ "express-urlrewrite": "^1.4.0",
32
31
  "json-parse-helpfulerror": "^1.0.3",
33
- "lodash": "^4.17.20",
34
- "lodash-id": "^0.14.0",
32
+ "lodash": "^4.17.21",
33
+ "lodash-id": "^0.14.1",
35
34
  "lowdb": "^1.0.0",
36
35
  "method-override": "^3.0.0",
37
36
  "morgan": "^1.10.0",
38
- "nanoid": "^3.1.16",
37
+ "nanoid": "^3.1.23",
39
38
  "please-upgrade-node": "^3.2.0",
40
39
  "pluralize": "^8.0.0",
41
40
  "server-destroy": "^1.0.1",
42
- "update-notifier": "^5.0.1",
43
- "yargs": "^16.1.1"
41
+ "update-notifier": "^5.1.0",
42
+ "yargs": "^17.0.1"
44
43
  },
45
44
  "devDependencies": {
46
45
  "@babel/cli": "^7.12.1",
@@ -49,22 +48,20 @@
49
48
  "@babel/preset-env": "^7.12.1",
50
49
  "cross-env": "^7.0.2",
51
50
  "eslint": "^7.13.0",
52
- "eslint-config-prettier": "^6.15.0",
51
+ "eslint-config-prettier": "^8.3.0",
53
52
  "eslint-config-standard": "^16.0.1",
54
53
  "eslint-plugin-import": "^2.22.1",
55
54
  "eslint-plugin-node": "^11.1.0",
56
55
  "eslint-plugin-prettier": "^3.1.4",
57
56
  "eslint-plugin-promise": "^4.2.1",
58
57
  "eslint-plugin-standard": "^4.1.0",
59
- "husky": "^5.0.0-beta.0",
58
+ "husky": "^6.0.0",
60
59
  "jest": "^26.6.3",
61
60
  "markdown-toc": "^1.2.0",
62
61
  "mkdirp": "^1.0.4",
63
62
  "npm-run-all": "^4.1.5",
64
63
  "os-tmpdir": "^2.0.0",
65
- "pinst": "^2.1.1",
66
- "pkg-ok": "^2.3.1",
67
- "prettier": "^2.1.2",
64
+ "prettier": "^2.3.2",
68
65
  "rimraf": "^3.0.2",
69
66
  "server-ready": "^0.3.1",
70
67
  "supertest": "^6.0.1",
@@ -97,7 +94,7 @@
97
94
  },
98
95
  "homepage": "https://github.com/typicode/json-server",
99
96
  "engines": {
100
- "node": ">=10"
97
+ "node": ">=12"
101
98
  },
102
99
  "jest": {
103
100
  "testURL": "http://localhost/"
package/CHANGELOG.md DELETED
@@ -1,303 +0,0 @@
1
- # Change Log
2
-
3
- Changes for 0.15.1+ can now be found in https://github.com/typicode/json-server/releases
4
-
5
- ## 0.15.0 - 2019-05-21
6
-
7
- * __Breaking__ Require Node 8
8
- * Upgrade dependencies
9
- * Reduce package size
10
-
11
- ## 0.14.2 - 2018-12-26
12
-
13
- * Fix `db.getState is not a function`
14
-
15
- ## 0.14.1 - 2018-12-25
16
-
17
- * Show error message if port is already used
18
- * Upgrade to [lowdb](https://github.com/typicode/lowdb) `1.0`
19
-
20
- ## 0.14.0 - 2018-06-09
21
-
22
- * Listen to `localhost` by default, instead of `0.0.0.0`
23
-
24
- ## 0.13.0 - 2018-05-30
25
-
26
- * Bundle all index page assets so that you access it without network connection
27
- * Drop Node 4 support
28
-
29
- ## 0.12.2 - 2018-04-26
30
-
31
- * Add `_delay` query parameter
32
- * Upgrade `please-upgrade-node` dependency
33
-
34
- ## 0.12.1 - 2017-11-02
35
-
36
- * Disable logging for static content requests
37
- * Remove bad `console.log`
38
- * Update `dependencies`
39
- * Use [`nanoid`](https://github.com/ai/nanoid)
40
-
41
- ## 0.12.0 - 2017-08-02
42
-
43
- Re-include `body-parser` in `jsonServer.defaults()`
44
-
45
- If you're using JSON Server in an Express server and experience issues, you can disable it by passing
46
-
47
- ```js
48
- jsonServer.defaults({ bodyParser: false })
49
- ```
50
-
51
- ## 0.11.2 - 2017-07-10
52
-
53
- Fix `engines` field in `package.json`
54
-
55
- ## 0.11.1 - 2017-07-10
56
-
57
- Add [please-upgrade-node](https://github.com/typicode/please-upgrade-node)
58
-
59
- ## 0.11.0 - 2017-07-05
60
-
61
- Switch to [express-urlrewrite](https://github.com/kapouer/express-urlrewrite) to support rewriting query parameters (e.g. `/articles?id=1 # → /posts/1`)
62
-
63
- If you're rewriting default routes, you'll need to update your `routes.json` file
64
- (see [add custom routes](https://github.com/typicode/json-server#add-custom-routes) for updated doc).
65
-
66
- ## 0.10.3 - 2017-06-28
67
-
68
- * Fix `line-break` error in CLI
69
-
70
- ## 0.10.2 - 2017-06-28
71
-
72
- * Add `--foreignKeySuffix` option (e.g. snake case `post_id`) [#556](https://github.com/typicode/json-server/pull/556) [#570](https://github.com/typicode/json-server/pull/570)
73
-
74
- ## 0.10.1 - 2017-05-16
75
-
76
- * Multiple fields sorting `GET /posts?_sort=user,views&_order=desc,asc`
77
-
78
- ## 0.10.0 - 2017-04-26
79
-
80
- * __Drop Node `v0.12` support__
81
- * Prevent `TypeError` when a filter is applied on a `null` value [#510](https://github.com/typicode/json-server/issues/510)
82
-
83
- ## 0.9.6 - 2017-03-08
84
-
85
- * Update index page
86
- * Improve performances ([lowdb](https://github.com/typicode/lowdb) `v0.15`)
87
- * Add `Location` header to newly created resources [#473](https://github.com/typicode/json-server/pull/473)
88
-
89
- ## 0.9.5 - 2017-02-11
90
-
91
- * Display custom routes on homepage
92
- * Fix duplicate query params error [#352](https://github.com/typicode/json-server/issues/352)
93
-
94
- ## 0.9.4 - 2016-12-08
95
-
96
- * Improve rewriter [#431](https://github.com/typicode/json-server/issues/431)
97
- * Improve watch mode [#427](https://github.com/typicode/json-server/pull/427)
98
-
99
- ## 0.9.3 - 2016-12-07
100
-
101
- * Fix [#396](https://github.com/typicode/json-server/issues/396) PUT/PATCH saves the updated item with an id that has been converted to string
102
-
103
- ## 0.9.2 - 2016-11-29
104
-
105
- * Fix [#221](https://github.com/typicode/json-server/issues/221) `nohup` support
106
- * Fix [#420](https://github.com/typicode/json-server/issues/420) TypeError when watching `db.json`
107
-
108
- ## 0.9.1 - 2016-11-21
109
-
110
- * Fix
111
- * [#412](https://github.com/typicode/json-server/issues/412)
112
- * [#451](https://github.com/typicode/json-server/issues/411)
113
-
114
- ## 0.9.0 - 2016-11-11
115
-
116
- * Shorter `uuid`
117
- * No automatic conversion of strings to boolean or integer
118
- * Create a default `db.json` file if it doesn't exist
119
- * Fix
120
- * [#361](https://github.com/typicode/json-server/issues/361)
121
- * [#363](https://github.com/typicode/json-server/issues/363) [#365](https://github.com/typicode/json-server/issues/365)
122
- * [#374](https://github.com/typicode/json-server/issues/374)
123
- * [#383](https://github.com/typicode/json-server/issues/383)
124
- * Updated dependencies and codebase to ES6
125
-
126
- ## 0.8.23 - 2016-11-03
127
-
128
- * Fix `Links` header
129
-
130
- ## 0.8.22 - 2016-10-04
131
-
132
- * Fix `Links` header issue when using `_page`
133
- * Add query params support to the route rewriter
134
-
135
- ## 0.8.21 - 2016-09-13
136
-
137
- * Fix bodyParser issue when using custom routes
138
-
139
- ## 0.8.20 - 2016-09-12
140
-
141
- * Fix [#355](https://github.com/typicode/json-server/issues/355)
142
- * Add `_page` support
143
-
144
- ## 0.8.19 - 2016-08-18
145
-
146
- * Fix [#341](https://github.com/typicode/json-server/issues/341)
147
-
148
- ## 0.8.18 - 2016-08-17
149
-
150
- * Add CLI option `--middlewares` and support them in `json-server.json` config file
151
-
152
- ## 0.8.17 - 2016-07-25
153
-
154
- * Fix snapshot creation for JS files (ex: `json-server generator.js`)
155
-
156
- ## 0.8.16 - 2016-07-11
157
-
158
- * Support `x-www-form-urlencoded`
159
-
160
- ## 0.8.15 - 2016-07-03
161
-
162
- * Bug fix: `--watch` option on OS X
163
-
164
- ## 0.8.14 - 2016-05-15
165
-
166
- * Bug fix: data wasn't written to file in `v0.8.13` and `v0.8.12`
167
-
168
- ## 0.8.13 - 2016-05-12
169
-
170
- * Make `_like` operator case insensitive
171
-
172
- ## 0.8.12 - 2016-05-08
173
-
174
- * Minor bug fix
175
-
176
- ## 0.8.11 - 2016-05-08
177
-
178
- * Support sort by nested field (e.g. `_sort=author.name`)
179
- * Fix `graceful-fs` warning
180
-
181
- ## 0.8.10 - 2016-04-18
182
-
183
- * CLI option `-ng/--no-gzip` to disable `gzip` compression
184
-
185
- ## 0.8.9 - 2016-03-17
186
-
187
- * CLI can now read options from `json-server.json` if present
188
- * CLI option `-c/--config` to point to a different configuration file
189
-
190
- ## 0.8.8 - 2016-02-13
191
-
192
- ### Fixed
193
-
194
- * Fix #233
195
-
196
- ## 0.8.7 - 2016-01-22
197
-
198
- ### Added
199
-
200
- * `gzip` compression to improve performances
201
- * CLI option `-nc/--no-cors` to disable CORS
202
-
203
- ## 0.8.6 - 2016-01-07
204
-
205
- ### Added
206
-
207
- * CLI option `-ro/--read-only` to allow only GET requests
208
-
209
- ## 0.8.5 - 2015-12-28
210
-
211
- ### Fixed
212
-
213
- * Fix #177
214
-
215
- ## 0.8.4 - 2015-12-13
216
-
217
- ### Added
218
-
219
- * Like operator `GET /posts?title_like=json` (accepts RegExp)
220
-
221
- ## 0.8.3 - 2015-11-25
222
-
223
- ### Added
224
-
225
- * CLI option `-q/--quiet`
226
- * Nested route `POST /posts/1/comments`
227
- * Not equal operator `GET /posts?id_ne=1`
228
-
229
- ## 0.8.2 - 2015-10-15
230
-
231
- ### Added
232
-
233
- * CLI option `-S/--snapshots` to set a custom snapshots directory.
234
-
235
- ### Fixed
236
-
237
- * Fix plural resources: `DELETE` should return `404` if resource doesn't exist.
238
-
239
- ## 0.8.1 - 2015-10-06
240
-
241
- ### Fixed
242
-
243
- * Fix plural resources: `PUT` should replace resource instead of updating properties.
244
- * Fix singular resources: `POST`, `PUT`, `PATCH` should not convert resource properties.
245
-
246
- ## 0.8.0 - 2015-09-21
247
-
248
- ### Changed
249
-
250
- * `jsonServer.defaults` is now a function and can take an object.
251
- If you're using the project as a module, you need to update your code:
252
-
253
- ```js
254
- // Before
255
- jsonServer.defaults
256
- // After
257
- jsonServer.defaults()
258
- jsonServer.defaults({ static: '/some/path'})
259
- ```
260
-
261
- * Automatically ignore unknown query parameters.
262
-
263
- ```bash
264
- # Before
265
- GET /posts?author=typicode&foo=bar # []
266
- # After
267
- GET /posts?author=typicode&foo=bar # [{...}, {...}]
268
- ```
269
-
270
- ### Added
271
-
272
- * CLI option for setting a custom static files directory.
273
-
274
- ```bash
275
- json-server --static some/path
276
- ```
277
-
278
- ## 0.7.28 - 2015-09-09
279
-
280
- ```bash
281
- # Support range
282
- GET /products?price_gte=50&price_lte=100
283
- ```
284
-
285
- ## 0.7.27 - 2015-09-02
286
-
287
- ### Added
288
-
289
- ```bash
290
- # Support OR
291
- GET /posts?id=1&id2
292
- GET /posts?category=javascript&category=html
293
- ```
294
-
295
- ## 0.7.26 - 2015-09-01
296
-
297
- ### Added
298
-
299
- ```bash
300
- # Support embed and expand in lists
301
- GET /posts?embed=comments
302
- GET /posts?expand=user
303
- ```