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

elysia-crud-plugin

v0.1.1

Published

Generate REST endpoints for your Drizzle tables without writing boilerplate. Inspired by Django Rest Framework's simplicity.

Readme

Elysia CRUD Plugin

Generate REST endpoints for your Drizzle tables without writing boilerplate. Inspired by Django Rest Framework's simplicity, this plugin creates full CRUD operations from your table definitions.

What it does

Pass a Drizzle table to the crud function, and you get five REST endpoints:

  • GET /{tableName} - List all records
  • GET /{tableName}/:id - Get one record
  • POST /{tableName} - Create a record
  • PUT /{tableName}/:id - Update a record
  • DELETE /{tableName}/:id - Delete a record

The plugin automatically detects your primary key, handles errors, and returns appropriate HTTP status codes.

Installation

bun add elysia-crud-plugin

You also need Elysia and Drizzle ORM:

bun add elysia drizzle-orm

Quick start

import { Elysia } from "elysia";
import { drizzle } from "drizzle-orm/bun-sqlite";
import { sqliteTable, integer, text } from "drizzle-orm/sqlite-core";
import { Database } from "bun:sqlite";
import { crud } from "elysia-crud-plugin";

// Define your table
const users = sqliteTable("users", {
  id: integer("id").primaryKey({ autoIncrement: true }),
  name: text("name").notNull(),
  email: text("email").notNull(),
});

// Set up database
const sqlite = new Database("example.db");
const db = drizzle(sqlite);

// Create your app
const app = new Elysia().decorate("db", db).use(crud(users)).listen(3000);

That's it. You now have working CRUD endpoints for users.

How it works

The plugin reads your Drizzle table definition to:

  1. Extract the table name for route generation
  2. Find the primary key column automatically
  3. Generate type-safe endpoints based on your table schema

You don't write route handlers, validation logic, or error handling. The plugin handles it.

Field selection

Control which fields appear in responses using the fields option:

app.use(crud(users, { fields: ["id", "name", "email"] }));

This returns only the specified fields in all responses. Useful for hiding sensitive data like passwords or internal fields.

Field selection affects responses only. All fields are still validated on create and update operations.

Database setup

The plugin expects a database instance decorated on your Elysia app. Use Elysia's decorate method:

const app = new Elysia().decorate("db", db).use(crud(users));

The plugin works with any database Drizzle supports: SQLite, PostgreSQL, MySQL, and others.

Error handling

The plugin handles common errors:

  • 404 Not Found - Record doesn't exist (GET, PUT, DELETE by ID)
  • 500 Internal Server Error - Database not configured or other server errors

Error responses include a JSON body with an error field:

{
  "error": "Resource not found"
}

Limitations

The current version focuses on core CRUD operations. It doesn't include:

  • Pagination for list endpoints
  • Filtering or sorting
  • Query parameter field selection
  • Lifecycle hooks
  • Custom validation beyond Drizzle schema

These may be added in future versions. For now, the plugin keeps things simple and focused.