-
Notifications
You must be signed in to change notification settings - Fork 1
Backend API
POST
Logs a user in with the given credentials.
Expects a json body containing the login credentials.
{
"username": "leinecker01",
"password": "foobar"
}Returns 200 OK and sets a token cookie on success.
Returns 401 Unauthorized if the login fails.
POST
Logs a user out with the given token.
Expects the user is logged in and the token cookie is set.
Returns 200 OK if the user was logged out.
Returns 401 Unauthorized if the token is malformed.
POST
Creates an account for the given credentials.
Expects a json body containing the login credentials.
{
"username": "leinecker01",
"password": "foobar"
}Returns 200 OK and sets the token cookie.
Returns 409 Conflict if a user already exists with that username.
GET
Gets all the contacts associated with the given login token.
Expects the token cookie to be correctly set.
Returns 200 OK and a json list of the contacts for the given token if logged in.
[
{
"id": "1j4Fqp",
"firstName": "bob",
"lastName": "dole",
"phoneNumber": "4075559999",
"email": "dummy@fakemail.net"
},
{
"id": "2rjp1Pq",
"firstName": "jim",
"lastName": "henson",
"phoneNumber": "4075558888",
"email": "elmo@fakemail.net"
}
]Returns 401 Unauthorized if the login token is malformed or expired.
POST
Creates a new contact in the database for the user corresponding to the given login token.
Expects a json body containing a single new contact for the logged in user and a valid token cookie.
{
"firstName": "bob",
"lastName": "dole",
"phoneNumber": "4075559999",
"email": "dummy@fakemail.net"
}Returns a json body containing the id of the created contact.
{
"id": "1j4Fqp"
}Returns 401 Unauthorized if the login token is malformed or expired.
DELETE
Deletes a contact with the given id.
Expects the token cookie to be correctly set.
Returns 200 OK on successful deletion.
Returns 401 Unauthorized if the login token is malformed or expired.
Returns 404 Not Found if no contact exists with the given id for the logged in user.
PUT
Updates a contact with given id.
Expects a json body containing the contact's updated details and a valid token cookie.
{
"firstName": "bob",
"lastName": "dole",
"phoneNumber": "4075559999",
"email": "dummy@fakemail.net"
}Returns 200 OK on successful update.
Returns 401 Unauthorized if the login token is malformed or expired.
Returns 404 Not Found if no contact exists with the given id for the logged in user.