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

supabase-management-js

v1.0.0

Published

Convenience wrapper for the Supabase Management API

Downloads

6,331

Readme

supabase-management-js

A convenience wrapper for the Supabase Management API written in TypeScript.

Status

The Management API is in beta. It is usable in it's current state, but it's likely that there will be breaking changes.

Installation

To install supabase-management-js in a Node.js project:

npm install supabase-management-js

supabase-management-js requires Node.js 18 and above because it relies on the native fetch client.

Authentication

You can configure the SupabaseManagementAPI class with an access token, retrieved either through OAuth or by generating an API token in your account page. Your API tokens carry the same privileges as your user account, so be sure to keep it secret.

import { SupabaseManagementAPI } from "supabase-management-js";

const client = new SupabaseManagementAPI({ accessToken: "<access token>" });

Usage

The SupabaseManagementAPI class exposes each API endpoint of the Management API as a function that returns a Promise with the corresponding response data type.

import { SupabaseManagementAPI } from "supabase-management-js";

const client = new SupabaseManagementAPI({ accessToken: "<access token>" });

const projects = await client.getProjects();

if (projects) {
  console.log(`Found ${projects.length} projects`);
}

Handling errors

Response errors are thrown as an instance of SupabaseManagementAPIError which is a subclass of Error. You can use the exported isSupabaseError guard function to narrow the type of an unknown error object:

import { SupabaseManagementAPI, isSupabaseError } from "supabase-management-js";

const client = new SupabaseManagementAPI({ accessToken: "<access token>" });

try {
  await client.getProjects();
} catch (error) {
  if (isSupabaseError(error)) {
    // error is now typed as SupabaseManagementAPI
    console.log(
      `Supabase Error:  ${error.message}, response status: ${error.response.status}`
    );
  }
}

Contributing

Contributions to this project are very welcome and greatly appreciated!

  1. Clone the repo into a public GitHub repo (or fork https://github.com/supabase-community/supabase-management-js/fork).

  2. Go to the project folder.

cd supabase-management-js
  1. Install packages with npm:
npm install
  1. Make your changes

  2. Make sure types are correct

npm run typecheck
  1. Create a changeset to describe your changes if you are making changes to the source code that effects its public API
npm exec changeset
  1. Create a branch, commit your changes, and open a Pull Request against the main branch in this repo.

Regenerating types

The v1.d.ts file is auto-generated based on the Supabase OpenAPI spec file with the following command:

npm run generate