https://insomnia.rest/download/
$ npm run start:dev
$ cd app/api
$ nest generate controller coffees
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees/flavors
returns
This action returns all coffees
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees/123
returns
This action return #123 coffee
$ curl \
-H "Content-Type: application/json" \
-X GET 'http://localhost:3000/coffees/flavors?limit=20&offset=10'
Returns:
This action returns all coffees. Limit: 20, Offset: 10
$ nest generate service coffees
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees/1 \
| python3 -m json.tool
returns
{
"id": 1,
"name": "Shipwreck Roast",
"brand": "Buddy Brew",
"flavors": [
"chocolate",
"vanilla"
]
}
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees/2 \
| python3 -m json.tool
Returns:
{
"statusCode": 404,
"message": "Coffee #2 not found",
"error": "Not Found"
}
$ nest generate module coffees
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees/1 \
| python3 -m json.tool
returns:
{
"id": 1,
"name": "Shipwreck Roast",
"brand": "Buddy Brew",
"flavors": [
"chocolate",
"vanilla"
]
}
$ nest generate class coffees/dto/create-coffee.dto --no-spec
$ nest generate class coffees/dto/update-coffee.dto --no-spec
$ npm install class-validator class-transformer
$ npm install @nestjs/mapped-types
Marley
Any questions in english: Telegram Chat
Любые вопросы на русском: Телеграм чат