jsonapi-server
Advanced tools
Comparing version 3.0.3 to 3.1.0
@@ -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 |
@@ -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
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance 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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
6408504
307
18679
4
1
6
+ Addedbody-parser@1.18.1(transitive)
+ Addedbytes@3.0.0(transitive)
+ Addeddebug@3.0.1(transitive)
+ Addeddepd@1.1.1(transitive)
+ Addedexpress@4.15.4(transitive)
+ Addedhttp-errors@1.6.2(transitive)
+ Addediconv-lite@0.4.19(transitive)
+ Addedqs@6.5.1(transitive)
+ Addedraw-body@2.3.2(transitive)
+ Addedsend@0.15.4(transitive)
+ Addedserve-static@1.12.4(transitive)
- Removedbody-parser@1.17.2(transitive)
- Removedbytes@2.4.0(transitive)
- Removeddebug@2.6.7(transitive)
- Removedexpress@4.15.3(transitive)
- Removediconv-lite@0.4.15(transitive)
- Removedqs@6.4.0(transitive)
- Removedraw-body@2.2.0(transitive)
- Removedsend@0.15.3(transitive)
- Removedserve-static@1.12.3(transitive)
Updatedbody-parser@1.18.1
Updateddebug@3.0.1
Updatedexpress@4.15.4
Updatedqs@6.5.1