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

@harvard-lil/perma-js-sdk

v0.0.5

Published

A JavaScript library to interact with Perma.cc's REST API

Downloads

13

Readme

perma-js-sdk

A JavaScript library to interact with Perma.cc's REST API.

⚠️ This is an early version.

Test suite npm version


Summary


Getting started

Installation as a dependency

You may use npm or your favorite JavaScript package manager to install perma-js-sdk as a dependency.

npm install @harvard-lil/perma-js-sdk

Directly in the browser

This library can be imported directly in the browser. You may use a service such as unpkg.com to import its latest version from npmjs.org.

import { PermaAPI } from "https://unpkg.com/@harvard-lil/perma-js-sdk@latest/index.js";

Quick Example

Here a quick example of how to use the PermaAPI class to interact with Perma.cc's API. See the API Documentation for details.

import { PermaAPI } from "@harvard-lil/perma-js-sdk";

try {
  const api = new PermaAPI(API_KEY);
  const archive = await api.createArchive("https://lil.harvard.edu");
  console.log(`Archive created -- guid: ${archive.guid}`);
}
catch(err) {
  // ...
}

☝️ Back to summary


Stack and compatibility

Stack

This library, by design, has no runtime dependency and does not require a build step in most cases.

Compatibility notes

This library:

  • [...] uses the Fetch API.Versions of Node.js that do not support fetch() may instead use node-fetch and make it globally accessible.
  • [...] is ES module-based and doesn't support CommonJS syntax.
  • [...] was written so it can be run without transpiling in:
    • Latest Chromium
    • Latest Gecko
    • Latest WebKit
    • Latest Node.js (+ latest Node.js LTS with node-fetch)

☝️ Back to summary


API documentation

Reference

Notes

  • This project uses JSDoc and is compatible with IntelliSense (Examples: [1] [2]).

Misc

☝️ Back to summary


Development CLI

docgen

npm run docgen

Refreshes files under /doc using JSDoc comments in index.js and types.js.

test-unit

npm run test-unit

Runs index.unit.test.js using Jest.

test-integration

npm run test-integration

Runs index.integration.test.js using Jest. This test suite requires the TESTS_API_KEY and TESTS_FORCE_BASE_URL environment variables to be set.

test-integration-local

npm run test-integration-local

Same as test-integration but:

  • Reads environment variables from .env file if available
  • Ignores TLS certificates errors (so the tests can be run against a local instance of the Perma API)

☝️ Back to summary


Environment variables

Scope: Integration tests

The following environment variables are only used in the context of the integration tests suite.

| Name | Required? | Description | | --- | --- | --- | | TESTS_API_KEY | Yes | API key to be used to perform integration tests. Can be of any type of account. | | TESTS_FORCE_BASE_URL | No | Base API url to be used to perform integration tests. If not set, will default to https://api.perma.cc. |

☝️ Back to summary


Publishing a new version

Once changes have been merged to develop and a new version is ready, please follow these steps to deploy a new version of the package:

  1. Run unit tests: npm run test-unit
  2. Run integration tests: npm run test-integration-local
  3. Update documentation: npm run docgen
  4. Update NPM package version number: npm version patch --no-git-tag-version
  5. Publish on NPM: npm publish --access public
  6. Commit and push changes to develop
  7. PR and merge to main, with version number as PR title.

ℹ️ Steps 1-5 can be replaced by ./test-and-publish.sh

You will need access to the @harvard-lil organization on npmjs.org to publish new versions of the package.

☝️ Back to summary