• Stars
    star
    253
  • Rank 160,776 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Full-featured CRUD routes for Next.js

Next Crud

NPM Version NPM License Github Actions

next-crud is a helper library that creates CRUD API routes with one simple function based on a Prisma model for Next.js.

Documentation

The documentation is available here

Overview

yarn add @premieroctet/next-crud

Given the following Prisma schema:

model User {
  id              Int        @id @default(autoincrement())
  name            String?
  email           String?
}

Create the file /pages/api/[...nextcrud].ts. with:

import NextCrud, { PrismaAdapter } from '@premieroctet/next-crud'
import { NextApiRequest, NextApiResponse } from 'next'

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
  const nextCrudHandler = await NextCrud({
    adapter: new PrismaAdapter({
      prismaClient: myPrismaClientInstance,
    }),
  })

  return nextCrudHandler(req, res)
}

export default handler

And get your full featured CRUD routes!

Endpoint Description
List GET /api/users Get all the users
Get GET /api/users/[id] Get one user
Add POST /api/users Create one user
Edit PUT /api/users/[id] Update one user
Partial edit PATCH /api/users/[id] Update one user (partial)
Delete DELETE/api/users/[id] Delete one user

Example

Open in CodeSandbox

Contributing

You can run the example project to test your modifications. Make sure to run yarn watch in the root folder.

More Repositories

1

openchakra

⚡️ Full-featured visual editor and code generator for React using Chakra UI
TypeScript
2,963
star
2

screen-guru

🔮 Screen Guru takes clean screenshot of any websites
TypeScript
516
star
3

next-admin

▲ Full-featured admin for Next.js and Prisma
TypeScript
297
star
4

reactivated-app

Reactivated.app is an open-source app that scans your JS dependencies every 4 hours and generates cool dashboards
TypeScript
69
star
5

firstcommit

🎈 Dig up the first commit of any GitHub repo
TypeScript
56
star
6

digestclub

The frontpage of teams knowledge 🧞‍♂️
TypeScript
44
star
7

gatsby-remark-images-zoom

👀 Bring medium-zoom to gatsby-remark-images
JavaScript
35
star
8

directus-extension-sql-panel

This is a custom interface for Directus that allows you to display result of your SQL queries in a table
TypeScript
21
star
9

react-native-video-controls

Controls elements and utilities for react-native video players (react-native-video, expo-av, etc.).
TypeScript
19
star
10

training-platform

A tool to build courses and training decks.
TypeScript
14
star
11

wonder-wheel

🎡 IKEA LUSTIGT Wheel of Fortune hack with Particle Photon + RFID
TypeScript
12
star
12

final-form-persist

🏁 Persist your final-form values into a storage
TypeScript
9
star
13

react-native-wallet

A React-Native wrapper for Apple PassKit and Google Wallet API
Java
9
star
14

ai-filter-demo

Let's see how to integrate a smart filtering system into a Next.js application using the Vercel AI SDK. The idea is to allow the user to filter data using a simple description.
TypeScript
6
star
15

react-native-core-ml-post

React Native project for CoreML + React Native blog post
Objective-C
5
star
16

react-workspaces

⚛ Yarn workspaces with React & React Native projects for blog post
PHP
3
star
17

escape-game

🐇 Follow the white rabbit
JavaScript
2
star
18

save-the-stickmans

GDScript
1
star
19

demo-maestro

TypeScript
1
star