This repository is a simple API using Prisma and TypeScript-based Node projects. The goal here is to get familiar with Prisma.
Clone the repo and install the dependencies.
git clone https://github.com/rodrigo-marcolino/prisma-starter.git
cd prisma-starter
npm i
Run the following command to create your SQLite database file. This also creates the Product
and Review
tables that are defined in prisma/schema.prisma
:
npx prisma migrate dev --name init
npm run start
The server is now running on http://localhost:3000
. You can now the API requests, e.g. http://localhost:3000/products
.
REST API endpoints:
/products
: Fetch all products./products/:id
: Fetch a single product by itsid
.
-
/products
: Add a new product.- Body:
name: String
: The product namedescription: String
: The product descriptionprice: Int
: The product price
- Body:
-
/reviews
: Add a new Review- Body:
text: String
: Review about the a specific productrating: Int
: The product ratingproductId: String
: The product id (cuid())
- Body:
-
/products/:id
: Delete a product by itsid