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

jsonapi-server

Package Overview
Dependencies
Maintainers
6
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 3.0.3 to 3.1.0

complexity/assets/css/morris.css

5

CHANGELOG.md

@@ -0,1 +1,6 @@

- 2017-09-14 - v3.1.0
- 2017-09-14 - Improved Swagger 2.0 configuration.
- 2017-09-14 - Correct sorting of date properties.
- 2017-09-14 - Fix bug when trying to detect arrays during Joi validation.
- 2017-09-14 - Fix bug for some requests with both `include` and `fields`.
- 2017-07-14 - v3.0.3

@@ -2,0 +7,0 @@ - 2017-07-14 - v3.0.2

2

documentation/foreign-relations.md

@@ -146,3 +146,3 @@ ### Foreign Key Relations

Our solution here is to add `meta` blocks to relationships to inform the consumer what kind of linage they are looking at, and to not provide foreign keys directly:
Our solution here is to add `meta` blocks to relationships to inform the consumer what kind of linkage they are looking at, and to not provide foreign keys directly:
```

@@ -149,0 +149,0 @@ relationships: {

@@ -16,2 +16,3 @@ 'use strict'

description: 'This is the API description block that shows up in the swagger.json',
termsOfService: 'http://example.com/termsOfService',
contact: {

@@ -25,2 +26,14 @@ name: 'API Contact',

url: 'http://opensource.org/licenses/MIT'
},
security: [
{
'APIKeyHeader': []
}
],
securityDefinitions: {
APIKeyHeader: {
type: 'apiKey',
in: 'header',
name: 'X-API-Auth'
}
}

@@ -27,0 +40,0 @@ },

@@ -80,3 +80,3 @@ 'use strict'

var oneRelationship = new graphQl.GraphQLInputObjectType({
const oneRelationship = new graphQl.GraphQLInputObjectType({
name: 'oneRelationship',

@@ -90,2 +90,2 @@ fields: {

})
var manyRelationship = new graphQl.GraphQLList(oneRelationship)
const manyRelationship = new graphQl.GraphQLList(oneRelationship)

@@ -28,3 +28,3 @@ 'use strict'

if (!(dataItems instanceof Array)) dataItems = [ dataItems ]
if (!(Array.isArray(dataItems))) dataItems = [ dataItems ]

@@ -63,3 +63,3 @@ let resourcesToFetch = dataItems.reduce((map, dataItem) => {

let data = json.data
if (!(data instanceof Array)) data = [ data ]
if (!(Array.isArray(data))) data = [ data ]
return done(null, data)

@@ -75,3 +75,3 @@ })

postProcess.fetchForeignKeys = (request, items, schema, callback) => {
if (!(items instanceof Array)) {
if (!(Array.isArray(items))) {
items = [ items ]

@@ -78,0 +78,0 @@ }

@@ -12,2 +12,3 @@ 'use strict'

const fields = {}
for (const resource in resourceList) {

@@ -23,5 +24,5 @@ if (!jsonApi._resources[resource]) {

var field = (`${resourceList[resource]}`).split(',')
fields[resource] = (`${resourceList[resource]}`).split(',')
for (const j of field) {
for (const j of fields[resource]) {
if (!jsonApi._resources[resource].attributes[j]) {

@@ -40,3 +41,3 @@ return callback({ // eslint-disable-line standard/no-callback-literal

Object.keys(dataItem.attributes).forEach(attribute => {
if (field.indexOf(attribute) === -1) {
if (fields[dataItem.type] && fields[dataItem.type].indexOf(attribute) === -1) {
delete dataItem.attributes[attribute]

@@ -43,0 +44,0 @@ }

@@ -14,3 +14,3 @@ 'use strict'

if (response.data instanceof Array) {
if (Array.isArray(response.data)) {
for (let j = 0; j < response.data.length; j++) {

@@ -91,3 +91,3 @@ if (!filter._filterKeepObject(response.data[j], filters)) {

if (!(data instanceof Array)) data = [ data ]
if (!(Array.isArray(data))) data = [ data ]
data = data.map(relation => relation.id)

@@ -94,0 +94,0 @@

@@ -23,3 +23,3 @@ 'use strict'

let dataItems = response.data
if (!(dataItems instanceof Array)) dataItems = [ dataItems ]
if (!(Array.isArray(dataItems))) dataItems = [ dataItems ]
includeTree._dataItems = dataItems

@@ -76,3 +76,3 @@

if (filter instanceof Array) {
if (Array.isArray(filter)) {
filter = filter.filter(i => i instanceof Object).pop()

@@ -88,5 +88,5 @@ }

if (!((filter instanceof Array) && (filter.length === 0))) {
if (!((Array.isArray(filter)) && (filter.length === 0))) {
for (const i in filter) {
if (!(typeof filter[i] === 'string' || (filter[i] instanceof Array))) continue
if (!(typeof filter[i] === 'string' || (Array.isArray(filter[i])))) continue
node[first]._filter.push(`filter[${i}]=${filter[i]}`)

@@ -140,3 +140,3 @@ }

if (!relationItems) return
if (!(relationItems instanceof Array)) relationItems = [ relationItems ]
if (!(Array.isArray(relationItems))) relationItems = [ relationItems ]
relationItems.forEach(relationItem => {

@@ -203,3 +203,3 @@ const key = `${relationItem.type}~~${relation}~~${relation}`

if (!data) return done()
if (!(data instanceof Array)) data = [ data ]
if (!(Array.isArray(data))) data = [ data ]
includeTree[parts[2]]._dataItems = includeTree[parts[2]]._dataItems.concat(data)

@@ -206,0 +206,0 @@ return done()

@@ -23,6 +23,7 @@ 'use strict'

// todo: consider using a stable sort algerith (e.g. lodash.sortBy)
response.data = response.data.sort((a, b) => {
if (typeof a.attributes[attribute] === 'string') {
return a.attributes[attribute].localeCompare(b.attributes[attribute]) * ascending
} else if (typeof a.attributes[attribute] === 'number') {
} else if (typeof a.attributes[attribute] === 'number' || a.attributes[attribute] instanceof Date) {
return (a.attributes[attribute] - b.attributes[attribute]) * ascending

@@ -29,0 +30,0 @@ } else {

@@ -21,3 +21,3 @@ 'use strict'

responseHelper._enforceSchemaOnArray = (items, schema, callback) => {
if (!(items instanceof Array)) {
if (!(Array.isArray(items))) {
items = [ items ]

@@ -107,3 +107,3 @@ }

if (linkItems) {
if (!(linkItems instanceof Array)) linkItems = [ linkItems ]
if (!(Array.isArray(linkItems))) linkItems = [ linkItems ]
linkItems.forEach(linkItem => {

@@ -157,3 +157,3 @@ link.data.push({

debug.errors(request.route.verb, request.route.combined, JSON.stringify(err))
if (!(err instanceof Array)) err = [ err ]
if (!(Array.isArray(err))) err = [ err ]

@@ -160,0 +160,0 @@ const errorResponse = {

@@ -39,3 +39,3 @@ 'use strict'

let theirs = request.params.data
if (!(theirs instanceof Array)) {
if (!(Array.isArray(theirs))) {
theirs = [ theirs ]

@@ -42,0 +42,0 @@ }

@@ -34,2 +34,3 @@ 'use strict'

description: swaggerConfig.description,
termsOfService: swaggerConfig.termsOfService,
contact: {

@@ -92,4 +93,6 @@ name: (swaggerConfig.contact || { }).name,

paths: { },
definitions: { }
definitions: { },
security: swaggerConfig.security || [ ],
securityDefinitions: swaggerConfig.securityDefinitions || { }
}
}

@@ -94,2 +94,4 @@ 'use strict'

swaggerPaths._addDeepPaths = (paths, resourceName, resourceConfig, relationName, relation) => {
const relationType = resourceConfig.attributes[relationName]._settings.__many ? 'many' : 'one'
if (resourceConfig.handlers.find) {

@@ -99,2 +101,3 @@ paths[`/${resourceName}/{id}/${relationName}`] = {

handler: 'find',
description: `Get the ${relationName} instance${relationType === 'many' ? 's' : ''} of a specific instance of ${resourceName}`,
resourceName: relation,

@@ -106,8 +109,9 @@ hasPathId: true

const relationType = resourceConfig.attributes[relationName]._settings.__many ? 'many' : 'one'
const relationPaths = { }
paths[`/${resourceName}/{id}/relationships/${relationName}`] = relationPaths
const description = `the ${relationName} relationship of a specific instance of ${resourceName}`
if (resourceConfig.handlers.find) {
relationPaths.get = swaggerPaths._getPathOperationObject({
description: `Get ${description}`,
handler: 'find',

@@ -123,2 +127,3 @@ resourceName: relation,

relationPaths.post = swaggerPaths._getPathOperationObject({
description: `Create ${description}`,
handler: 'create',

@@ -134,2 +139,3 @@ resourceName: relation,

relationPaths.patch = swaggerPaths._getPathOperationObject({
description: `Update ${description}`,
handler: 'update',

@@ -145,2 +151,3 @@ resourceName: relation,

relationPaths.delete = swaggerPaths._getPathOperationObject({
description: `Delete ${description}`,
handler: 'delete',

@@ -147,0 +154,0 @@ resourceName: relation,

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

@@ -23,6 +23,6 @@ "keywords": [

"async": "2.5.0",
"body-parser": "1.17.2",
"body-parser": "1.18.1",
"cookie-parser": "1.4.3",
"debug": "2.6.8",
"express": "4.15.3",
"debug": "3.0.1",
"express": "4.15.4",
"express-graphql": "0.5.4",

@@ -37,3 +37,3 @@ "graphql": "0.7.2",

"lodash.uniqby": "4.7.0",
"qs": "6.5.0",
"qs": "6.5.1",
"request": "2.81.0",

@@ -44,13 +44,13 @@ "use-strict": "1.0.1",

"devDependencies": {
"eslint": "4.2.0",
"eslint": "4.6.1",
"eslint-config-standard": "10.2.1",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-node": "5.1.0",
"eslint-plugin-node": "5.1.1",
"eslint-plugin-promise": "^3.3.0",
"eslint-plugin-standard": "3.0.1",
"istanbul": "0.4.5",
"jscpd": "0.6.11",
"jscpd": "0.6.13",
"lokka": "1.7.0",
"lokka-transport-http": "1.6.1",
"mocha": "3.4.2",
"mocha": "3.5.3",
"mocha-performance": "0.1.1",

@@ -57,0 +57,0 @@ "node-inspector": "1.1.1",

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