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

lek-sessions-storage-sqlite-bun

v1.0.0

Published

Persistent SQLite storage for lek-sessions using bun:sqlite

Readme

lek-sessions-storage-sqlite-bun

Persistent SQLite storage for lek-sessions using Bun's built-in bun:sqlite.

Keeps sessions across restarts. No external dependencies — Bun ships its own SQLite.

Install

npm i lek-sessions-storage-sqlite-bun

Usage

const LekSessions = require("lek-sessions");
const SqliteStorage = require("lek-sessions-storage-sqlite-bun");

const storage = new SqliteStorage("./sessions.db");
const lek = new LekSessions("your-secret-key", { storage });

// Create session — stored in SQLite
const { access_token, refresh_token } = await lek.create("user-1", {
    metadata: { role: "admin" }
});

// Confirm — reads from SQLite
const result = await lek.confirm(access_token);
// → { success: true, id_subject: "user-1", metadata: { role: "admin" } }

// Refresh — updates keys in SQLite
const refreshed = await lek.refresh(refresh_token);

// Revoke — deletes or marks session
await lek.revoke(access_token);

// Close — cleanup timer + DB connection
await lek.close();

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | delete_on_revoke | boolean | true | When true, revoking a session deletes its row. When false, sets revoked=1 instead. | | auto_clean_up | boolean | true | Periodically removes expired and revoked sessions from the database. | | clean_up_interval | number | 3600000 | Milliseconds between clean-up runs (default: 1 hour). Only used if auto_clean_up is true. |

Example with options

const storage = new SqliteStorage("./sessions.db", {
    delete_on_revoke: false,     // keep revoked sessions (marked as revoked)
    auto_clean_up: true,
    clean_up_interval: 60000     // clean every minute
});

How it works

  • Uses bun:sqlite with WAL mode for concurrency.
  • The sessions table stores session data as BLOBs (id, keys) and TEXT (dates, metadata, subject).
  • auto_clean_up spawns a setInterval that deletes sessions where revoked=1 or both tokens expired.
  • Call close() to clear the interval and close the database cleanly.

License

ISC