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

@livefolio/db

v0.1.9

Published

Database management library for Livefolio

Readme

@livefolio/db

Database management for Livefolio — Supabase migrations, schemas, edge functions, and shared TypeScript types.

Setup

npm install
npx supabase start

Copy .env.example to .env and fill in the values from npx supabase status:

cp .env.example .env
npx supabase status   # copy SUPABASE_URL, ANON_KEY, SERVICE_ROLE_KEY into .env

The FRED_API_KEY is needed for treasury/rate series (DTB3, DFF, DGS*, CPIAUCNS). Get a free key at https://fred.stlouisfed.org/docs/api/api_key.html.

Usage

Install in a consuming Node.js project:

npm install @livefolio/db
import type { Tables, Enums } from "@livefolio/db";

type Strategy = Tables<"strategies">;
type Frequency = Enums<"trading_frequency">;

The Constants export provides enum values as readonly arrays for runtime use:

import { Constants } from "@livefolio/db";

Constants.public.Enums.trading_frequency;
// ["Daily", "Weekly", "Monthly", "Quarterly", "Semiannually", "Yearly"]

Development

# Run all migrations and seeds against local DB
npx supabase db reset

# Regenerate TypeScript types after schema changes
npx supabase gen types typescript --local > src/database.types.ts

# Build the npm package (compiles src/ → dist/)
npm run build

Migrations

Create a new migration:

npx supabase migration new <name>

This creates a timestamped SQL file in supabase/migrations/. Write your DDL there, then run npx supabase db reset to apply.

Edge Functions

Edge functions live in supabase/functions/. Each function has its own deno.json for Deno configuration.

| Function | Description | |----------|-------------| | series | Cache-through daily price series (yahoo chart / FRED) | | quote | Real-time quote (yahoo quote API, falls back to series cache) | | strategy | Strategy resolution with testfol.io auto-import fallback |

Serve locally (loads secrets from .env):

npx supabase functions serve --env-file .env

Test:

# Run from monorepo root
deno test --no-check --allow-env --allow-net --allow-read db/supabase/functions/

Releasing

This package is published to the public npm registry. CI handles it automatically:

  1. On PR — migrations are dry-run against the remote DB, and CI verifies the version in package.json was bumped
  2. On merge to main — migrations are pushed to the remote DB, and the package is built and published to npm

Before merging a PR, bump the version:

npm version patch   # 0.1.0 → 0.1.1
npm version minor   # 0.1.1 → 0.2.0
npm version major   # 0.2.0 → 1.0.0

Project Structure

src/                        # TypeScript library (published to npm)
  index.ts                  # Re-exports types + Constants
  database.types.ts         # Auto-generated from Supabase schema
supabase/
  migrations/               # Timestamped SQL migrations (source of truth)
  schemas/                  # Numbered SQL files (human-readable reference)
  seeds/                    # Seed data (trading days calendar)
  functions/                # Supabase Edge Functions (Deno)
  templates/                # Email templates (magic link, email change)
  config.toml               # Local Supabase configuration