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

prospector-js-sdk

v2.0.0

Published

Client library for calling the Prospector API

Downloads

1,575

Readme

Prospector JavaScript Client Library (Experimental)

Install

$ npm install --save prospector-js-sdk superagent

Usage

Importing

The prospector-js-sdk package is static; nothing needs to be constructed.

import * as sdk from 'prospector-js-sdk'

Base URL

All API functions allow you to specify the baseUrl of the request. However, to avoid having to pass that every time, you can call setBaseUrl to statically set the base URL for every API call.

sdk.setBaseUrl('http://localhost:3000/api/v1') // Use the applicable base url for your environment

You can always override this by explicitly passing baseUrl to the API function.

Token strategies

Automatic (recommended)

By default, prospector-js-sdk will first look for a token query parameter in the URL, then it will look for a token cookie. If neither are found, it will throw an error.

// Make a call with default automatic token management.
const { json: editor } = await sdk.getEditor({ editorId })

Provide your own token

Every API function also allows you to explicitly provide a token. This will override the automatic token management.

// Make a call with a token you manage.
const { json: editor } = await sdk.getEditor({ token: someToken, editorId })

Set your own automatic strategy

If the default token management strategy doesn't suit your application, you can provide your own. prospector-js-sdk will then use that to retrieve tokens for API calls.

sdk.setTokenStrategy = async () => {
  // Obtain a Prospector token by whatever means you need.
  return someToken
}

// Then you don't need to provide a token.
const { json: editor } = await sdk.getEditor({ editorId })

If you would like to use the default token management strategy but the details of your application differ, you can wrap the manageToken function and provide overrides.

sdk.setTokenStrategy = () => {
  return sdk.manageToken({
    baseUrl: 'some-other-base-url',
    paramName: 'jwt',
    tokenName: 'jwt',
    path: '/super/special/cookie/path'
  })
}

const { json: editor } = await sdk.getEditor({ editorId })

Deployment

An alpha release is automatically created when opening a PR into dev.

Releases are found on NPM.

To make an official version release:

  1. Check out dev
  2. Run npm version with patch, minor, or major
  3. Push dev and the newly created version tag
  4. Go to Releases in Github and create a release
  5. For good hygiene, make a PR and merge dev into main to keep them up to date (it doesn't functionally do anything)

At some point we would like to just use main and delete the dev branch to simplify this.