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

clubhouse-lib

Package Overview
Dependencies
Maintainers
6
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clubhouse-lib - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

65

build/index.js
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

@@ -34,18 +36,8 @@

* @class Client
*/
*/
var Client = function () {
function Client() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultConfig,
baseURL = _ref.baseURL,
version = _ref.version;
var requestFactory = arguments[1];
var requestPerformer = arguments[2];
var responseParser = arguments[3];
function Client(requestFactory, requestPerformer, responseParser) {
_classCallCheck(this, Client);
this.baseURL = baseURL;
this.version = version;
this.requestFactory = requestFactory;

@@ -59,11 +51,5 @@ this.requestPerformer = requestPerformer;

_createClass(Client, [{
key: 'generateUrl',
value: function generateUrl(uri) {
return this.baseURL + '/api/' + this.version + '/' + uri;
}
}, {
key: 'listResource',
value: function listResource(uri) {
var URL = this.generateUrl(uri);
var request = this.requestFactory.createRequest(URL);
var request = this.requestFactory.createRequest(uri);
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse);

@@ -74,4 +60,3 @@ }

value: function getResource(uri, params) {
var URL = this.generateUrl(uri);
var request = params ? this.requestFactory.createRequest(URL, 'GET', params) : this.requestFactory.createRequest(URL);
var request = params ? this.requestFactory.createRequest(uri, 'GET', params) : this.requestFactory.createRequest(uri);
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse);

@@ -82,4 +67,3 @@ }

value: function createResource(uri, params) {
var URL = this.generateUrl(uri);
var request = this.requestFactory.createRequest(URL, 'POST', params);
var request = this.requestFactory.createRequest(uri, 'POST', params);
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse);

@@ -90,4 +74,3 @@ }

value: function updateResource(uri, params) {
var URL = this.generateUrl(uri);
var request = this.requestFactory.createRequest(URL, 'PUT', params);
var request = this.requestFactory.createRequest(uri, 'PUT', params);
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse);

@@ -98,4 +81,3 @@ }

value: function deleteResource(uri, params) {
var URL = this.generateUrl(uri);
var request = this.requestFactory.createRequest(URL, 'DELETE', params);
var request = this.requestFactory.createRequest(uri, 'DELETE', params);
return this.requestPerformer.performRequest(request).then(this.responseParser.parseResponse);

@@ -219,2 +201,23 @@ }

}, {
key: 'searchStories',
value: function searchStories(query) {
var _this = this;
var pageSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
return this.getResource('search/stories', {
query: query,
page_size: pageSize
}).then(function (result) {
return _extends({}, result, {
fetchNext: function fetchNext() {
return _this.getResource(result.next);
}
});
});
}
/** */
}, {
key: 'createStory',

@@ -402,4 +405,8 @@ value: function createStory(params) {

key: 'create',
value: function create(token, options) {
return new Client(options || defaultConfig, new _TokenRequestFactory2.default(token), new _FetchRequestPerformer2.default(), new _FetchRequestParser2.default());
value: function create(token) {
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig;
var baseURL = config.baseURL,
version = config.version;
return new Client(new _TokenRequestFactory2.default(token, baseURL, version), new _FetchRequestPerformer2.default(), new _FetchRequestParser2.default());
}

@@ -406,0 +413,0 @@ }]);

@@ -7,7 +7,5 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _queryString = require('query-string');
var _universalUrl = require('universal-url');

@@ -19,14 +17,26 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var TokenRequestFactory = function () {
function TokenRequestFactory(token) {
function TokenRequestFactory(token, baseURL, version) {
_classCallCheck(this, TokenRequestFactory);
this.token = token;
this.baseURL = baseURL;
this.version = version;
}
_createClass(TokenRequestFactory, [{
key: 'prefixURI',
value: function prefixURI(uri) {
var prefix = '/api/' + this.version + '/';
if (uri.startsWith(prefix)) {
return uri;
}
return '' + prefix + uri;
}
}, {
key: 'createRequest',
value: function createRequest(url) {
value: function createRequest(uri) {
var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GET';
var body = arguments[2];
var url = new _universalUrl.URL(this.prefixURI(uri), this.baseURL);
var headers = {

@@ -36,9 +46,12 @@ Accept: 'application/json',

};
var params = _extends({}, body, {
token: this.token
});
url.searchParams.append('token', this.token);
if (method === 'GET') {
var resolvedURL = url + '?' + (0, _queryString.stringify)(params);
return new Request(resolvedURL, {
if (body) {
Object.entries(body).forEach(function (entry) {
return url.searchParams.append(entry[0], String(entry[1]));
});
}
return new Request(url.toString(), {
headers: headers,

@@ -49,4 +62,4 @@ method: method

return new Request(url, {
body: JSON.stringify(params),
return new Request(url.toString(), {
body: JSON.stringify(body),
headers: headers,

@@ -53,0 +66,0 @@ method: method

{
"name": "clubhouse-lib",
"version": "0.4.1",
"version": "0.5.0",
"description": "A Promise based library to the Clubhouse REST API",

@@ -18,2 +18,3 @@ "files": [

"flow": "flow",
"prettier": "prettier --single-quote --trailing-comma all --write src/**/*.js",
"ci": "npm run lint && npm run flow && npm test"

@@ -45,3 +46,3 @@ },

"jest": "^21.2.0",
"prettier": "^1.7.1",
"prettier": "^1.16.4",
"save": "^2.3.1"

@@ -59,4 +60,5 @@ },

"fetch-everywhere": "^1.0.5",
"query-string": "^6.2.0"
"query-string": "^6.2.0",
"universal-url": "^2.0.0"
}
}

Sorry, the diff of this file is not supported yet

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