2.2.9 • Published 4 years ago

paw-client v2.2.9

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

paw-client 🔑

paw-client is a javascript client for Plugandwork api that comes with tools to build an app based on Plugandwork services.


1 - Getting started

npm install --save paw-client

import PawClient from 'paw-client';

// create and configure a new client instance
const client = new PawClient(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 = new PawClient({
  host: 'https://host.plugandwork.fr',
  credentials: {
    token: '',
    uuid: ''
  }
});

2 - Docs

paw-client allows you to manage docs

import { Doc } from 'paw-client';

// create a new Doc instance
const doc = new Doc({
  title: 'Doc#1',
  tags: ['doing', 'work']
});

see Doc class

create doc

const _doc = new Doc(configuration);
const doc = await client.createDoc(doc);
console.log(doc.id); // 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.createDoc(configuration);
console.log(doc instanceof Doc); // true

upload a file in doc

const file = fs.createReadStream(filePath);
const formData = new FormData();
formData.append('file', file, { filepath });
await client.uploadFile(formData, { docId: doc.id, headers: formData.getHeaders(), maxContentLength });

read docs

const docs = await client.getDocs({ title: 'test' });
console.log(docs.length); // 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.updateDocs(docs, { title: 'test', key: 'newValue' });

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.deleteDocs(docs);

3 - Spaces

Documentation to come

4 - Other tools

verify if a file is already uploaded

try {
  const md5 = 'myFileMd5';
  await client.validateMd5(md5);
} catch (e) {
  throw new Error('This file is already uploaded');
}
2.2.9

4 years ago

2.2.8

5 years ago

2.2.7

5 years ago

2.2.6

5 years ago

2.2.5

5 years ago

2.2.4

5 years ago

2.2.3

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

0.1.61

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago