
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
drizzle-rest-adapter
Advanced tools
A dynamic REST API adapter for Drizzle ORM with JSON-Server compatible query syntax
Transform your database schema into a REST API in seconds.
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.
beforeOperation
and afterOperation
hooksnpm install drizzle-rest-adapter
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.
# 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
# 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
# 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
# Single field ascending
GET /api/v1/users?_sort=name
# Single field descending
GET /api/v1/users?_sort=-created_at
# Embed related data
GET /api/v1/posts?_embed=author
GET /api/v1/posts?_embed=author,comments
Migrating from JSON-Server? The query syntax is 100% compatible:
Currently supports PostgreSQL databases:
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.
git clone https://github.com/mgaebler/drizzle-rest.git
cd drizzle-rest
npm install
npm run dev
npm test # Run all tests
npm run test:watch # Watch mode
npm run lint # Lint code
MIT License - see LICENSE file for details.
Made with ❤️ for the Drizzle community
FAQs
A dynamic REST API adapter for Drizzle ORM with JSON-Server compatible query syntax
The npm package drizzle-rest-adapter receives a total of 2 weekly downloads. As such, drizzle-rest-adapter popularity was classified as not popular.
We found that drizzle-rest-adapter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.