Run npm i
to install dependencies
Setup a .env file according to the .env.sample file
Run npm start
to start development server
This document outlines the available API endpoints in our backend service. All routes return an HTTPError with relevant status and a json body containing message
on error.
Server runs on PORT 3010 by default.
- Endpoint:
POST /api/users
- Request Body: JSON object containing:
email
(required, string)password
(required, string)name
(required, string)dob
(required, Date - yyyy-mm-dd)gender
(required, sring - one of "female", "male", "other")tel
(optional, number)timezone
(optional, string)
- Response: JSON object containing:
message: 'User successfully created and verification email sent sucessfully'
Note: Signup endpoint also sends and email with a link for email verification
- Endpoint:
POST /api/users/login
- Request Body: JSON object containing:
email
(required, string)password
(required, string)
- Response: JSON object containing:
accessToken
- Cookies
refreshToken
(httpOnly)
- Endpoint:
POST /api/users/mobile/login
- Request Body: JSON object containing:
email
(required, string)password
(required, string)
- Response: JSON object containing:
accessToken
refreshToken
- Endpoint:
POST /api/users/verify-email
- Request Body: JSON object containing:
token
(required, string)
- Response: JSON object containing:
message: 'User\'s email was verified successfully'
- Endpoint:
POST /api/users/resend-email
- Request Body: JSON object containing:
token
(optional, string)email
(optional, string)
- Response: JSON object containing:
message: 'Email resent successfully'
Note: Endpoint accepts token or email
- Endpoint:
POST /api/users/forgot-password
- Request Body: JSON object containing:
email
(required, string)
- Response: JSON object containing:
message: 'Password reset email sent successfully'
- Endpoint:
POST /api/users/reset-password
- Request Body: JSON object containing:
token
(required, string)newPassword
(required, string)confirmNewPassword
(required, string)
- Response: JSON object containing:
message: 'User\'s password reset successfully'
Note: All the routes below expect an Authorization
header with a Bearer token.
- Endpoint:
POST /api/users/refresh
- Authorization: Bearer Token
- Request Body: JSON object containing:
device
(required, string)refresh
(optional, string)
- Response:
- For mobile: JSON object containing:
accessToken
refreshToken
- For web:
- Cookies
refreshToken
(httpOnly)
- JSON object containing:
accessToken
- Cookies
- For mobile: JSON object containing:
- Endpoint:
GET /api/users/logout
- Authorization: Bearer Token
- Response: JSON object containing:
message: 'Cookie cleared'
- Endpoint:
PUT /api/users/password
- Authorization: Bearer Token
- Request Body: JSON object containing:
oldPassword
(required, string)newPassword
(required, string)
- Endpoint:
DELETE /api/users
- Authorization: Bearer Token
- Response: JSON object containing:
confirmationToken
- Endpoint:
POST /api/confirm-delete
- Authorization: Bearer Token
- Request Body: JSON object containing:
confirmationToken
(required, string)
- Side Effect: Deletes associated UserProfile
- Endpoint:
GET /api/users/profile
- Authorization: Bearer Token
- Response: JSON object containing:
profile
- Endpoint:
PUT /api/users/profile
- Authorization: Bearer Token
- Request Body: JSON object containing (any of):
interests
(optional, string[])bio
(optional, string)timezone
(optional, string)name
(optional, string)tel
(optional, number)gender
(optional, string)dob
(optional, string)timezone
(optional, string)emailNotifications
(optional, boolean)pushNotifications
(optional, boolean)
- Response: JSON object containing:
message: "User profile updated"
profile
- Endpoint:
POST /api/users/profile/upload
- Authorization: Bearer Token
- Request Body: Form-data containing:
photo
(required, File)
- Response: JSON object containing:
message: "Photo uploaded successfully"
photoUrl
Note: The photo upload utilizes AWS S3 for storage.
- Endpoint:
GET /api/friends
- Authorization: Bearer Token
- Response: JSON object containing:
today: friend[], thisWeek: friend[], thisMonth: friend[], laterOn: friend[]
- Endpoint:
POST /api/friends/create
- Authorization: Bearer Token
- Request Body: JSON object containing:
name
(required, string)dob
(required, Date - yyyy-mm-dd)gender
(required, string - one of "female", "male", "other")location
(optional, string)bio
(optional, string)interests
(optional, string[])tags
(optional, string[] - objectIds)giftPreferences
(optional, string[])
- Response: JSON object containing:
newFriend
- Endpoint:
POST /api/friends/:id/upload
- Authorization: Bearer Token
- Request Body: Form-data containing:
photo
(required, File)
- Response: JSON object containing:
message: "Photo uploaded successfully"
photoUrl
- Endpoint:
POST /api/friends/:id
- Authorization: Bearer Token
- Response: JSON object containing:
friend
- Endpoint:
DELETE /api/friends/:id/delete
- Authorization: Bearer Token
- Response: JSON object containing:
message: 'Friend deleted successfully'
- Endpoint:
PUT /api/friends/:id/update
- Authorization: Bearer Token
- Request Body: JSON object containing:
name
(optional, string)dob
(optional, Date - yyyy-mm-dd)location
(optional, string)bio
(optional, string)interests
(optional, string[])tags
(optional, string[] - objectIds)giftPreferences
(optional, string[])gender
(optional, string - one of "female", "male", "other")
- Response: JSON object containing:
message: 'Friend updated'
Note: tags and giftPreferences are not checked for duplicate entries at this endpoint.
- Endpoint:
GET /api/friends/birthdays
- Authorization: Bearer Token
- Response: JSON object containing:
mm-dd
(represents friend dob): friend[]
- Endpoint:
POST /api/friends/:id/tags
- Authorization: Bearer Token
- Request Body: JSON array containing:
- JSON object containing:
_id
(required, string - ID of existing tag)title
(required, string - title of existing tag)type
(required, string - type of existing tag)
- OR:
title
(required, string - title of new tag)
- JSON object containing:
- Response: JSON object containing:
message: 'Tags updated successfully'
Note: This endpoint associates an existing tag with the friend, or creates a new tag and associates with the friend
- Endpoint:
POST /api/friends/:id/generate-gift
- Authorization: Bearer Token
- Request Body: JSON object containing:
giftTypes
(required, string[] - must be known to the backend. Currently "present", "donation" and "experience" are accepted)tags
(required, string[] - names of tags to be sent with the query)budget
(optional, number - recommendations will try to be below this amount)
- Response: JSON object containing:
recommendations
message: 'Gift recommendations generated'
- Endpoint:
POST /api/friends/:id/favorites
- Authorization: Bearer Token
- Request Body: JSON object containing:
title
(required, string)reason
(required, string)imgSrc
(required, string - link of thumbnail image)giftType
(required, string - one of 'present', 'experience' or 'donation')imageSearchQuery
(required, string - query used to find thumbnail image) Response: JSON object containing:recommendation
(with ObjectId)
- Endpoint:
GET /api/friends/:id/favorites
- Authorization: Bearer Token
Response: JSON object containing:
favorites
- Endpoint:
DELETE /api/friends/:id/favorites/:favoriteId
- Authorization: Bearer Token
Response: JSON object containing:
message: "Favorite gift removed"
- Endpoint:
PUT /api/friends/update-notification-inclusion
- Authorization: Bearer Token
Request Body: JSON object containing:
friendIds
(required, string[])
- Response: JSON object containing:
message: 'Updated friend notification preference successfully'
- Endpoint:
GET /api/tags
- Response: JSON object containing:
tag[]
Note: Only returns tags that do not have the type designation of "custom" at this endpoint for the purpose of rendering options to user
- Endpoint:
GET /api/tags/suggestions
- Query Parameter:
search
(required, string - search term for matching tag title suggestion)
- Response: JSON object containing:
tag[]
- Endpoint:
GET /api/reminders
- Authorization: Bearer Token
- Response: JSON object containing:
reminder[]
- Endpoint:
PUT /api/reminders/read
Request Body: JSON object containing:reminderIds
(required, string[])
- Authorization: Bearer Token
- Response: JSON object containing:
message: 'Reminders marked as read successfully'
- Endpoint:
DELETE /api/reminders/:id/delete
- Authorization: Bearer Token
- Response: JSON object containing:
message: 'Reminder deleted successfully'
- Endpoint:
POST /api/device
- Authorization: Bearer Token
- Request Body: JSON object containing:
token
(required, string)
- Response: JSON object containing:
message: "Device token added"
Note: Will hold one record per device token. If the same token is sent by another user, overwrites the record