- Clone repo locally: https://github.com/tuto4ki/crud-api
git clone [email protected]:tuto4ki/crud-api.git
- Go to branch
develop
git checkout develop
- To install all dependencies
npm install
- Run develop version
npm run start:dev
- Check server
POST/PUT requests with Postman:
send the request body
by selecting raw
and insert it into the field, for example:
{
"username": "Tamara",
"age": 64,
"hobbies": ["Music", "Dancing"]
}
-
Endpoint
api/users
:- GET
api/users
get all persons - GET
api/users/{userId}
get person with{userId}
- POST
api/users
create record about new user and store it in database - PUT
api/users/{userId}
update existing user - DELETE
api/users/{userId}
delete existing user from database
- GET
-
Users have following properties:
id
— unique identifier (string
,uuid
) generated on server sideusername
— user's name (string
, required)age
— user's age (number
, required)hobbies
— user's hobbies (array
ofstrings
or emptyarray
, required)
-
Requests to non-existing endpoints: server answer with
status code
404 and messageRoute not found
-
Errors on the server side that occur during the processing of a request: server answer with
status code
500 and messageServer error
-
There 2 modes of running application (development and production):
- The application is run in development mode
npm run start:dev
- The application is run in production mode
npm run start:prod