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

node-directus-client

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-directus-client - npm Package Compare versions

Comparing version 0.1.2 to 0.3.0

src/BaseClient.js

6

package.json
{
"name": "node-directus-client",
"version": "0.1.2",
"version": "0.3.0",
"description": "A JavaScript client for the Directus API",

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

"sinon": "^1.17.6",
"sinon-chai": "^2.8.0",
"webpack": "^1.13.2"

@@ -30,4 +31,5 @@ },

"q": "^1.4.1",
"request": "^2.76.0"
"request": "^2.76.0",
"sprintf-js": "^1.0.3"
}
}

@@ -14,18 +14,25 @@ # Directus API JavaScript Client

Then require it in your application script:
`const DirectusClient = require('node-directus-client')`
`const DirectusSDKClient = require('node-directus-client')`
## Usage
The module is a class, so you'll have to create a new instance of the client bound to the endpoint and access token of your Directus instance.
The module is a class, so you'll have to create a new instance of the client bound to the endpoint and access token of your Directus instance. This can either be a self-hosted Directus installation or a hosted Directus instance.
Self-hosted
```javascript
const cms = new DirectusClient({
url: 'https://example.com/api/1/',
key: 'abcdef12345'
const client = new DirectusSDKClient('apiKey-12345', {
baseURL: 'http://yoursite.com/api/'
});
```
Hosted
```javascript
const client = new DirectusSDKClient('apiKey-12345', {
instanceKey: 'instance_key'
});
```
Every method (see below) is asynchronous and can be used with callbacks as well as promises.
```javascript
cms.tables()
client.getTables()
.then((res) => {

@@ -35,3 +42,3 @@ console.log(res);

cms.tables(function(err, res) {
client.getTables(function(err, res) {
console.log(res);

@@ -42,11 +49,41 @@ });

## Methods (endpoints)
The methods mimic the [original Directus API endpoints](http://getdirectus.com/api/overview/endpoints) as closely as possible.
### Tables
The options object will be converted to query params in the api request. Check [the official Directus API endpoints docs](http://getdirectus.com/api/overview/endpoints) for all available options.
### getTables
```javascript
cms.tables([raw = false, callback])
client.getTables([_obj_ options, _fn_ callback])
```
Gets all available tables.
Get all available tables.
### Arguments:
- `raw`: (bool) return the data as an Array of names or original Directus response
### getColumns
```javascript
client.getColumns(_string_ table, [_obj_ options, _fn_ callback])
```
Get all columns from a single table.
### getEntry
```javascript
client.getEntry(_string_ table, _int_ id, [_obj_ options, _fn_ callback])
```
Get a single item from a table
### getEntries
```javascript
client.getEntries(_string_ table, [_obj_ options, _fn_ callback])
```
Get multiple items from a table
### getUser
```javascript
client.getUser(_int_ id, [_obj_ options, _fn_ callback])
```
Get a single user
### getUsers
```javascript
client.getUsers([_obj_ options, _fn_ callback])
```
Get all users
**More methods will be added over time, including methods to update and post entries**

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