Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 4 : Create routes to update data (Chandra) #6

Open
Devopssquadtechire opened this issue Oct 14, 2021 · 0 comments
Open

Step 4 : Create routes to update data (Chandra) #6

Devopssquadtechire opened this issue Oct 14, 2021 · 0 comments

Comments

@Devopssquadtechire
Copy link
Owner

Finally, you will create routes to add new users and new schedules.

For this, you will have to create the following routes in POST :

‘/schedules’ to add a new schedule. It will return the newly created schedule.
‘/users’ (this time in POST!) to add a new user. It will return the newly created user. The user's password must be encrypted in SHA256.

To test these routes, you will need to make POST requests and send data as if there was a form.

This is done using the -X POST option (to specify that the request is in POST), combined with the -d option to specify the data attached to the request.

Here is an example of a command line session:

$> curl localhost:3000/users

[{"firstname":"James","lastname":"Bond","email":"james.bond@gmail.com","password":"b6b7fb4cad4bc020f76e16889a8e9065cb708d0f8c304a8a3db609b644da9536"},{"firstname":"Tony","lastname":"Stark","email":"starkrulz@gmail.com","password":"a836ebba36776b21dd0f5cdca497bff65c5bdfc8411cfbfe0111f27bde1c1894"},{"firstname":"Ali","lastname":"G","email":"nameisnotborat@gmail.com","password":"3b5fe14857124335bb8832cc602f8edcfa12db42be36b135bef5bca47e3f2b9c”}]

$> curl localhost:3000/users/3

$> curl -d "firstname=Donald&lastname=Duck&email=coincoin@gmail.com&password=daisy" -X POST localhost:3000/users

{"firstname":"Donald","lastname":"Duck","email":"coincoin@gmail.com","password":"QgKe8hUlb4+p/ttTVC7mVT7vdgJ7EW+PrFNGIRseRzw="}Mezards-MacBook-Pro:dmaiga laurie$

$> curl localhost:3000/users

[{"firstname":"James","lastname":"Bond","email":"james.bond@gmail.com","password":"b6b7fb4cad4bc020f76e16889a8e9065cb708d0f8c304a8a3db609b644da9536"},{"firstname":"Tony","lastname":"Stark","email":"starkrulz@gmail.com","password":"a836ebba36776b21dd0f5cdca497bff65c5bdfc8411cfbfe0111f27bde1c1894"},{"firstname":"Ali","lastname":"G","email":"nameisnotborat@gmail.com","password":"3b5fe14857124335bb8832cc602f8edcfa12db42be36b135bef5bca47e3f2b9c"},{"firstname":"Donald","lastname":"Duck","email":"coincoin@gmail.com","password":"QgKe8hUlb4+p/ttTVC7mVT7vdgJ7EW+PrFNGIRseRzw="}]

$> curl localhost:3000/users/3

{"firstname":"Donald","lastname":"Duck","email":"coincoin@gmail.com","password":"QgKe8hUlb4+p/ttTVC7mVT7vdgJ7EW+PrFNGIRseRzw=“}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant