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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cattle-grid/account-api

v0.5.12

Published

The aim here is to create a client sdk for the cattle grid account api. This package is autogenerated using [@hey-api/openapi-ts](https://heyapi.dev/openapi-ts/get-started).

Downloads

126

Readme

cattle_grid account api sdk

The aim here is to create a client sdk for the cattle grid account api. This package is autogenerated using @hey-api/openapi-ts.

For background on cattle_grid, see here.

This API does not support event sources directly. For how to use them see Event Sources

Usage

Import the relevant methods and configure the client with the baseUrl.

import { signin, accountInfo } from "@cattle-grid/account-api";
import { client } from "@cattle-grid/account-api/client";

client.setConfig({
  baseUrl: "http://localhost:3001/fe",
});

Signin

One can sign in into an account with the account name and the corresponding password. For further requests, you will need the bearer token.

let result = await signin({ body: { name: "js", password: "js" } });

const bearerToken = result.data.token;

Setting the bearer token

This is done via:

client.interceptors.request.use(async (request) => { 
  request.headers.set("Authorization", "Bearer " + bearerToken);
  return request;
});

Getting account info

This can be done via

const result = await accountInfo();

The response data is in result.data the status code can be retrieved from result.response.status.

Furthermore methods can be discovered via sdk.gen.

Event Sources

As we use Bearer authentication, you cannot use a vanilla event source as provided by the browser. Instead, you have to use a polyfill such as extended-eventsource.

Once you have this, usage is like this

import { EventSource } from "extended-eventsource";

const eventSource = new EventSource(`/fe/account/stream/${eventType}`, {
  headers: {
    Authorization: `Bearer ${token}`,
  },
});


eventSource.addEventListener("message", (event) => {
  const parsed = JSON.parse(event.data);
  console.log(parsed);
});

Here eventType is one of incoming, outgoing, or error.