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

contentful

Package Overview
Dependencies
Maintainers
5
Versions
452
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful - npm Package Compare versions

Comparing version 0.1.2 to 1.0.0

CHANGELOG.md

109

index.js
'use strict';
var _ = require('lodash');
var questor = require('questor');
var axios = require('axios');
var redefine = require('redefine');

@@ -20,29 +20,30 @@ var resolveResponse = require('contentful-resolve-response');

request: function(path, options) {
if (!options) options = {};
if (!options.headers) options.headers = {};
if (!options.query) options.query = {};
options.headers['Content-Type'] = 'application/vnd.contentful.delivery.v1+json';
options.query.access_token = this.options.accessToken;
_request: function(path, query) {
if (!query) query = {};
query.access_token = this.options.accessToken;
var uri = [
this.options.secure ? 'https' : 'http',
'://',
_.first(this.options.host.split(':')),
':',
this.options.secure ? '443' : '80',
'/spaces/',
this.options.space,
path,
'?',
querystring.stringify(options.query)
].join('');
var params = {
headers: {},
method: 'get',
url: [
this.options.secure ? 'https' : 'http',
'://',
_.first(this.options.host.split(':')),
':',
this.options.secure ? '443' : '80',
'/spaces/',
this.options.space,
path,
'?',
querystring.stringify(query)
].join('')
};
params.headers['Content-Type'] = 'application/vnd.contentful.delivery.v1+json';
return questor(uri, options)
.then(parseJSONBody)
.catch(Error, function(error) {
throw error;
return axios(params)
.then(function (response) {
return response.data;
})
.catch(function(error) {
throw parseJSONBody(error);
.catch(function (error) {
throw error.data;
});

@@ -52,3 +53,6 @@ },

asset: function(id, callback) {
return this.request('/assets/' + id).then(Asset.parse).nodeify(callback);
return nodeify(
this._request('/assets/' + id).then(Asset.parse),
callback
);
},

@@ -58,11 +62,11 @@

var query = Query.parse(object);
return this.request('/assets', {query: query})
.then(_.partial(SearchResult.parse, Asset))
.nodeify(callback);
var deferred = this._request('/assets', query)
.then(_.partial(SearchResult.parse));
return nodeify(deferred, callback);
},
contentType: function(id, callback) {
return this.request('/content_types/' + id)
.then(ContentType.parse)
.nodeify(callback);
var deferred = this._request('/content_types/' + id)
.then(ContentType.parse);
return nodeify(deferred, callback);
},

@@ -72,11 +76,11 @@

var query = Query.parse(object);
return this.request('/content_types', {query: query})
.then(_.partial(SearchResult.parse, ContentType))
.nodeify(callback);
var deferred = this._request('/content_types', query)
.then(_.partial(SearchResult.parse));
return nodeify(deferred, callback);
},
entry: function(id, callback) {
return this.request('/entries/' + id)
.then(Entry.parse)
.nodeify(callback);
var deferred = this._request('/entries/' + id)
.then(Entry.parse);
return nodeify(deferred, callback);
},

@@ -86,9 +90,9 @@

var query = Query.parse(object);
return this.request('/entries', {query: query})
.then(_.partial(SearchResult.parse, Entry))
.nodeify(callback);
var deferred = this._request('/entries', query)
.then(_.partial(SearchResult.parse));
return nodeify(deferred, callback);
},
space: function(callback) {
return this.request('').nodeify(callback);
return nodeify(this._request(''), callback);
}

@@ -150,3 +154,3 @@ });

statics: {
parse: function(ItemType, object) {
parse: function(object) {
walkMutate(object, isParseableResource, parseResource);

@@ -264,6 +268,2 @@ var items = resolveResponse(object);

function parseJSONBody(response) {
return JSON.parse(response.body);
}
function stringifyArrayValues(object) {

@@ -289,1 +289,16 @@ return _.reduce(object, function(object, value, key) {

}
function nodeify(deferred, callback) {
if(callback) {
return deferred
.then(function (response) {
callback(null, response);
return response;
})
.catch(function (error) {
callback(error);
throw error;
});
}
return deferred;
}
{
"name": "contentful",
"description": "Client for Contentful's Content Delivery API",
"version": "0.1.2",
"version": "1.0.0",
"homepage": "https://www.contentful.com/developers/documentation/content-delivery-api/",
"main": "index.js",
"browser": {
"questor": "./questor.min.js"
},
"repository": "git@github.com:contentful/contentful.js.git",

@@ -14,5 +11,5 @@ "author": "Stephan Seidt <stephan@contentful.com>",

"dependencies": {
"axios": "^0.5.2",
"contentful-resolve-response": "~0.1.0",
"lodash": "~2.4.1",
"questor": "1.0.0-alpha.2",
"redefine": "~0.2.0"

@@ -22,13 +19,13 @@ },

"buster": "~0.7.6",
"bluebird": "~1.2.4",
"bluebird": "^2.0.0",
"envify": "~1.0.1",
"testem": "~0.6.2",
"browserstack-cli": "~0.3.1",
"browserify": "~3.20.0"
"browserify": "~3.20.0",
"saucie": "^0.1.0"
},
"scripts": {
"prepare-browser-test": "browserify -d -t envify -x buster test/helper.js > test/bundle-helper.js",
"test": "testem ci -P 6",
"test-local": "testem"
"ci": "testem ci -P 6",
"test": "testem"
}
}

@@ -55,3 +55,6 @@ # contentful.js

// Enable or disable SSL. Enabled by default.
secure: true
secure: true,
// Set an alternate hostname, default shown.
host: 'cdn.contentful.com'
});

@@ -58,0 +61,0 @@

@@ -9,6 +9,6 @@ 'use strict';

global.assert = buster.assert;
global.refute = buster.refute;
global.assert = global.buster.assert;
global.refute = global.buster.refute;
global.util = require('./util');
global.client = global.util.client;

Sorry, the diff of this file is not supported yet

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