Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devmukulsingh/jainitriassignment
https://github.com/devmukulsingh/jainitriassignment
honojs hostpital-management typescript
Last synced: about 8 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/devmukulsingh/jainitriassignment
- Owner: devMukulSingh
- Created: 2025-02-12T08:04:21.000Z (1 day ago)
- Default Branch: master
- Last Pushed: 2025-02-13T05:06:57.000Z (about 10 hours ago)
- Last Synced: 2025-02-13T06:22:18.521Z (about 9 hours ago)
- Topics: honojs, hostpital-management, typescript
- Language: TypeScript
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This project built using honojs as framework and nodejs as runtime.
# STEPS to run the project locally-
STEP1 -> Rename .env.example to .env and enter the `DATABASE_URL` and `JWT_SECRET`
STEP2 -> Install dependencies using `bun install` or `npm install`
STEP3 -> Generate prisma client using `bun run generate` or `npx prisma generate`
STEP4 -> Migrate database schema using `bun run migrate` or `npx prisma migrate`
STEP5 -> Run `bun run dev` or `npm run dev` to start the server
# API DOCUMENTATION -
Base path - "/api/v1"
1. Register a New User (Hospital)
Endpoint: /auth/register
Method: POSTDescription:
Creates a new user (hospital) account.Request Body Example : {
"email": "[email protected]",
"name": "City Hospital",
"password": "strongPassword123"
}
Response -> status:201, {
msg: "User created successfully",
data: {
id: "1",
name: "name",
email: "email",
token
}
}Error Responses:
1. Status: 400 Bad Request
error: [`field` is required]
2. Status: 409 Conflict
error: "user already exists"
3. Status: 500
error: Internal server error `error messsage`2. User Login
Endpoint: /auth/login
Method: POSTDescription:
Authenticates a user (hospital).Request Body Example:
{
"email": "[email protected]",
"password": "strongPassword123"
}
Success Response:Status: 200 OK
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": 1,
"email": "[email protected]",
"name": "City Hospital"
}
}
Error Responses:1. Status:400
error:['field' is required]
2. Status: 401 Unauthorized
error: Invalid credentials.
3. Status: 500
error: Internal server error `error messsage`3. Post a New Disease
Endpoint: /disease/:userId/post-disease
Method: POSTDescription:
Creates a new disease record for the hospital (user). Optionally, the disease can be linked to a specific patient by providing patientId. (Note: In the current schema, each disease record is associated with one patient at most.)Path Parameters:
userId (String) – The ID of the user (hospital).Request Body Example:
{
"name": "Influenza",
}
Success Response:
Status: 201 Created
{
"id": 10,
"name": "Influenza",
"userId": 1,
"patientId": 2
}
Error Responses:
1. Status: 400 Bad Request
error:[`field` is required]
2. Status: 403 Unauthenticated
error: Unauthenticated
3. Status: 500
error: Internal server error `error messsage`4. Post a New Patient
Endpoint: /patient/:userId/post-patient
Method: POSTDescription:
Adds a new patient record for the specified user (hospital).Path Parameters:
userId (String) – The ID of the user (hospital).Request Body Example:
{
"phone": "+1234567890",
"name": "John Doe",
"diseaseIds":[{id:"1",id:"2"}],
"heartRate":"40"
}Success Response:
Status: 201 Created
{
"id": 2,
"phone": "+1234567890",
"name": "John Doe",
"userId": 1,
"createdAt": "2025-02-12T12:00:00.000Z",
"updatedAt": "2025-02-12T12:00:00.000Z"
}
Error Responses:1. Status: 400 Bad Request
error: [`field` is required]
2. Status: 409 Conflict
error: A patient with the given phone number already exists.
3. Status: 500
error: Internal server error `error messsage`5. Get All Patients for a User
Endpoint: /patient/:userId/get-patients
Method: GETDescription:
Retrieves a list of all patients associated with the given user (hospital).Path Parameters:
userId (String) – The ID of the user (hospital).
Success Response:
Status: 200 OK
[
{
"id": 2,
"phone": "+1234567890",
"name": "John Doe",
"userId": 1,
"createdAt": "2025-02-12T12:00:00.000Z",
"updatedAt": "2025-02-12T12:00:00.000Z"
},
{
"id": 3,
"phone": "+1098765432",
"name": "Jane Doe",
"userId": 1,
"createdAt": "2025-02-12T12:05:00.000Z",
"updatedAt": "2025-02-12T12:05:00.000Z"
}
]Error Responses:
1. Status: 500
error: Internal server error `error messsage`
6. Get a Specific Patient by PhoneEndpoint: /patient/:userId/get-patient/:phone
Method: GETDescription:
Retrieves the details of a single patient, identified by their phone number, associated with the specified user (hospital).Path Parameters:
userId (String) – The ID of the user (hospital).
phone (String) – The patient's phone number.Success Response:
Status: 200 OK
{
"id": 2,
"phone": "+1234567890",
"name": "John Doe",
"userId": 1,
"createdAt": "2025-02-12T12:00:00.000Z",
"updatedAt": "2025-02-12T12:00:00.000Z"
}Error Responses:
1. Status: 500
error: Internal server error `error messsage`