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

pinniped-sdk

v0.5.1

Published

SDK for communicating with your Pinniped backend

Downloads

7

Readme

Pinniped-SDK

An easy-to-use SDK for communicating with your Pinniped backend, using Axios.

Setup

  • Install the SDK: npm install pinniped-sdk

  • Import the library and point it to your Pinniped backend:

import pinniped from "pinniped-sdk";

//Your sdk instance ready for use in your frontend
const pnpd = pinniped("https://yourwebsite.com");

You can access all of the SDK methods on pnpd.

Usage

Note: In the examples below we await the sdk methods since in the background they are making an async Axios network request. These await calls must be in an async function in order to have any effect.

Authentication

Authentication is how users are registered and logged in/out. Note: You will not be able to log in as an admin, the SDK only supports user operations. Any adminstrative actions should utilize the Admin UI.

// Register
await pnpd.auth.register(username, password);

// Login
await pnpd.auth.login(username, password);

// Logout
await pnpd.auth.logout();

// Returns the current user session data
await pnpd.auth.getUser();

Database Access

// Get all rows from a table
const rows = await pnpd.db.getAll(tableName);

// Get all rows from a table with pagination and sorting by a given column name
const rows = await pnpd.db.getAll(tableName, pageNum, limit, sortBy, order);

// Get one row from a table
const row = await pnpd.db.getOne(tableName, rowId);

// Create a new row in a table
const createdRow = await pnpd.db.createOne(tableName, data);

// Update a row in a table
const updatedRow = await pnpd.db.updateOne(tableName, rowId, data);

// Delete a row in a table
await pnpd.db.deleteOne(tableName, rowId);

The data argument supplied to createOne and updateOne should be an object with key-value pairs that correspond to the columns of the table. For instance, if my table had columns for type and description, I would send an object that looked like: `{type: "Elephant Seal", description: "Really big!"}.

You may notice the columns: id, created_at, and updated_at. These are all system columns that are automatically populated upon creation of a row.

Return Value

The sdk operations return an object (the standard object that Axios returns from a request) with the following properties:

{
  status
  statusText
  headers
  config
  request
  data
}

Any response data from the backend can be accessed by using the data property of the object:

const response = await pnpd.db.getAll("seals");
console.log(response.data.rows); // -> logs an array of rows from the seals table