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

aroraql-client

v0.1.0

Published

Supabase-inspired, type-safe fluent query builder that turns chained calls into a JSON payload and POSTs it to your AroraQL endpoint

Readme

aroraql-client

Supabase-inspired, type-safe fluent query builder for the frontend. Chain calls, get a JSON payload, and let the client POST it to your AroraQL endpoint — results come back mapped to your types.

const employees = await arora
  .from<Employee>("Employees")
  .select("Id", "Name", "Department.Name")
  .where("Age")
  .gt(18)
  .where("Country")
  .eq("Egypt")
  .orderBy("Name")
  .asc()
  .take(50)
  .many(); // Employee[]
  • Zero dependencies — just fetch
  • Fully generic — field names and value types checked against your row type
  • Runs anywhere — Bun, Node 18+, and browsers

Install

bun add aroraql-client
# or
npm install aroraql-client

Setup

The client auto-detects the endpoint from the AroraQL_Api environment variable:

# .env
AroraQL_Api=https://api.example.com/query
import { createClient } from "aroraql-client";

const arora = createClient();

Or configure it explicitly (required in browsers, where env variables don't exist):

const arora = createClient({
  url: "https://api.example.com/query",
  headers: { authorization: `Bearer ${token}` }, // optional, sent on every request
});

Usage

Define your row type once and every part of the query is checked against it:

type Employee = {
  Id: number;
  Name: string;
  Age: number;
  Country: string;
  Department: { Name: string };
};

Fetch many rows

const rows = await arora
  .from<Employee>("Employees")
  .where("Age")
  .gte(18)
  .orderBy("Name")
  .asc()
  .many(); // Employee[]

Fetch a single row

// First match or null — never throws on "not found"
const employee = await arora
  .from<Employee>("Employees")
  .where("Id")
  .eq(42)
  .maybeSingle(); // Employee | null

// Exactly one row — throws unless precisely 1 match
const employee = await arora
  .from<Employee>("Employees")
  .where("Id")
  .eq(42)
  .single(); // Employee

Build without fetching

const payload = arora
  .from<Employee>("Employees")
  .select("Id", "Name")
  .where("Country")
  .eq("Egypt")
  .build();
// { from: "Employees", select: ["Id", "Name"],
//   where: [{ field: "Country", op: "=", value: "Egypt" }], orderBy: [] }

API

Query builder

| Method | Description | | ----------------------------------- | -------------------------------------------------------------------------------- | | .from<T>(table) | Start a query. T types everything downstream. | | .select(...fields) | Project fields. Supports dotted paths ("Department.Name"). Empty = all fields. | | .where(field) | Start a condition — follow with an operator (below). | | .orderBy(field).asc() / .desc() | Sort. Chain multiple for multi-field ordering. | | .take(n) | Limit the number of rows. |

Where operators

| Method | SQL equivalent | | ---------------------------- | ------------------------------------ | | .eq(value) | = | | .ne(value) | != | | .gt(value) / .gte(value) | > / >= | | .lt(value) / .lte(value) | < / <= | | .like(pattern) | LIKE (% any chars, _ one char) |

Operator values are typed as T[K]where("Age").eq("old") is a compile error.

Executors

| Method | Returns | Behavior | | ---------------- | -------------------- | --------------------------------------------------- | | .many() | Promise<T[]> | All matching rows. | | .maybeSingle() | Promise<T \| null> | First row or null. | | .single() | Promise<T> | Exactly one row — throws AroraQLError on 0 or 2+. | | .build() | QueryPayload | The raw JSON payload, no request made. |

Backend contract

The client sends a single POST with a JSON body:

{
  "from": "Employees",
  "select": ["Id", "Name", "Department.Name"],
  "where": [{ "field": "Age", "op": ">", "value": 18 }],
  "orderBy": [{ "field": "Name", "dir": "asc" }],
  "take": 50
}

Your endpoint maps this onto any data source and responds with:

{ "data": [ ... ] }

or, on failure (any status):

{ "error": "Unknown table: Employes" }

Errors are surfaced as AroraQLError (with .status). A minimal Bun endpoint:

import type { QueryPayload } from "aroraql-client";

Bun.serve({
  port: 3123,
  async fetch(req) {
    const payload = (await req.json()) as QueryPayload;
    return Response.json({ data: runQuery(payload) }); // map payload -> your DB
  },
});

All payload types (QueryPayload, WhereCondition, OrderByClause, Operator) are exported so your backend can share them.

License

MIT