1.1.2 • Published 1 year ago
@jigolka/next-crud v1.1.2
Next Crud
What is Next Crud ?
Next Crud is an api wrapper for Next.js and Prisma that handle automatically CRUD endpoints.
Documenation
You can access the full documentation at next-crud-docs.vercel.app
Getting started
npm install @jigolka/next-crud
Given this specific schema:
model User {
id String @id @default(cuid())
name String
email String
}
Paste the following snippet to get you started:
// pages/api/[...crud].ts
import ApiWrapper from "@jigolka/next-crud"
import { PrismaClient } from "@prisma/client"
export default ApiWrapper({
prismaInstance: new PrismaClient(),
})
This will generate these differents endpoints:
Endpoint | Description |
---|---|
GET /api/user | Get all the users |
GET /api/user/[id] | Get one user |
POST /api/user | Create one user |
PATCH /api/user/[id] | Update one user |
DELETE/api/user/[id] | Delete one user |
Contributing
Pull requests are welcome!