Sample API using Node, Prisma and Postgresql.
Server: Node, Express, Prisma, PostgreSQL
Install main libraries with yarn
yarn init -y
yarn add express @prisma/client
Install development related packages:
yarn add -D typescript @types/node @types/express prisma ts-node-dev
For tsconfig.json file
npx typescript --init
which typescript
For prisma initialization:
npx prisma init
Prisma Migration commands:
npx prisma migrate dev
? Enter a name for the new migration: init
Prisma UI studio:
npx prisma studio
To run the node server:
"scripts": {
"dev": "ts-nod-dev server.ts"
},
GET /
example: http://127.0.0.1:3000/
http://127.0.0.1:3000/?joke_id=ckph6po9l0000hse5sdrtby89
GET /:joke_id
example: http://127.0.0.1:3000/ckph6po9l0000hse5sdrtby89
Parameter | Type | Description |
---|---|---|
joke_id |
string |
Required. joke_id of joke to fetch |
POST /
example: http://127.0.0.1:3000
{
text: "Joke ...",
userId: "ckph6oqz700007ge5ia5d2klp",
},
DELETE /
example: http://127.0.0.1:3000/ckph6po9l0000hse5sdrtby89
Parameter | Type | Description |
---|---|---|
joke_id |
string |
Required. joke_id of joke to fetch |