Skip to content

habtamu/node-prisma-api-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Node API

Sample API using Node, Prisma and Postgresql.

Tech Stack

Server: Node, Express, Prisma, PostgreSQL

Installation

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"
 },

API Reference

Get all jokes

  GET /
  example: http://127.0.0.1:3000/
           http://127.0.0.1:3000/?joke_id=ckph6po9l0000hse5sdrtby89

Get joke by id

  GET /:joke_id

  example: http://127.0.0.1:3000/ckph6po9l0000hse5sdrtby89
Parameter Type Description
joke_id string Required. joke_id of joke to fetch

Save joke

  POST /
  example: http://127.0.0.1:3000

  {
      text: "Joke ...",
      userId: "ckph6oqz700007ge5ia5d2klp",
  },

Remove a joke

  DELETE /
  example: http://127.0.0.1:3000/ckph6po9l0000hse5sdrtby89
Parameter Type Description
joke_id string Required. joke_id of joke to fetch

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published