node-directus-client
Advanced tools
Comparing version 0.1.2 to 0.3.0
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14397
10
295
87
4
5
1
+ Addedsprintf-js@^1.0.3
+ Addedsprintf-js@1.1.3(transitive)