@elmony/supabase-management-js
v1.0.1
Published
Convenience wrapper for the Supabase Management API
Readme
@elmony/supabase-management-js
A convenience wrapper for the Supabase Management API, published for Elmony.
Status
The Supabase Management API is in beta. It is usable in its current state, but there may be breaking changes.
Installation
npm install @elmony/supabase-management-jsyarn add @elmony/supabase-management-jspnpm add @elmony/supabase-management-js@elmony/supabase-management-js requires Node.js 18 or newer because it relies on the native fetch client.
Authentication
Configure the SupabaseManagementAPI class with an access token, retrieved either through OAuth or by generating an API token in your account page.
import { SupabaseManagementAPI } from "@elmony/supabase-management-js";
const client = new SupabaseManagementAPI({ accessToken: "<access token>" });Usage
The SupabaseManagementAPI class exposes Management API endpoints as functions that return promises with typed response data.
import { SupabaseManagementAPI } from "@elmony/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. Use the exported isSupabaseError guard function to narrow unknown errors:
import {
SupabaseManagementAPI,
isSupabaseError,
} from "@elmony/supabase-management-js";
const client = new SupabaseManagementAPI({ accessToken: "<access token>" });
try {
await client.getProjects();
} catch (error) {
if (isSupabaseError(error)) {
console.log(
`Supabase Error: ${error.message}, response status: ${error.response.status}`,
);
}
}Publishing
This package is a scoped Elmony republish of the compiled Supabase Management wrapper.
cd packages/@elmony/supabase-management-js
npm publish --access public