Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonapi-server

Package Overview
Dependencies
Maintainers
5
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonapi-server - npm Package Compare versions

Comparing version 1.15.0 to 1.15.1

3

CHANGELOG.md

@@ -0,1 +1,4 @@

- 2016-07-05 - v1.15.1
- 2016-07-05 - Fixed bug when deleting singular relationships via deep urls
- 2016-07-05 - Added warning messages to test suite to warn when handlers don't filter
- 2016-06-28 - v1.15.0

@@ -2,0 +5,0 @@ - 2016-06-28 - Scrap sub-millisecond accuracy on metrics

6

lib/routes/removeRelation.js

@@ -38,2 +38,4 @@ /* @flow weak */

var isMany = resourceConfig.attributes[request.params.relation]._settings.__many;
var isOne = resourceConfig.attributes[request.params.relation]._settings.__one;
var relationType = isMany || isOne;
var theirs = request.params.data;

@@ -44,3 +46,3 @@ if (!(theirs instanceof Array)) {

var keys = theirResource[request.params.relation].map(function(j) {
var keys = [].concat(theirResource[request.params.relation]).map(function(j) {
return j.id;

@@ -50,3 +52,3 @@ });

for (var i = 0; i < theirs.length; i++) {
if (theirs[i].type !== request.params.relation) {
if (theirs[i].type !== relationType) {
return callback({

@@ -53,0 +55,0 @@ status: "403",

{
"name": "jsonapi-server",
"version": "1.15.0",
"version": "1.15.1",
"description": "A config driven NodeJS framework implementing json:api",

@@ -5,0 +5,0 @@ "keywords": [

@@ -132,3 +132,3 @@ "use strict";

method: "delete",
url: "http://localhost:16006/rest/articles/fa2a073f-8c64-4cbb-9158-b8f67a4ab9f5/relationships/tags",
url: "http://localhost:16006/rest/articles/fa2a073f-8c64-4cbb-9158-b8f67a4ab9f5/relationships/author",
headers: {

@@ -138,3 +138,3 @@ "Content-Type": "application/vnd.api+json"

body: JSON.stringify({
"data": { "type": "tags", "id": "6ec62f6d-9f82-40c5-b4f4-279ed1765492" }
"data": { "type": "people", "id": "ad3aa89e-9c5b-4ac9-a652-6670f9f27587" }
})

@@ -153,3 +153,3 @@ };

it("new resource has changed", function(done) {
var url = "http://localhost:16006/rest/articles/fa2a073f-8c64-4cbb-9158-b8f67a4ab9f5/relationships/tags";
var url = "http://localhost:16006/rest/articles/fa2a073f-8c64-4cbb-9158-b8f67a4ab9f5/relationships/author";
helpers.request({

@@ -163,3 +163,3 @@ method: "GET",

assert.equal(res.statusCode, "200", "Expecting 200");
assert.deepEqual(json.data, [ ]);
assert.deepEqual(json.data, null);

@@ -169,2 +169,23 @@ done();

});
it("restore relation", function(done) {
var data = {
method: "post",
url: "http://localhost:16006/rest/articles/fa2a073f-8c64-4cbb-9158-b8f67a4ab9f5/relationships/author",
headers: {
"Content-Type": "application/vnd.api+json"
},
body: JSON.stringify({
"data": { "type": "people", "id": "ad3aa89e-9c5b-4ac9-a652-6670f9f27587" }
})
};
helpers.request(data, function(err, res, json) {
assert.equal(err, null);
json = helpers.validateJson(json);
assert.equal(res.statusCode, "201", "Expecting 201");
done();
});
});
});

@@ -171,0 +192,0 @@ });

@@ -59,5 +59,29 @@ "use strict";

assert.equal(typeof json.links.self, "string", "Response should have a \"self\" link");
testHelpers.validatePagination(json);
return json;
};
testHelpers.validatePagination = function(json) {
if (!json.meta.page) return;
if (!(json.data instanceof Array)) return;
var page = json.meta.page;
var expectedCount = null;
if ((page.offset + page.limit) > page.total) {
expectedCount = page.total - page.offset;
} else if (page.limit < page.total) {
expectedCount = page.limit;
} else {
expectedCount = page.total;
}
if (expectedCount !== json.data.length) {
console.warn("!!!!!!!!!!!!");
console.warn(json.links.self);
console.warn("WARNING: Pagination count doesn't match resource count.");
console.warn("This usually indicates the resource hanlder is not filtering correctly!");
console.warn("!!!!!!!!!!!!");
}
};
testHelpers.validateRelationship = function(relationship) {

@@ -64,0 +88,0 @@ assert.ok(relationship.meta instanceof Object, "Relationships should have a meta block");

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