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

directus-sdk-javascript

Package Overview
Dependencies
Maintainers
3
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directus-sdk-javascript - npm Package Compare versions

Comparing version 3.0.0-8 to 3.0.0-9

3

package.json
{
"name": "directus-sdk-javascript",
"version": "3.0.0-8",
"version": "3.0.0-9",
"description": "WIP - Directus SDK for JavaScript (Node and Browser)",

@@ -28,3 +28,2 @@ "main": "index.js",

"axios": "^0.16.2",
"base-64": "^0.1.0",
"qs": "^6.5.1"

@@ -31,0 +30,0 @@ },

const axios = require('axios');
const base64 = require('base-64');
const qs = require('qs');

@@ -14,13 +13,11 @@

class RemoteInstance {
constructor(options = {}) {
// Headers to be send with every request
this._headers = options.headers || {};
const RemoteInstance = {
// Headers to be send with every request
headers: {},
// The currently in use full unparsed access token
this._accessToken = options.accessToken || {};
// The currently in use full unparsed access token
accessToken: null,
// The currently in use api url
this._url = options.url || {};
}
// The currently in use api url
url: null,

@@ -37,27 +34,11 @@ // Private methods

_createHeaders() {
const headers = this._headers || {};
const headers = this.headers || {};
if (this._accessToken) {
headers.Authorization = 'Bearer ' + this._accessToken;
if (this.accessToken) {
headers.Authorization = 'Bearer ' + this.accessToken;
}
return headers;
}
},
get url() {
return this._url;
}
set url(val) {
this._url = val;
}
get accessToken() {
return this._accessToken;
}
set accessToken(val) {
this._accessToken = val;
}
// ---------------------------------------------------------------------------

@@ -80,3 +61,3 @@

request(method, url, requestData = {}) {
if (Boolean(this._url) === false) throw 'No API URL set';
if (Boolean(this.url) === false) throw 'No API URL set';

@@ -89,3 +70,3 @@ const requestConfig = {

headers: this._createHeaders(),
baseURL: this._url,
baseURL: this.url,

@@ -97,3 +78,3 @@ // Use QS to format params

return axios.request(requestConfig).then(response => response.data);
}
},

@@ -106,7 +87,7 @@ // ---------------------------------------------------------------------------

return this.request('post', '/auth/authenticate', userCredentials);
}
},
refreshToken(token) {
return this.request('post', '/auth/refresh', { token });
}
},

@@ -117,19 +98,19 @@ // Items

return this.request('get', `items/${table}`, params);
}
},
getItem(table = requiredParam('table'), primaryKey = requiredParam('primaryKey'), params = {}) {
return this.request('get', `items/${table}/${primaryKey}`, params);
}
},
updateItem(table = requiredParam('table'), primaryKey = requiredParam('primaryKey'), data = {}) {
return this.request('patch', `items/${table}/${primaryKey}`, data);
}
},
createItem(table = requiredParam('table'), data = {}) {
return this.request('post', `items/${table}`, data);
}
},
deleteItem(table = requiredParam('table'), primaryKey = requiredParam('primaryKey')) {
return this.request('delete', `items/${table}/${primaryKey}`);
}
},

@@ -140,8 +121,8 @@ // Tables

return this.request('get', 'tables', params);
}
},
getTable(table = requiredParam('table'), params = {}) {
return this.request('get', `tables/${table}`, params);
}
}
},
};

@@ -148,0 +129,0 @@ function requiredParam(name) {

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