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

@zapi-x/core

v0.1.0-beta.3

Published

Zero to API in seconds - Entity-first, type-safe API framework

Readme

Zapi

Zero to API in seconds - Entity-first, type-safe API framework

Beta npm version License: MIT

⚠️ Beta Software: APIs may change before v1.0. Use in production at your own risk.

Features

  • 🚀 Entity-first - Define your entities, get your API
  • 🔒 Type-safe - Full TypeScript support with inference
  • 🔌 Framework agnostic - Express, Hono, and more
  • 🗄️ Database agnostic - Prisma, and more coming
  • 🧩 Plugin system - Auth, timestamps, and custom plugins
  • Zero config - Sensible defaults, override when needed

Installation

npm install @zapi-x/core
# or
pnpm add @zapi-x/core

Quick Start

import { entity, string, text, belongsTo } from "@zapi-x/core"
import { zapi } from "@zapi-x/core"

// 1. Define entities
const user = entity("user", {
  email: string.unique(),
  name: string.min(1).max(100),
})
  .build()

const post = entity("post", {
  title: string,
  content: text,
  author: belongsTo(() => user),
})
  .ownedBy("author")
  .build()

// 2. Mount to your framework (Express + Prisma example)
import express from "express"
import { expressAdapter, expressDevAuth } from "@zapi-x/core/adapters/express"
import { prisma } from "@zapi-x/core/drivers/prisma"
import { PrismaClient } from "@prisma/client"

const app = express()
const prisma = new PrismaClient()

const api = zapi({
  entities: [user, post],
  driver: prisma(prisma),
})

app.use("/api", expressAdapter(api, { getUser: expressDevAuth, cors: true }))

app.listen(3000)

Entity DSL

import { entity, string, text, int, bool, datetime, belongsTo, hasMany } from "@zapi-x/core"

const task = entity("task", {
  // String fields
  title: string.min(1).max(200),
  description: text.optional(),
  
  // Other types
  priority: int.default(0).min(0).max(3),
  completed: bool.default(false),
  dueDate: datetime.optional(),
  
  // Relations
  project: belongsTo(() => project),
  assignee: belongsTo(() => user),
})
  .ownedBy("assignee")  // Auto-set owner on create
  .rules({
    create: ["authenticated"],
    read: ["everyone"],
    update: ["owner", "admin"],
    delete: ["admin"],
  })
  .build()

Adapters

Import only what you need:

// Express
import { expressAdapter, expressDevAuth, expressJwtAuth } from "zapi/adapters/express"

// Hono
import { honoAdapter, honoDevAuth, honoJwtAuth, cookieAuth } from "zapi/adapters/hono"

Drivers

// Prisma
import { prisma } from "zapi/drivers/prisma"

Plugins

// Timestamps (adds createdAt/updatedAt globally)
import { timestamps } from "zapi/plugins/timestamps"

// Auth helpers are provided via adapters (dev/jwt) to keep Zapi auth-agnostic
// import { expressDevAuth, expressJwtAuth } from "zapi/adapters/express"

Generated Files

Use the generator to create Prisma schema, TypeScript types, and API client:

import { generate } from "@zapi-x/generator"
import { entities } from "./entities"

generate(entities, {
  outDir: "./generated",
  prismaProvider: "sqlite",
})

This generates:

  • generated/prisma/schema.prisma - Prisma schema
  • generated/types.ts - TypeScript interfaces
  • generated/client.ts - Type-safe API client

API Endpoints

For each entity, zapi generates:

| Method | Endpoint | Description | |--------|----------|-------------| | GET | /users | List with filter/sort/pagination | | POST | /users | Create | | GET | /users/:id | Get by ID | | PUT | /users/:id | Update | | DELETE | /users/:id | Delete |

Query Parameters

# Filtering
GET /users?filter[role]=admin

# Sorting
GET /posts?sort=-createdAt

# Pagination
GET /posts?limit=10&offset=20

# Include relations
GET /posts?include=author

License

MIT © 2025