- Backend for Eldafriend app, A pal for the elder community! Track your medication, along with reminders and many showstopper features that ensure completely homely care.
End-Points:
- User Authentication endpoints
- Medicine endpoints
- Community endpoints
- Expense endpoints
- User functionalities
To install dependencies:
bun install
To run:
bun run dev
Returns a greeting message.
Creates a new user and sends an OTP to their email.
- Content-Type: application/json
{
"fullname": "John Doe",
"email": "[email protected]",
"password": "password123"
}
- If Phone number is not valid
{
"message": "Phone number is not valid"
}
- If Email already Exists
{
"message": "Email already exists"
}
- If Phone number already exists
{
"message": "Phone number already exists"
}
- If User is not added to the database due to internal server error
{
"message": "User not created due to an Internal server error"
}
- If OTP generated successfully
{
"userId": "ufiabifahbigubapigbiua",
"message": "An OTP has been successfully sent to your registered email address"
}
- HTTP status codes: 201 for success, 400 for bad request, 404 for not found, 500 for internal server error.
Verifies the OTP sent to the user's email.
- Content-Type: application/json
{
"userId": "123",
"otp": 459819
}
- Successful creation
{
"message": "User created successfully"
}
- Error while verifying the OTP
{
"message": "User not created"
}
- User enters wrong OTP
{
"message": "Invalid OTP"
}
- User enters the correct OTP
{
"message": "User verified!"
}
- HTTP status codes: 201 for success, 400 for bad request, 404 for not found, 500 for internal server error.
Logs in a user.
- Content-Type: application/json
{
"email": "[email protected]",
"password": "password123"
}
- Email doesn't exists in database
{
"message": "User not found"
}
- User types invalid password
{
"message": "Invalid password"
}
- If Email and password matches and the user exists in database
{
"_id": "65e5e402368294524c92cc00"
}
Gets user details
- Content-Type: application/json
- user-id: "dummyUserid123456789"
{
"_id": "65e5e402368294524c92cc00",
"fullname": "John",
"phone": "+919999999999",
"email": "[email protected]",
"picture": null,
"globalPin": 1234,
"communities": [],
"medicines": [],
"expenses": [],
"verified": true
}
Response status codes: 200: Successful retrieval of user details 404: User not found 422: Check headers/request body 500: Internal Server Error
Creates a new medicine for a user.
- Content-Type: application/json
{
"userId": "123",
"dosageType": "Syrup",
"medAmount": "2",
"medName": "cough syrup",
"duration": "1",
"scheduledTime": "08:00 AM"
}
- If medicine is not created
{
"message": "Failed to create Medicine"
}
- If medicine is created
{
"message": "Medicine created successfully"
}
- HTTP status codes: 201 for success, 400 for bad request , 404 for not found, 500 for internal server error.
Updates the status of a medicine as taken.
- Content-Type: application/json
{
"userId": "123",
"medicineId": "456",
"setTrueForDate": 2024-03-05T15:11:24.451+00:00,
"setTrue": true
}
- If Server error while updating medicine taken status
{
"message": "Internal Server error while updating the medicine taken status"
}
- HTTP Status Code: 204 No Content
Gets all the medicines of a user.
- Content-Type: application/json
{
"userId": "123"
}
- If Server error while getting all meds
{
"message": "Internal Server error while getting the Medicines"
}
- Successful response
[
{
"_id": "65e5e49c368294524c92cc06",
"name": "Cough Syrup",
"scheduledTime": "8:00"
},
{
"_id": "65e5e4ea368294524c92cc09",
"name": "Dolo",
"scheduledTime": "14:00"
},
{
"_id": "6623ce293e907121089af226",
"name": "DummyMed",
"scheduledTime": "20:00"
},
{
"_id": "6623cf8f14b66b366c40a877",
"name": "DummyMed",
"scheduledTime": "19:50"
},
{
"_id": "6623d11aba798dad2b403fef",
"name": "DummyMed",
"scheduledTime": "19:00"
}
]
- HTTP Status Code: 200 (success),204(medicine not found), 500(internal server failure), 422(request body error)
Creates a new community.
- Content-Type: application/json
{
"adminUserId": "123",
"name": "Community Name",
"description": "Community Description",
"picture": "http://example.com/picture.jpg",
"banner": "http://example.com/banner.jpg"
}
- If the community is created successfully:
{
"message": `Community created and Admin status is updated`
}
- If the input data is incorrect:
{
"message": "Failed to create community. Please check your input data."
}
- If there's an internal server error:
{
"message": "Internal Server Error while creating community"
}
- HTTP status codes: 201 for success, 400 for bad request, 500 for internal server error.
Fetches all communities.
None required
[
{
"_id": "123",
"adminUserId": "123",
"name": "Community Name",
"description": "Community Description",
"picture": "http://example.com/picture.jpg",
"banner": "http://example.com/banner.jpg"
},
...
]
Adds a new expense for a user.
Content-Type: application/json
{
"userId": "123",
"itemName": "Groceries",
"itemPrice": 50.0
}
- If the request body validation fails:
{
"message": "Validation error messages"
}
- If the user ID is not found:
{
"message": "User ID not found"
}
- If there's an error while adding the expense:
{
"message": "Error message from addExpense service"
}
- If the expense is added successfully but there's an error while updating the user:
{
"message": "Failed to update user with new expense"
}
- If the expense is added and the user is updated successfully:
{
"message": "Expense Updated successfully"
}
- HTTP status codes: 201 for success, 400 for bad request, 404 for not found, 500 for internal server error.
Fetches a list of users who are associated with a specific medicine.
medicine_name
: The name of the medicine. This is a path parameter.
-
200 OK
: The request was successful. The response body contains an array of users who are associated with the specified medicine. Each user object includes the user's full name, phone number, and email address. -
400 Bad Request
: The request was unsuccessful because themedicine_name
parameter was not provided. The response body contains a message explaining the error. -
500 Internal Server Error
: The request was unsuccessful due to an unexpected error on the server. The response body contains a message explaining the error.
Empty
[
{
"fullname": "John Doe",
"phone": "123-456-7890",
"email": "[email protected]"
},
{
"fullname": "Jane Doe",
"phone": "098-765-4321",
"email": "[email protected]"
}
]