Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maximemoreillon/prisma-auto-crud
An express middleware that generates routes and CRUD controllers for every table defined in a prisma schema.
https://github.com/maximemoreillon/prisma-auto-crud
express expressjs nodejs prisma
Last synced: about 2 months ago
JSON representation
An express middleware that generates routes and CRUD controllers for every table defined in a prisma schema.
- Host: GitHub
- URL: https://github.com/maximemoreillon/prisma-auto-crud
- Owner: maximemoreillon
- License: mit
- Created: 2022-12-03T03:40:51.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-15T22:22:04.000Z (10 months ago)
- Last Synced: 2024-03-16T05:25:04.479Z (10 months ago)
- Topics: express, expressjs, nodejs, prisma
- Language: TypeScript
- Homepage:
- Size: 758 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Auto CRUD
[![coverage report](https://gitlab.com/moreillon_ci/moreillon_npm/prisma-auto-crud/badges/master/coverage.svg)](https://gitlab.com/moreillon_ci/moreillon_npm/prisma-auto-crud/-/commits/master)
At its core, Auto CRUD is an express middleware that generates routes and CRUD controllers for every table defined in a Prisma schema.
As such, it can be integrated in an existing Express app to kickstart a project involving CRUD.
On the other hand, if the functionalities of Auto CRUD can be used as is, it is also provided as a Docker container.## Usage as a module
### Install
This module can be installed using NPM:
```
npm install @moreillon/prisma-auto-crud
```### Usage
This module is intended to be used as an Express middleware.
```typescript
import express from "express"
import { PrismaClient } from "@prisma/client"
import autoCrud from "@moreillon/prisma-auto-crud"const prismaClient = new PrismaClient()
const { PORT = 7070 } = process.env
const app = express()
app.use(express.json())app.use(autoCrud(prismaClient))
app.listen(PORT, () => {
console.log(`[Express] Listening on port ${PORT}`)
})
```## Usage as a Docker container
If Auto CRUD does not need any additional customization, it can be deployed as a Docker container.
```bash
docker run \
-e DATABASE_URL="postgresql://user:pass@localhost:5432/db?schema=public" \
-p 8080:80 \
moreillon/auto-crud
```