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 2.2.0 to 2.3.0

5

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

@@ -27,3 +27,4 @@ "main": "index.js",

"dependencies": {
"axios": "^0.16.2"
"axios": "^0.16.2",
"qs": "^6.5.1"
},

@@ -30,0 +31,0 @@ "devDependencies": {

58

remote.js
const axios = require('axios');
const qs = require('qs');
class RemoteInstance {
constructor(options) {
const {accessToken, url} = options;
const {accessToken, url, headers} = options;
this.accessToken = accessToken;
this.headers = headers;

@@ -17,3 +19,3 @@ if (!url) {

get _requestHeaders() {
const headers = {};
const headers = this.headers;

@@ -31,3 +33,7 @@ if (this.accessToken) {

return new Promise((resolve, reject) => {
axios.get(this.url + endpoint, {params, headers})
axios.get(this.url + endpoint, {
params,
headers,
paramsSerializer: params => qs.stringify(params, {arrayFormat: 'brackets'})
})
.then(res => resolve(res.data))

@@ -92,2 +98,18 @@ .catch(err => {

// Authentication
// -------------------------------------------
authenticate(email = requiredParam('email'), password = requiredParam('password')) {
return new Promise((resolve, reject) => {
this._post('auth/request-token', {email, password})
.then(res => {
if (res.success) {
this.accessToken = res.data.token;
return resolve(res);
}
return reject(res);
})
.catch(err => reject(err));
});
}
// Items

@@ -115,2 +137,32 @@ // ----------------------------------------------------------------------------------

createBulk(table = requiredParam('table'), data = requiredParam('data')) {
if (Array.isArray(data) === false) {
throw new TypeError(`Parameter data should be an array of objects`);
}
return this._post(`tables/${table}/rows/bulk`, {
rows: data
});
}
updateBulk(table = requiredParam('table'), data = requiredParam('data')) {
if (Array.isArray(data) === false) {
throw new TypeError(`Parameter data should be an array of objects`);
}
return this._put(`tables/${table}/rows/bulk`, {
rows: data
});
}
deleteBulk(table = requiredParam('table'), data = requiredParam('data')) {
if (Array.isArray(data) === false) {
throw new TypeError(`Parameter data should be an array of objects`);
}
return this._delete(`tables/${table}/rows/bulk`, {
rows: data
});
}
// Files

@@ -117,0 +169,0 @@ // ----------------------------------------------------------------------------------

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