npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

buttress-js-api

v2.5.2

Published

ButtressJS API for Node.js

Downloads

7

Readme

buttress-api-js

Latest: 2.5.2

  • ADDED: get user by token API (#8)

2.5.1

  • ADDED: mongo project to filter returned results (#7)

2.5.0

  • ADDED: Query, Limit, Skip, Sort to search & count APIs

2.4.1

  • ADDED: Added count api to each schema

2.4.0

  • TODO: Write some notes

2.3.5

  • ADDED: Generate a id locally when creating collection documents
  • BUMP: dependencies (mongodb), devDependencies (eslint, mocha)

2.3.4

  • ADDED: Customer Error definitions for NotYetInitiated && SchemaNotFound
  • ADDED: Test for interacting with a buttress app after a schema update
  • FIX: Fetch the latest compiled Schema after a schema update

2.3.3

  • FIX: Failing to update app roles due to non-array being passed

2.3.2

  • ADDED: Allow user to pass allowUnauthorized to bypass invalid cert

2.3.1

  • FIX: incorrect dependency name Helper -> Helpers

2.3.0

  • REFACTOR: Removed restler and replaced with axios
  • TWEAK: Testing, added bulk companies save
  • REFACTOR: Bulk save with return the newly added objects
  • REFACTOR: getCollection should reference collection
  • ADDED: Block user from calling getCollection before init

2.2.1

  • FIX: Update outdated npm packages

2.2.0

  • ADDED: Schema method for creating a object with default values
  • ADDED: Helpers for schema handling (flattern, inflate)
  • ADDED: data type 'id' now has default 'new' which will generate a new id

2.1.4

  • FIX: Update package.json engine 'node' version

2.1.3

  • FIX: Token not passed through from default options to get request

2.1.2

  • FIX: Removed APIs using load/create -> get/save

2.1.1

  • ADDED: API under Auth for creating new tokens for a user

2.1.0

  • ADDED: Apps API's are now prefixed with there own name

2.0.1

  • ADDED: API for updating a token role

2.0.0 :tada:

  • ADDED: API support for custom schema. (Core schema are now stripped down).
  • ADDED: Ability to pass app roles object to buttress
  • REFACTOR: Breaking data changes to all core API's (app, auth, user, token).

For the v1 change list please see ./changelog.md

Installation

npm install buttress-js-api

Usage

First of all you need to initialise Buttress with a valid App Token. App Tokens are created in Buttress by the system administrator.

const Buttress = require('buttress-js-api');
Buttress.init({
  buttressUrl: 'http://buttress.url',
  apiPath: 'my-app',
  appToken: 'Get this from the Buttress Admin',
  version: 1
});

Once you have initialised Buttress you can use it as follows:

User Auth

This creates a Buttress user based on OAuth2 user flow authentication leading to a token and tokenSecret. In addition to the basic information Buttress stores these properties:

var user = {
  app: 'twitter',
  id: profile.id,
  token: token,
  tokenSecret: tokenSecret,
  name: profile._json.name,
  username: profile.username,
  profileUrl: `https://twitter.com/${profile.username}`,
  profileImgUrl: profile._json.profile_image_url,
  bannerImgUrl: profile._json.profile_banner_url
};
  
Buttress.Auth.findOrCreateUser(user)
  .then(buttressUser => cb(null, buttressUser))
  .catch(Logging.Promise.logError());

User data is shared across all Buttress applications based on trusted OAuth application Ids.

User Metadata

User metadata is silo'ed on a per application basis. Specify the default value for when there is no metadata in the database.

buttress.User.loadMetadata(userButtressId, 'KEY_NAME', [])
  .then(data => Logging.log(data))
  .catch(err => Logging.log(err));
Buttress.User.saveMetadata(userbuttressId, 'KEY_NAME', {foo:true, bar:false})
  .then(data => Logging.log(data))
  .catch(err => Logging.log(err));

User

Buttress.User.get(buttressUserId)
  .then(u => {
    var twauth = u.auth.find(a => a.app === 'twitter');
    if (!twauth) {
      return;
    }
    // Do something useful with the user twauth.token && twauth.tokenSecret

App Metadata

Applications have metadata (specify the default value for when there is no metadata in the database):

Buttress.App.loadMetadata('KEY_NAME', [])
  .then(data => Logging.log(data))
  .catch(err => Logging.log(err));
Buttress.User.saveMetadata('KEY_NAME', {foo:true, bar:false})
  .then(data => Logging.log(data))
  .catch(err => Logging.log(err));