quintype-backend
Advanced tools
Comparing version 1.4.1 to 1.5.0
35
index.js
'use strict'; | ||
var rp = require('request-promise'); | ||
var Promise = require("bluebird"); | ||
var _ = require("lodash"); | ||
const rp = require('request-promise'); | ||
const Promise = require("bluebird"); | ||
const _ = require("lodash"); | ||
const {loadNestedCollectionData} = require("./collection-loader"); | ||
const { DEFAULT_DEPTH } = require("./constants"); | ||
function wrapBuildFunction(clazz, upstream) { | ||
clazz.build = function() { | ||
if(!arguments[0]) | ||
return null; | ||
return new Proxy(new clazz(...arguments), { | ||
@@ -113,6 +118,10 @@ get: function(target, key) { | ||
static getCollectionBySlug(client, slug, params) { | ||
static getCollectionBySlug(client, slug, params, options = {}) { | ||
const {depth = DEFAULT_DEPTH} = options; | ||
return client | ||
.getCollectionBySlug(slug, params) | ||
.then(response => response && Collection.build(response["collection"] || response)); | ||
.then(response => { | ||
const collection = response ? response["collection"] || response : null; | ||
return collection && loadNestedCollectionData(client, collection, {depth}) | ||
}).then(collection => Collection.build(collection)) | ||
} | ||
@@ -180,2 +189,8 @@ } | ||
function catch404(e, defaultValue) { | ||
if(e && e.statusCode == 404) | ||
return defaultValue; | ||
throw e; | ||
} | ||
class Client { | ||
@@ -218,3 +233,3 @@ constructor(baseUrl, temporaryClient) { | ||
json: true | ||
}) | ||
}).catch(e => catch404(e, {})) | ||
} | ||
@@ -228,3 +243,3 @@ | ||
json: true | ||
}) | ||
}).catch(e => catch404(e, null)) | ||
} | ||
@@ -247,3 +262,3 @@ | ||
json: true | ||
}); | ||
}).catch(e => catch404(e, {})); | ||
} | ||
@@ -256,3 +271,3 @@ | ||
json: true | ||
}); | ||
}).catch(e => catch404(e, {})); | ||
} | ||
@@ -285,3 +300,3 @@ | ||
json: true | ||
}); | ||
}).catch(e => catch404(e, {})); | ||
} | ||
@@ -288,0 +303,0 @@ |
{ | ||
"name": "quintype-backend", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "client for accessing quintype API", | ||
"main": "index.js", | ||
"scripts": { | ||
"prepublishOnly": "npm install && git diff --quiet && git tag v$(cat package.json | grep version | head -n1 | cut -d \\\" -f 4) && git push --tags origin master" | ||
}, | ||
@@ -23,6 +23,6 @@ "repository": { | ||
"dependencies": { | ||
"lodash": "^3.10.1", | ||
"request": "^2.74.0", | ||
"lodash": "^4.17.10", | ||
"request": "^2.85.0", | ||
"request-promise": "^4.1.1" | ||
} | ||
} |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
12021
5
357
1
27
0
- Removedlodash@3.10.1(transitive)
Updatedlodash@^4.17.10
Updatedrequest@^2.85.0