To start the app:
-
Clone repo
-
Switch to dev branch
-
Run
npm ito install the dependencies. -
The app supports 2 modes of running application (development and production)
- To start app in dev mode please run
npm run start:dev - To start app in prod mode please run
npm run start:prod.
- To start app in dev mode please run
-
After running the app you can use. for example, Postman to send the request to the server.
With this server you can:
- receive all users using GET request and
api/userspath - receive user by id using GET request and
api/users/{userId}path. You can get the user id from GETapi/usersrequest. - add user to the server using POST request and
api/users.
You must specifyusername,ageandhobbiesproperties and put them into the body of your request
username(string, required)
age(number, required)
hobbies— (arrayofstringsor emptyarray, required)
for example
{ "username": "user", "age": 33, "hobbies": ["sport"] } - update user data using PUT request and
api\userspath. You need to specify all the fields as for POST request. - delete user using DELETE request and
api\users\{userId}path. You can get the user id from GETapi/usersrequest.
The server should answer with 400 and 404 codes if userId is invalid or user is missing or the path is not valid
API description
- GET
api/users- Success -
status code200 and all users records
- Success -
- GET
api/users/{userId}- Success -
status code200 and record withuserIdif it exists - Invalid
uuid-status code400 and corresponding message - User does not exist -
status code404 and corresponding message
- Success -
- POST
api/usersis used to create record about new user and store it in database- Success -
status code201 and newly created record - Missing required fileds
status code400 and corresponding message
- Success -
- PUT
api/users/{userId}is used to update existing user- Success
status code200 and updated record - Invalid
uuid-status code400 and corresponding message - User does not exist -
status code404 and corresponding message
- Success
- DELETE
api/users/{userId}is used to delete existing user from database- Success
status code204 if the record is found and deleted - Invalid
uuid-status code400 and corresponding message - Missing required fileds -
status code404 and corresponding message
- Success
Users are stored as objects that 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 (arrayofstringsor emptyarray, required)
Requests to non-existing endpoints (e.g. some-non/existing/resource) should answer with status code 404 and message