You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

drizzle-rest-adapter

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drizzle-rest-adapter

A dynamic REST API adapter for Drizzle ORM with JSON-Server compatible query syntax

0.1.2-alpha.3
alpha
latest
Source
npmnpm
Version published
Weekly downloads
8
-97.5%
Maintainers
1
Weekly downloads
 
Created
Source

Drizzle REST

Transform your database schema into a REST API in seconds.

CI TypeScript License: MIT npm version Alpha Release

A dynamic REST API adapter for Drizzle ORM with JSON-Server compatible query syntax

⚠️ Alpha Release: This project is in active development. APIs may change and features are still being finalized. Use in production at your own risk.

Transform your Drizzle schema into a fully functional REST API with a single function call. Perfect for rapid prototyping, admin panels, and seamless migration from JSON-Server.

✨ Features

  • 🚀 Zero Configuration: Generate REST endpoints from your Drizzle schema instantly
  • 🔍 JSON-Server Compatible: Familiar query syntax for filtering, sorting, and pagination
  • 🎣 Hook System: Authorization, data transformation, and custom logic with beforeOperation and afterOperation hooks
  • 🗄️ PostgreSQL Support: Full PostgreSQL database support

📦 Installation

npm install drizzle-rest-adapter

🚀 Quick Start

import express from 'express';
import { createDrizzleRestAdapter } from 'drizzle-rest-adapter';
import { db } from './db/connection'; // Your Drizzle instance
import * as schema from './db/schema'; // Your Drizzle schema

const app = express();
app.use(express.json());

// Create the REST API adapter
const apiRouter = createDrizzleRestAdapter({
  db: db,
  schema: schema,
});

// Mount the generated API
app.use('/api/v1', apiRouter);

app.listen(3000, () => {
  console.log('REST API running on http://localhost:3000/api/v1');
});

That's it! Your API is now available with full CRUD operations for all tables in your schema.

📖 API Usage

Basic CRUD Operations

# Get all users
GET /api/v1/users

# Get user by ID
GET /api/v1/users/123

# Create new user
POST /api/v1/users
Content-Type: application/json
{ "name": "John Doe", "email": "john@example.com" }

# Update user (partial)
PATCH /api/v1/users/123
Content-Type: application/json
{ "name": "Jane Doe" }

# Replace user (complete)
PUT /api/v1/users/123
Content-Type: application/json
{ "name": "Jane Doe", "email": "jane@example.com" }

# Delete user
DELETE /api/v1/users/123

Filtering

# Direct equality
GET /api/v1/users?status=active

# Range filters
GET /api/v1/users?age_gte=18&age_lte=65

# String search (substring)
GET /api/v1/users?name_like=John

# Negation
GET /api/v1/users?status_ne=inactive

# Array membership (multiple IDs)
GET /api/v1/users?id=1&id=2&id=3

Pagination

# Page-based pagination
GET /api/v1/users?_page=2&_per_page=25

# Range-based pagination
GET /api/v1/users?_start=10&_end=20
GET /api/v1/users?_start=10&_limit=10

Sorting

# Single field ascending
GET /api/v1/users?_sort=name

# Single field descending
GET /api/v1/users?_sort=-created_at

Relationships

# Embed related data
GET /api/v1/posts?_embed=author
GET /api/v1/posts?_embed=author,comments

🎯 JSON-Server Migration

Migrating from JSON-Server? The query syntax is 100% compatible:

🗄️ Database Support

Currently supports PostgreSQL databases:

  • PostgreSQL (PGlite and standard PostgreSQL)

🤝 Contributing

We welcome contributions! This is an alpha project, so expect rapid changes and improvements.

Alpha Contributors Welcome: Since this is an alpha release, your feedback and contributions are especially valuable in shaping the final API.

Please see CONTRIBUTING.md for guidelines.

Development Setup

git clone https://github.com/mgaebler/drizzle-rest.git
cd drizzle-rest
npm install
npm run dev

Running Tests

npm test          # Run all tests
npm run test:watch # Watch mode
npm run lint      # Lint code

📄 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments

Made with ❤️ for the Drizzle community

Keywords

drizzle

FAQs

Package last updated on 21 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts