The name is pretty self explanatory.
You track what you borrowed. (also what other people borrowed from you)
Especially helpful if you're forgetful.
An interface used to represent a user. Included in responses if the requesting user is the user itself.
name
username
email
password
: is always empty in responsesprofilePicture
: as a stringbio
amountOwed
: amount of money the user has lended to other usersamountOwing
: amount of money the user has borrowed from other usersdebts
: a list containing the ids of active debts associated with the userhistory
: a list containing the ids of paid (or declined if the user is the borrower but not if the user is the lender) debts associated with the user_id
: id of the user
Represents users but contains less information than userInterface
name
username
email
profilePicture
: as a stringbio
_id
: id of the user associated with this profile
An interface used to represent a debt
lender
: id of the lending userborrower
: id of the borrowing useramount
description
requestedDate
: date object of when it was requested in UTCapprovedDate
: date object of when it was approved in UTC (present only if the debt has been approved)declinedDate
: date object of when it was declined in UTC (present only if the debt has been declined)paidDate
: date object of when it was confirmed to be paid in UTC (present only if the debt has been confirmed)status
: is one of the following'pending'
,'approved'
,'declined'
or'paid'
paid
: boolean value representing whether it has been paid or not (true for paid)_id
: id of the debt
Allows the creation and authentication of user accounts.
Checks if a username is available for registration.
- URL:
/auth/checkUsername/:username
- Method: GET
username
: The username to check.
- Code: 200
- Content:
{ "message": "Username is available." }
-
Code: 400
-
Content:
{ "message": "Please enter a username." }
-
Code: 400
-
Content:
{ "message": "Username must be at least 3 characters long." }
-
Code: 400
-
Content:
{ "message": "Username already exists." }
-
Code: 500
-
Content:
{ "message": "Internal server error." }
Registers a new user account.
- URL:
/auth/signup
- Method: POST
name
: The name of the new user.username
: The username for the new user.email
: The email address for the new user.password
: The password for the new user.
- Code: 201
- Content:
{ "user": UserInterface, "token": string }
Authenticates a user and returns a JWT token.
- URL:
/auth/signin
- Method: POST
usernameOrEmail
: The username or email address of the user to authenticate.password
: The password of the user to authenticate.remember
: A boolean indicating whether to remember the user's session. If it is set to true, token will be valid for 7 days otherwise for 2 hours.
- Code: 201
- Content:
{ "user": UserInterface, "token": string }
Allows managing users
Returns a list of users
- URL:
/user
- Method: GET
authorization
:bearer {token}
- Code: 200
- Content:
[ Profile ]
Returns a user object representing the requesting user
- URL:
/user/me
- Method: GET
authorization
:bearer {token}
- Code: 200
- Content:
UserInterface
Returns a profile object of the user with the provided id
- URL:
/user/id/:id
- Method: GET
authorization
:bearer {token}
id
: user id of the required user
- Code: 200
- Content:
Profile
Returns a profile object of the user with the provided username
- URL:
/user/username/:username
- Method: GET
authorization
:bearer {token}
username
: username of the required user
- Code: 200
- Content:
Profile
Returns a list of profile objects of users whose usernames contain the given username
parameter
- URL:
/user/search/:username
- Method: GET
authorization
:bearer {token}
username
: username or substring of username
- Code: 200
- Content:
[Profile]
Edit the profile of a user
- URL:
/user/edit
- Method: PATCH
authorization
:bearer {token}
All are optional. Only include ones you want to edit
username
name
email
profilePicture
in string format
- Code: 200
- Content:
UserInterface
of the new edited user
Allows to change the password of the requesting user
- URL:
/user/changePassword
- Method: PATCH
authorization
:bearer {token}
oldPassword
: The old password of the usernewPassword
: The new password the user wants to change to
- Code: 200
- Content:
{ message: 'Password changed successfully.' }
Allows to delete the account of the requesting user
- URL:
/user/delete
- Method: DELETE
authorization
:bearer {token}
- Code: 200
- Content:
{ message: 'User deleted successfully.' }
Managing debts
Returns all the debts associated with the requesting user
- URL:
/debt
- Method: GET
authorization
:bearer {token}
- Code: 200
- Content:
[DebtInterface]
Returns the debt with the given id
- URL:
debt/:id
- Method: GET
- Requesting user must be either the
borrower
or thelender
of the debt
authorization
:bearer {token}
id
: id of the requiered debt
- Code: 200
- Content:
DebtInterface
Creates a debt request
- URL:
/debt/request
- Method: POST
authorization
:bearer {token}
lenderId
: id of the user the debt is being requested from (the lender)amount
: amount of moneydescription
- Code: 201
- Content:
DebtInterface
of the newly created debt
Allows to approve (accept) a debt request
- URL:
/debt/approve/:debtId
- Method: PATCH
- Requesting user must be
lender
of the debt - The status of the debt must be
'pending'
authorization
:bearer {token}
debtId
: id of the debt to be approved
- Code: 200
- Content:
{ message: "Debt approved." }
Allows to decline a debt request
- URL:
/debt/decline/:debtId
- Method: PATCH
- Requesting user must be
lender
of the debt - The status of the debt must be
'pending'
authorization
:bearer {token}
debtId
: id of the debt to be declined
- Code: 200
- Content:
{ message: "Debt declined." }
Allows to confirm that the debt has been paid
- URL:
/debt/confirm/:debtId
- Method: PATCH
- Requesting user must be
lender
of the debt - The status of the debt must be
'approved'
authorization
:bearer {token}
debtId
: id of the debt to be confirmed
- Code: 200
- Content:
{ message: "Debt paid." }
Allows to delete a debt request that hasn't yet been approved
- URL:
/debt/deleteRequest/:debtId
- Method: Delete
- Requesting user must be
borrower
of the debt - The status of the debt must be
'pending'
authorization
:bearer {token}
debtId
: id of the debt to be deleted
- Code: 200
- Content:
{ message: "Debt deleted." }
Allows to delete a debt that has been approved
- URL:
/debt/deleteApproved/:debtId
- Method: Delete
- Requesting user must be
lender
of the debt - The status of the debt must be
'approved'
authorization
:bearer {token}
debtId
: id of the debt to be deleted
- Code: 200
- Content:
{ message: "Debt deleted." }