Coder Social home page Coder Social logo

users-crud's Introduction

Deployment

Just run docker compose up -d and Docker will set up database and web app on port 8080

Example API requests and responses

Create user

POST localhost:8080/api/v1/users

Content-Type: application/json

{
    "email": "[email protected]",
    "firstName": "David",
    "lastName": "Green",
    "birthDate": "2002-04-24",
    "address": "Lviv, Kyivska street, 3",
    "phoneNumber": "+380660000001"
}

Expected Response:

201 Created

Headers:
    Location=http://localhost:8080/api/v1/users/1

Get user by id

GET localhost:8080/api/v1/users/1

Expected Response:

200 OK

{
    "id": 1,
    "email": "[email protected]",
    "firstName": "David",
    "lastName": "Green",
    "birthDate": "2002-04-24",
    "address": "Lviv, Kyivska street, 3",
    "phoneNumber": "+380660000001"
}

Get users

Get all users with default 'from' and 'to' dates and default pagination settings i.e. from=0000-01-01, to=2100-01-01, page=0, size=20.

GET localhost:8080/api/v1/users

is the same as

GET localhost:8080/api/v1/users?from=0000-01-01&to=2100-01-01&page=0&size=20

Also sorting could be applied, f.e:

Sort by 'id' with descending order

GET localhost:8080/api/v1/users?sort=id,desc

or sort by 'lastName' and then sort by 'firstName'

GET localhost:8080/api/v1/users?sort=lastName&sort=firstName

Expected Response:

200 OK

[
    <<Users>>
]

Partial user update

PATCH localhost:8080/api/v1/users/1

Content-Type: application/json-patch+json

[
    {"op": "replace", "path": "/email", "value": "[email protected]"},
    {"op": "replace", "path": "/firstName", "value": "Diana"}
]

Expected Response:

200 OK

{
    "id": 1,
    "email": "[email protected]",
    "firstName": "Diana",
    "lastName": "Green",
    "birthDate": "2002-04-24",
    "address": "Lviv, Kyivska street, 3",
    "phoneNumber": "+380660000001"
}

Full user update

PATCH localhost:8080/api/v1/users/1

Content-Type: application/json-patch+json

[
    {"op": "replace", "path": "/email", "value": "[email protected]"},
    {"op": "replace", "path": "/firstName", "value": "Daniel"},
    {"op": "replace", "path": "/lastName", "value": "Yellow"},
    {"op": "replace", "path": "/birthDate", "value": "1990-12-21"},
    {"op": "replace", "path": "/address", "value": "City, Street, 1"},
    {"op": "remove", "path": "/phoneNumber"}
]

Expected Response:

200 OK

{
    "id": 1,
    "email": "[email protected]",
    "firstName": "Daniel",
    "lastName": "Yellow",
    "birthDate": "1990-12-21",
    "address": "City, Street, 1",
    "phoneNumber": null
}

Delete user

DELETE localhost:8080/api/v1/users/1

Expected Response:

204 No Content

users-crud's People

Contributors

xd6d avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.