Socket
Socket
Sign inDemoInstall

json-server

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-server - npm Package Compare versions

Comparing version 0.8.8 to 0.8.9

11

CHANGELOG.md
# Change Log
## [0.8.9][2016-03-17]
* CLI can now read options from `json-server.json` if present
* CLI option `-c/--config` to point to a different configuration file
## [0.8.8][2016-02-13]
### Fixed
* Fix #233
## [0.8.7][2016-01-22]

@@ -4,0 +15,0 @@

6

package.json
{
"name": "json-server",
"version": "0.8.8",
"version": "0.8.9",
"description": "Serves JSON files through REST routes.",

@@ -29,6 +29,6 @@ "main": "./src/server/index.js",

"update-notifier": "^0.5.0",
"yargs": "^3.10.0"
"yargs": "^4.2.0"
},
"devDependencies": {
"husky": "^0.6.1",
"husky": "^0.11.4",
"mocha": "^2.2.4",

@@ -35,0 +35,0 @@ "rimraf": "^2.4.1",

@@ -40,3 +40,7 @@ # 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)

Also, if you make POST, PUT, PATCH or DELETE requests, changes will be automatically and safely saved to `db.json` using [lowdb](https://github.com/typicode/lowdb).
Also when doing requests, its good to know that
- If you make POST, PUT, PATCH or DELETE requests, changes will be automatically and safely saved to `db.json` using [lowdb](https://github.com/typicode/lowdb).
- Your request body JSON should be object enclosed, just like the GET output. (for example `{"name": "Foobar"}`)
- Id values are not mutable. Any `id` value in the body of your PUT or PATCH request wil be ignored. Only a value set in a POST request wil be respected, but only if not already taken.
- A POST, PUT or PATCH request should include a `Content-Type: application/json` header to use the JSON in the request body. Otherwise it wil result in a 200 OK but without changes being made to the data.

@@ -184,2 +188,10 @@ ## Install

### Alternative port
You can start JSON Server on other ports with the `--port` flag:
```bash
$ json-server --watch db.json --port 3004
```
### Access from anywhere

@@ -245,2 +257,37 @@

### CLI usage
```
json-server [options] <source>
Options:
--config, -c Path to config file [default: "json-server.json"]
--port, -p Set port [default: 3000]
--host, -H Set host [default: "0.0.0.0"]
--watch, -w Watch file(s) [boolean]
--routes, -r Path to routes file
--static, -s Set static files directory
--read-only, --ro Allow only GET requests [boolean]
--no-cors, --nc Disable Cross-Origin Resource Sharing [boolean]
--snapshots, -S Set snapshots directory [default: "."]
--delay, -d Add delay to responses (ms)
--id, -i Set database id property (e.g. _id) [default: "id"]
--quiet, -q Suppress log messages from output [boolean]
--help, -h Show help [boolean]
--version, -v Show version number [boolean]
Examples:
bin db.json
bin file.js
bin http://example.com/db.json
```
You can also set options in a `json-server.json` configuration file.
```json
{
"port": 3000
}
```
### Module

@@ -247,0 +294,0 @@

@@ -11,2 +11,3 @@ var updateNotifier = require('update-notifier')

var argv = yargs
.config('config')
.usage('$0 [options] <source>')

@@ -30,3 +31,3 @@ .options({

alias: 'r',
description: 'Load routes file'
description: 'Path to routes file'
},

@@ -62,2 +63,7 @@ static: {

description: 'Suppress log messages from output'
},
config: {
alias: 'c',
description: 'Path to config file',
default: 'json-server.json'
}

@@ -64,0 +70,0 @@ })

@@ -19,3 +19,9 @@ var path = require('path')

delete require.cache[filename]
data = require(filename)()
var dataFn = require(filename)
if (typeof dataFn !== 'function') {
throw new Error('The database is a JavaScript file but the export is not a function.')
}
data = dataFn()
cb(null, data)

@@ -22,0 +28,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc