json-server 0.17.0 → 0.17.2

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
@@ -11,7 +11,7 @@ Created with <3 for front-end developers who need a quick back-end for prototypi
11
11
  See also:
12
12
  * :dog: [husky - Git hooks made easy](https://github.com/typicode/husky)
13
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
+ * [xv - a beautifully simple and capable test runner](https://github.com/typicode/xv)
15
15
 
16
16
  <p>&nbsp;</p>
17
17
 
@@ -36,16 +36,16 @@ See also:
36
36
  <p>&nbsp;</p>
37
37
 
38
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">
39
+ <a href="https://megafamous.com/buy-instagram-followers" target="_blank">
40
+ <img src="https://jsonplaceholder.typicode.com/megafamous.png" height="70px">
41
41
  </a>
42
42
  </p>
43
43
 
44
44
  <p>&nbsp;</p>
45
45
 
46
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">
47
+ <a href="http://asocks.com/c/TFw5bz" target="_blank">
48
+ <img src="https://jsonplaceholder.typicode.com/asocks.png" height="70px">
49
49
  </a>
50
50
  </p>
51
51
 
@@ -53,11 +53,15 @@ See also:
53
53
 
54
54
  <p>&nbsp;</p>
55
55
 
56
- ---
56
+ <h2 align="center">Silver sponsors 🥈</h2>
57
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/)
58
+ <p>&nbsp;</p>
59
59
 
60
- ---
60
+ <p align="center">
61
+ <a href="https://cased.com" target="_blank">
62
+ <img src="https://user-images.githubusercontent.com/5502029/194441951-b7dca49d-efd6-496d-900b-288004717f11.png" height="55px">
63
+ </a>
64
+ </p>
61
65
 
62
66
  <p>&nbsp;</p>
63
67
 
@@ -352,7 +356,7 @@ module.exports = () => {
352
356
  $ json-server index.js
353
357
  ```
354
358
 
355
- __Tip__ use modules like [Faker](https://github.com/Marak/faker.js), [Casual](https://github.com/boo1ean/casual), [Chance](https://github.com/victorquinn/chancejs) or [JSON Schema Faker](https://github.com/json-schema-faker/json-schema-faker).
359
+ __Tip__ use modules like [Faker](https://github.com/faker-js/faker), [Casual](https://github.com/boo1ean/casual), [Chance](https://github.com/victorquinn/chancejs) or [JSON Schema Faker](https://github.com/json-schema-faker/json-schema-faker).
356
360
 
357
361
  ### HTTPS
358
362
 
@@ -482,6 +486,8 @@ const router = jsonServer.router(path.join(__dirname, 'db.json'))
482
486
 
483
487
  For an in-memory database, simply pass an object to `jsonServer.router()`.
484
488
 
489
+ To add custom options (eg. `foreginKeySuffix`) pass in an object as the second argument to `jsonServer.router('db.json', { foreginKeySuffix: '_id' })`.
490
+
485
491
  Please note also that `jsonServer.router()` can be used in existing Express projects.
486
492
 
487
493
  #### Custom routes example
@@ -603,10 +609,12 @@ Returns middlewares used by JSON Server.
603
609
  * `noCors` disable CORS (default: false)
604
610
  * `readOnly` accept only GET requests (default: false)
605
611
 
606
- __`jsonServer.router([path|object])`__
612
+ __`jsonServer.router([path|object], [options])`__
607
613
 
608
614
  Returns JSON Server router.
609
615
 
616
+ * options (see [CLI usage](#cli-usage))
617
+
610
618
  ### Deployment
611
619
 
612
620
  You can deploy JSON Server. For example, [JSONPlaceholder](http://jsonplaceholder.typicode.com) is an online fake API powered by JSON Server and running on Heroku.
package/lib/cli/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- const updateNotifier = require('update-notifier');
4
-
5
3
  const yargs = require('yargs');
6
4
 
7
5
  const run = require('./run');
@@ -9,10 +7,6 @@ const run = require('./run');
9
7
  const pkg = require('../../package.json');
10
8
 
11
9
  module.exports = function () {
12
- updateNotifier({
13
- pkg
14
- }).notify();
15
-
16
10
  const argv = yargs.config('config').usage('$0 [options] <source>').options({
17
11
  port: {
18
12
  alias: 'p',
@@ -11,7 +11,7 @@ function FILE(s) {
11
11
  }
12
12
 
13
13
  function JS(s) {
14
- return !URL(s) && /\.js$/.test(s);
14
+ return !URL(s) && /\.c?js$/.test(s);
15
15
  }
16
16
 
17
17
  function URL(s) {
@@ -13,6 +13,7 @@ module.exports = obj => {
13
13
  if (_.isPlainObject(obj)) {
14
14
  Object.keys(obj).forEach(validateKey);
15
15
  } else {
16
- throw new Error(`Data must be an object. Found ${typeof obj}.` + 'See https://github.com/typicode/json-server for example.');
16
+ throw new Error(`Data must be an object. Found ${Array.isArray(obj) ? 'array' : typeof obj}
17
+ 'See https://github.com/typicode/json-server for example.`);
17
18
  }
18
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-server",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
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",
@@ -38,7 +38,7 @@
38
38
  "please-upgrade-node": "^3.2.0",
39
39
  "pluralize": "^8.0.0",
40
40
  "server-destroy": "^1.0.1",
41
- "update-notifier": "^5.1.0",
41
+ "standard": "^17.0.0",
42
42
  "yargs": "^17.0.1"
43
43
  },
44
44
  "devDependencies": {
package/public/script.js CHANGED
@@ -15,7 +15,7 @@ function ResourceList({ db }) {
15
15
  ResourceItem({
16
16
  name,
17
17
  length: Array.isArray(db[name]) && db[name].length,
18
- })
18
+ }),
19
19
  )
20
20
  .join('')}
21
21
  </ul>
@@ -40,7 +40,7 @@ window
40
40
  .then((response) => response.json())
41
41
  .then(
42
42
  (db) =>
43
- (document.getElementById('resources').innerHTML = ResourcesBlock({ db }))
43
+ (document.getElementById('resources').innerHTML = ResourcesBlock({ db })),
44
44
  )
45
45
 
46
46
  function CustomRoutesBlock({ customRoutes }) {
@@ -56,7 +56,7 @@ function CustomRoutesBlock({ customRoutes }) {
56
56
  `<tr>
57
57
  <td>${rule}</td>
58
58
  <td><code>⇢</code> ${customRoutes[rule]}</td>
59
- </tr>`
59
+ </tr>`,
60
60
  )
61
61
  .join('')}
62
62
  </table>
@@ -72,5 +72,5 @@ window
72
72
  (customRoutes) =>
73
73
  (document.getElementById('custom-routes').innerHTML = CustomRoutesBlock({
74
74
  customRoutes,
75
- }))
75
+ })),
76
76
  )