jwdotjs / friend-app

Learning NestJS and Prisma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Friend App

Description

Nest framework TypeScript starter repository.

Installation and Initial Setup

$ yarn install

$ cp dev.env .env

$ docker-compose up -d
$ yarn migrate
$ yarn seed

Running the app

# development
$ yarn run start

# watch mode
$ yarn run start:dev

Testing The Routes

GET Routes

  • http://localhost:3000/users?take=5&skip=0 (note: no additional filters were supported here, but in production we would make this composable so any combination of filters could be applied)
  • http://localhost:3000/users/1
  • With an id from the first API response, apply that as a query string param to this endpoint: http://localhost:3000/friends?userId=1 (alternatively this could have been written as /users/1/friends)
  • Optionally, grab the id of a friend from the previous response and call http://localhost:3000/friends/distance?userId=1&friendId=2 (note: the max recursive depth is 5 and the system does not distinguish between the max depth being exceeded and there being no connected friends)

POST /users

curl --request POST \
  --url http://localhost:3000/users \
  --header 'Content-Type: application/json' \
  --data '{
	"email": "jason@walsh-web.com",
	"firstName": "Jason",
	"lastName": "Walsh"
}'

PATCH /users/:id

curl --request PATCH \
  --url http://localhost:3000/users/5001 \
  --header 'Content-Type: application/json' \
  --data '{
	"firstName": "Jay"
}'

DELETE /users/:id

curl --request DELETE \
  --url http://localhost:3000/users/5001 \
  --header 'Content-Type: application/json'

About

Learning NestJS and Prisma


Languages

Language:TypeScript 95.0%Language:JavaScript 5.0%