0.1.4 • Published 10 years ago

@praekelt/seed-auth v0.1.4

Weekly downloads
1
License
BSD-3-Clause
Repository
github
Last release
10 years ago

seed-auth-js

js client for seed-auth-api

install

$ npm install @praekelt/seed-auth

usage

const auth = require('@praekelt/seed-auth');

auth.users.list()
  .then(res => console.log(resp.data));

api

configuration

Configuration can be provided as an options object for each api method:

auth.users.list({conf: {token: '1234'}});

or set for all api methods:

auth.conf.token = '1234';

conf.prefix

The prefix to use for requests. Defaults to http://localhost:8000.

conf.token

The authentication token to use for requests.

query params

Query params for api methods can be provided directly in the options object for each api method:

auth.users.list({archived: true});

pagination

The result object contains next(), prev(), hasNext() and hasPrev() methods for traversing paginated results:

auth.users.list({
    page: 1,
    page_size: 2
  })
  .then(res => {
    // `true` if there is a next page, otherwise `false`
    console.log(res.hasNext());

    // `true` if there is a previous page, otherwise `false`
    console.log(res.hasPrev());

    return res
  })
  .then(res => res.next()) // next page (or `null` if there is no next page)
  .then(res => res.prev()); // prev page (or `null` if there is no prev page)

auth.user

auth.tokens

auth.passwords

auth.users

auth.organizations

auth.teams

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago