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.16.1 to 0.16.2

26

lib/cli/utils/load.js

@@ -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

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