Simple CRUD API with Express JS, Prisma ORM and PostgreSQL Database
- Clone this repository
git clone https://github.com/armandwipangestu/express-prisma
- Install dependency
cd express-prisma && pnpm install
- Create
.env
file
cp .env.development .env
NOTE: Fill
DATABASE_URL
with your database postgres, for exampleDATABASE_URL=postgresql://USER:PASSWORD@HOSTNAME:PORT/DBNAME
- Run this command to run Prisma Studio
pnpm dlx prisma studio
Open your web browser with url localhost:5555
, it will show like this
NOTE: If you add or edit file
schema.prisma
then you need to run this (to regenerate the schema)pnpm dlx prisma generate && pnpm dlx prisma db push
.
├── node_modules
├── package.json
├── pnpm-lock.yaml
├── prisma
│ └── schema.prisma
├── README.md
└── src
├── db
│ └── index.js
├── index.js
└── product
├── product.controller.js
├── product.repository.js
└── product.service.js
Endpoint | Method |
---|---|
/products |
GET |
/products/:id |
GET |
/products |
POST |
/products/:id |
DELETE |
/products/:id |
PUT |
/products/:id |
PATCH |