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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@purecore/supabase-emancipation

v1.0.5

Published

Drop-in replacement do Supabase Client para conexão direta com Postgres

Readme

Supabase Emancipation

Supalike - Drop-in replacement do Supabase Client para conexão direta com Postgres.

Este projeto fornece uma biblioteca TypeScript que replica a API do @supabase/supabase-js, mas conecta diretamente ao PostgreSQL em vez de usar o PostgREST. Ideal para aplicações backend que precisam de conexão direta ao banco.

🚀 Instalação

bun add pg dotenv
# ou
npm install pg dotenv

⚙️ Configuração

1. Configure o arquivo .env

Adicione a connection string do seu PostgreSQL no arquivo .env:

DATABASE_URL=postgresql://usuario:senha@localhost:5432/nome_do_banco

2. Crie o client

import { createClient } from "./index";
import { config } from "dotenv";

// Carrega variáveis do .env
config();

// Cria o client usando DATABASE_URL
const db = createClient(process.env.DATABASE_URL!);

📚 Exemplos de Uso

SELECT (Query)

const { data, error } = await db
  .from("users")
  .select("*")
  .eq("active", true)
  .limit(10);

INSERT

const { data, error } = await db
  .from("users")
  .insert({ name: "João", email: "[email protected]" })
  .single();

UPDATE

const { data, error } = await db
  .from("users")
  .update({ active: false })
  .eq("id", 1)
  .single();

DELETE

const { data, error } = await db.from("users").delete().eq("id", 1);

TRANSAÇÕES ✨

await db.transaction(async (tx) => {
  await tx.from("accounts").update({ balance: 100 }).eq("id", 1);
  await tx.from("accounts").update({ balance: 200 }).eq("id", 2);
  // Se qualquer operação falhar, TUDO é revertido
});

PAGINAÇÃO ✨

const { data, meta } = await db.from("products").select("*").paginate(1, 20); // Página 1, 20 itens

console.log(`Total: ${meta.total}, Última página: ${meta.lastPage}`);

CDC / REALTIME

// Inicializa CDC
await db.initializeCDC();

// Escuta mudanças na tabela 'users'
db.cdc.on("change:users", (event) => {
  console.log(event.eventType); // INSERT, UPDATE, DELETE
  console.log(event.new); // Dados novos
  console.log(event.old); // Dados antigos
});

📖 Mais Exemplos

Veja example.ts para exemplos completos de uso.

🗄️ Database Setup

Executar Migrations

Cria a estrutura do banco de dados (tabelas, índices, triggers):

bun run migrate
# ou
npm run migrate

As migrations SQL estão em migrations/. Atualmente inclui:

  • 001_create_usuarios.sql - Cria tabela usuarios com campos id, name, email, active, timestamps

Popular com Dados (Seed)

Insere dados de exemplo na tabela usuarios:

bun run seed
# ou
npm run seed

Setup Completo (Migrate + Seed)

bun run db:setup
# ou
npm run db:setup

📝 Changelog

Veja CHANGELOG.md para mudanças recentes.

🔧 Development

  • Install: bun install
  • Migrate: bun run migrate
  • Seed: bun run seed

⚠️ Importante

Esta biblioteca é para conexão direta com PostgreSQL. Se você está usando o Supabase com PostgREST, use o @supabase/supabase-js oficial.

🎯 Vantagens vs Supabase oficial

  1. Transações nativas: Suporte completo a BEGIN/COMMIT/ROLLBACK
  2. Paginação automática: .paginate() retorna metadados úteis
  3. Sem overhead de REST: Conexão direta = mais rápido
  4. CDC/Realtime nativo: Usando LISTEN/NOTIFY do Postgres