json-server
Advanced tools
Comparing version 0.16.1 to 0.16.2
@@ -7,4 +7,6 @@ "use strict"; | ||
const request = require('request'); | ||
const http = require('http'); | ||
const https = require('https'); | ||
const low = require('lowdb'); | ||
@@ -48,10 +50,16 @@ | ||
} else if (is.URL(source)) { | ||
// Load remote data | ||
const opts = { | ||
url: source, | ||
json: true | ||
}; | ||
request(opts, (err, response) => { | ||
if (err) return reject(err); | ||
resolve(low(new Memory()).setState(response.body)); | ||
// Normalize the source into a URL object. | ||
const sourceUrl = new URL(source); // Pick the client based on the protocol scheme | ||
const client = sourceUrl.protocol === 'https:' ? https : http; | ||
client.get(sourceUrl, res => { | ||
let dbData = ''; | ||
res.on('data', data => { | ||
dbData += data; | ||
}); | ||
res.on('end', () => { | ||
resolve(low(new Memory()).setState(JSON.parse(dbData))); | ||
}); | ||
}).on('error', error => { | ||
return reject(error); | ||
}); | ||
@@ -58,0 +66,0 @@ } else if (is.JS(source)) { |
{ | ||
"name": "json-server", | ||
"version": "0.16.1", | ||
"version": "0.16.2", | ||
"description": "Get a full fake REST API with zero coding in less than 30 seconds", | ||
@@ -35,3 +35,2 @@ "main": "./lib/server/index.js", | ||
"pluralize": "^8.0.0", | ||
"request": "^2.88.2", | ||
"server-destroy": "^1.0.1", | ||
@@ -38,0 +37,0 @@ "update-notifier": "^4.0.0", |
@@ -126,3 +126,3 @@ # 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) | ||
- Id values are not mutable. Any `id` value in the body of your PUT or PATCH request will be ignored. Only a value set in a POST request will 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 will result in a 200 OK but without changes being made to the data. | ||
- A POST, PUT or PATCH request should include a `Content-Type: application/json` header to use the JSON in the request body. Otherwise it will return a 2XX status code, but without changes being made to the data. | ||
@@ -595,3 +595,2 @@ ## Routes | ||
* [Node Module Of The Week - json-server](http://nmotw.in/json-server/) | ||
* [Mock up your REST API with JSON Server](http://www.betterpixels.co.uk/projects/2015/05/09/mock-up-your-rest-api-with-json-server/) | ||
* [ng-admin: Add an AngularJS admin GUI to any RESTful API](http://marmelab.com/blog/2014/09/15/easy-backend-for-your-restful-api.html) | ||
@@ -598,0 +597,0 @@ * [Fast prototyping using Restangular and Json-server](https://glebbahmutov.com/blog/fast-prototyping-restangular-and-json-server/) |
Sorry, the diff of this file is not supported yet
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
Network access
Supply chain riskThis module accesses the network.
Found 2 instances 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
20
66567
37
1122
613
2
- Removedrequest@^2.88.2
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)