paw-client 🔑
paw-client is a javascript client for Plugandwork api that comes with tools to build an app based on Plugandwork services.
- Getting started
- Minimal configuration for the client
- Docs
- create doc
- upload a file in doc
- read docs
- update docs
- delete docs
- Spaces
- Other tools
- verify if a file is already uploaded
1 - Getting started
npm install --save paw-client
; // create and configure a new client instanceconst client = configuration;
Minimal configuration for the client
The Paw Client requires a minimal configuration. You need to provide the plugandwork server url to call and credentials to authorize all requests.
You can generate a new token in your plugandwork settings.
const client = host: 'https://host.plugandwork.fr' credentials: token: '' uuid: '' ;
2 - Docs
paw-client allows you to manage docs
; // create a new Doc instanceconst doc = title: 'Doc#1' tags: 'doing' 'work';
create doc
const _doc = configuration;const doc = await client;console; // will print the doc id provided by the api
You can also directly provide configuration to the createDoc method, a Doc instance will be returned
const doc = await client;console; // true
upload a file in doc
const file = fs;const formData = ;formData;await client;
read docs
const docs = await client;console; // will print how many docs with title 'test' did found by the api
You can get just one doc by adding limit: 1, exact: true
to the query object.
update docs
const docs = await client;
By default, client will replace doc values. You can add patch: true
to the values object to update values instead of replace.
delete docs
const docs = await client;
3 - Spaces
Documentation to come
4 - Other tools
verify if a file is already uploaded
try const md5 = 'myFileMd5'; await client; catch e throw 'This file is already uploaded';