Skip to content

Nox911PS/crude-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

To start the app:

  1. Clone repo

  2. Switch to dev branch

  3. Run npm i to install the dependencies.

  4. 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.
  5. 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/users path
  • receive user by id using GET request and api/users/{userId} path. You can get the user id from GET api/users request.
  • add user to the server using POST request and api/users.
    You must specify username, age and hobbies properties and put them into the body of your request
    username (string, required)
    age (number, required)
    hobbies — (array of strings or empty array, required)
    for example
    { "username": "user", "age": 33, "hobbies": ["sport"] }
  • update user data using PUT request and api\users path. 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 GET api/users request.

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 code 200 and all users records
  • GET api/users/{userId}
    • Success - status code 200 and record with userId if it exists
    • Invalid uuid - status code 400 and corresponding message
    • User does not exist - status code 404 and corresponding message
  • POST api/users is used to create record about new user and store it in database
    • Success - status code 201 and newly created record
    • Missing required fileds status code 400 and corresponding message
  • PUT api/users/{userId} is used to update existing user
    • Success status code 200 and updated record
    • Invalid uuid - status code 400 and corresponding message
    • User does not exist - status code 404 and corresponding message
  • DELETE api/users/{userId} is used to delete existing user from database
    • Success status code 204 if the record is found and deleted
    • Invalid uuid - status code 400 and corresponding message
    • Missing required fileds - status code 404 and corresponding message

Users are stored as objects that have following properties:

  • id — unique identifier (string, uuid) generated on server side
  • username — user's name (string, required)
  • age — user's age (number, required)
  • hobbies — user's hobbies (array of strings or empty array, required)

Requests to non-existing endpoints (e.g. some-non/existing/resource) should answer with status code 404 and message

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors