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

badgr-client

v1.0.0

Published

client for the badgr-server API

Downloads

15

Readme

Badgr-client

Work In Progress: not much to see for now.

Travis

A nodejs client for the badgr-server API.

The main goal is to use this client in PaperBadger, so the bulk of the work will focus on the needs of that particular project. At some point, the library will be extended to support the full Badgr API.

What works for now

  • Authorisation through user name and password (only method supported by the Badgr API).
  • List all badges
  • Issue badges to a recipient (email as Id)
  • List all instances of a badge by issuer
  • List all badges issued to a particular recipient (by ORCID)
  • List all badges issued for a particular paper (by evidence doi url)

What needs to be done?

The bulk of the work is stated in #7.

Development

Fork and clone

Fork a repo as per github instructions and then clone with (make sure to swap YOUR_USER_NAME with your real github username):

git clone [email protected]:YOUR_USER_NAME/badgr-client.git

Main branch - dev

Note that the main branch is dev and not master. All work will eventually be merged into master, but dev is the working branch, while master will be used to publish to nmp.

Tests

Mocha is the test framework used for this project, and chai is the assertion library. Run all tests with npm test.

Unit tests can be run with npm run test:unit.

Testing will automatically lint and stop if code style does not pass.

Note that you will need to copy the default.env file into an .env file in order to provide authentication details for a Badgr user and server URL.

Easy badgr-server install

For an easy way to install badgr-server, you can use this Dockerfile.

Code Style

This project follows most of the guidelines in the mofo-style package. Some of the rules have been modified because this is not a front-end ES6 project.

Linting will be run automatically with some other tasks (such as testing), but can be invoked by itself with npm run lint.

Contributing

Please see CONTRIBUTING.md for contribution guidelines.

Install & Usage

Note that there's no npm package yet, so you can npm link if you want to use it in a demo app

The easiest way to see how to use the library is to look into the integration tests in badge_methods.js

Client setup & API calls

The main example in tests so far is:


    it('should return data when calling all badges', function (done) {
      var client = new Index(apiEndpoint, goodTestAuth);

      client.getAllBadges(function (err, data) {
        expect(err).to.be.null;
        expect(data).not.to.be.undefined;
        expect(data[0].created_at).not.to.be.undefined;
        done();
      });
    });

where apiEndpoint is a valid url to a badgr-server instance, and goodTestAuth is in the form: { username: '[email protected]', password: 'xxx'}.

Concerns and things to watch out for

Because this library is being created for PaperBadger, some abstractions from that project may be leaking into the library. For instance, the evidence field is used to contain a paper doi url, and the method is currently called getBadgeInstancesByEvidence, although getBadgeInstancesByPaper would make more sense in PaperBadger. This would not make sense in a generic badges context, though. Another example is using references to DOI and ORCID within the tests. Those tests should not fail even if the data is not available, but it ties the library to the PaperBadger domain.

The library should be as generic as possible.

Jos - May 2o16