A basic template for Backend with Express, Prisma and TypeScript.
Method | Route | Body | Description |
---|---|---|---|
GET | /cats |
null |
Get all the cats. |
GET | /cats/:id |
null |
Get a cat by id. |
POST | /cats |
Body |
Create a cat. |
PATCH | /cats/:id |
Body |
Update a cat by id. |
DELETE | /cats/:id |
null |
Delete a cat by id. |
{
"name": "Catalina",
"age": 8,
"race": "Van turco", // idk
}
{
"name": "Catalina", // Optional
"age": 8, // Optional
"race": "Van turco", // Optional
}
-
Create a
.env
file with the following content:DATABASE_URL="Your database URL here"
-
Configure the Prisma provider (in
./prisma/schema.prisma
).datasource db { provider = "sqlite" ... }
-
Install the dependencies.
npm install # If you're using npm
yarn install # If you're using yarn
pnpm install # If you're using pnpm
bun install # If you're using bun
-
Migrate your prisma schema (Only if your use a SQL database).
npx prisma migrate dev --name init
-
Start the server
-
In development
npm run dev # or with yarn, pnpm, bun
-
In production
npm run build # Compile TS npm start
-