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

@graphoria/server

v0.1.2

Published

Auto-generated GraphQL and REST APIs from database schema - Connect your database to modern APIs instantly

Readme

@graphoria/server

The runtime that powers Graphoria — schema introspection, GraphQL/REST handlers, JWT/PASETO authentication, RBAC, message queues, cron, remote schemas, and remote REST integration. This package is what you install into a Bun application to get a complete API server out of one configuration file.

Looking for the full guide? Start with the Quickstart, then dig into the topic-specific docs in docs/.

Install

bun add @graphoria/server

Installing the server package is enough: the runtime is exported from @graphoria/server and the configuration helpers + types from @graphoria/server/config.

Public API

import { createGraphQLEngine, createHandlers, createBunServer } from "@graphoria/server";

| Export | Use | | --------------------- | --------------------------------------------------------------------------------------------------------------------------- | | createBunServer | Spin up a Bun.serve server end-to-end. Returns { server, prefixes, execute }. | | createHandlers | Build the route map and websocket handler so you can compose them with your own server. Also returns execute. | | createGraphQLEngine | Run GraphQL queries in-process — no server. Returns { execute, roles, close }. execute bypasses auth (full privileges). |

createBunServer and createHandlers also return execute, the same in-process query runner as createGraphQLEngine, bound to the running server's schema.

One-call setup

import { createBunServer } from "@graphoria/server";

// JWT_SECRET and ADMIN_SECRET are read from the environment (see below).
const { server, prefixes } = await createBunServer({
  configuration: "./graphoria.ts",
  port: 3000,
});

Embedding into an existing Bun.serve

import { createHandlers } from "@graphoria/server";

const { serverHandlers } = await createHandlers({
  configuration: "./graphoria.ts",
});

Bun.serve({
  port: 3000,
  routes: { "/health": () => new Response("OK"), ...serverHandlers.routes },
  websocket: serverHandlers.websocket,
});

Running a query without a server

import { createGraphQLEngine } from "@graphoria/server";

const { execute, close } = await createGraphQLEngine({
  configuration: "./graphoria.ts",
});

// Defaults to the superadmin role (full privileges); pass { role } to scope it.
const result = await execute("query { users { id name } }");
console.log(result);

await close(); // release database connections

execute bypasses authentication — there is no token verification — so don't expose it to untrusted input. Because no HTTP request exists, operation init/beforeRequest hooks and header-derived session variables do not run.

Environment variables

The server reads a small set of environment variables. Every variable has a sensible default except JWT_SECRET (or PASETO equivalents) and ADMIN_SECRET, both of which are required.

| Variable | Default | Purpose | | ---------------------- | ------------------------------ | -------------------------------------------------------------------------- | | PORT | 3000 | HTTP port for createBunServer. | | JWT_SECRET | required | Symmetric secret for JWT signing. | | JWT_EXPIRES_IN | 5m | Access-token lifetime. | | JWT_RT_EXPIRES_IN | 7d | Refresh-token lifetime. | | PASETO_LOCAL_KEY | required for paseto_local | XChaCha20-Poly1305 key (k4.local.…). | | PASETO_SECRET_KEY | required for paseto_public | Ed25519 secret (k4.secret.…). | | PASETO_PUBLIC_KEY | required for paseto_public | Ed25519 public (k4.public.…). | | ADMIN_SECRET | required | Bypasses RBAC when sent in the admin header. | | REDIS_URL | redis://localhost:6379 | Refresh-token rotation + cache. | | GRAPHQL_API_ENDPOINT | /graphql | GraphQL endpoint path. | | REST_API_PREFIX | /rest | REST API prefix. | | GRAPHIQL_ENDPOINT | /graphiql | Built-in GraphiQL playground path. | | SCALAR_ENDPOINT | /scalar | Scalar API documentation path. | | OPENAPI_ENDPOINT | /openapi.json | OpenAPI document path. | | CORS_ENABLED | true | Toggle CORS preflight handler. | | MAX_QUERY_DEPTH | 0 (disabled) | Reject queries deeper than this — guard against abusive nested selections. |

The complete list lives in packages/server/src/types/env.ts.

Configuration helpers

Import the configuration helpers — plus ConfigurationFn and the config types — from @graphoria/server/config:

import type { ConfigurationFn } from "@graphoria/server/config";
import {
  operation,
  cron,
  z,
  queue,
  virtualColumnExpression,
  virtualColumnFunction,
  createOneToBooleanMSSQL,
  createYAndNToBooleanMSSQL,
} from "@graphoria/server/config";

See also