CRUD API
npm install
npm run start:dev
PORT=5000 or it can be changed in .env
npm run start:multi
npm run start:prod
npm run test
GET /api/users
status code 200 and all users records
POST /api/users
body: { username — user's name (string, required) age — user's age (number, required) hobbies — user's hobbies (array of strings or empty array, required) }
example {"username": "Andrey", "age":20, hobbies: []}
status code 201 and newly created record
body {"id":"uuid","username":"Andrey","age":20, hobbies: []}
status code 400 and corresponding message if request body does not contain required fields or fields are invalid
body 'Body does not contain required fields'
GET /api/users/${userId}
userId - valid uuid identifier
status code 200 and newly created record
{"id":"f8ccd33f-f817-4f09-89e1-99fdfde62157","username":"SomeName","age": 45, hobbies: ['flex']}
status code 400 and corresponding message if userId is invalid (not uuid)
User id ${idFromReq} is invalid
status code 404 and corresponding message if record with id === userId doesn't exist
User with id ${idFromReq} does not exist
PUT /api/users/${userId}
userId - valid uuid identifier
status code 200 and updated record
{"id":"f8ccd33f-f817-4f09-89e1-99fdfde62157","username":"NewName", "age": 15, hobbies: ["reading"]}
status code 400 and corresponding message if userId is invalid (not uuid)
Body User id ${idFromReq} is invalid
status code 400 and corresponding message if request body does not contain required fields or fields are invalid
Body Body does not contain required fields
status code 404 and corresponding message if record with id === userId doesn't exist
Body User with id ${idFromReq} does not exist
DELETE /api/users/${userId}
userId - valid uuid identifier
status code 204 if the record is found and deleted
status code 400 and corresponding message if userId is invalid (not uuid)
body User id ${idFromReq} is invalid
status code 404 and corresponding message if record with id === userId doesn't exist
body User with id ${idFromReq} does not exist
status code 500
'Internal Server Error'