Skip to content

Commit 9621503

Browse files
authored
Update README.md (#9)
This hot fix is to provide the Backend repository with up-to-date documentation relevant for the Sprint 2. Since the Sprint 2 changes have already been deployed to main, this is a one-time only merge to main.
1 parent db362fa commit 9621503

File tree

1 file changed

+131
-1
lines changed

1 file changed

+131
-1
lines changed

README.md

Lines changed: 131 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,131 @@
1-
# Backend
1+
# Backend
2+
3+
![Frame 71](https://github.com/ISIS3510-202410-Team-13/Backend/assets/68788933/2d41f599-1291-42e4-9242-4829fb7e32e3)
4+
5+
## AvailableSpaces Service
6+
7+
The AvailableSpaces service, a critical component of our application, facilitates the retrieval of information regarding available classrooms within specified time frames and days of the week at Universidad de los Andes' campus. Developed in TypeScript using Express.js and Node.js, this service serves as an API endpoint to support scheduling and resource allocation for university activities. It is deployed on Google Cloud Platform's Compute Engine.
8+
9+
### Installation Guide
10+
11+
To install and run the AvailableSpaces service locally or in your environment, follow these steps:
12+
13+
1. Clone the Repository: `git clone https://github.com/ISIS3510-202410-Team-13/Backend.git`
14+
2. Navigate to the Backend Directory: `cd Backend/AvailableSpaces`
15+
3. Build the Docker Image: `docker build -t available_spaces .`
16+
4. Run the Docker Container: `docker run -d -p 3000:3000 available_spaces`
17+
5. Verify Installation: `docker ps`
18+
19+
### Usage Guide
20+
21+
#### Request Schema
22+
23+
To query the AvailableSpaces service, make a GET request to the following endpoint:
24+
25+
```
26+
GET http://34.133.121.100:3000/
27+
```
28+
29+
Include the following JSON body in your request:
30+
31+
```json
32+
{
33+
"dayOfWeek": "l|m|i|j|v|s|d",
34+
"startTime": "hhmm",
35+
"endTime": "hhmm"
36+
}
37+
```
38+
39+
40+
- `dayOfWeek`: A single letter string representing the day of the week. Valid values are 'l' (Monday), 'm' (Tuesday), 'i' (Wednesday), 'j' (Thursday), 'v' (Friday), 's' (Saturday), and 'd' (Sunday).
41+
- `startTime`: A four-digit string representing the start time in 24-hour format (e.g., "0800" for 8:00 AM).
42+
- `endTime`: A four-digit string representing the end time in 24-hour format (e.g., "1700" for 5:00 PM).
43+
44+
45+
#### Response Schema
46+
47+
The response will be a JSON array containing objects with the following structure:
48+
49+
```json
50+
[
51+
{
52+
"building": "string",
53+
"room": "string",
54+
"availableFrom": "hhmm",
55+
"availableUntil": "hhmm",
56+
"minutesAvailable": "integer"
57+
},
58+
...
59+
]
60+
```
61+
62+
63+
- `building`: The building code where the space is located (e.g., "ML" for Mario Laserna building).
64+
- `room`: The room number or identifier.
65+
- `availableFrom`: The time the space is available from in 24-hour format.
66+
- `availableUntil`: The time the space is available until in 24-hour format.
67+
- `minutesAvailable`: The duration of availability in minutes.
68+
69+
> Notice that the endpoint returns a list of these objects (an empty list is possible)
70+
71+
#### Example Call
72+
73+
```bash
74+
curl -X GET http://34.133.121.100:3000/ \
75+
-H "Content-Type: application/json" \
76+
-d '{"dayOfWeek": "m", "startTime": "0800", "endTime": "1200"}'
77+
```
78+
79+
### Troubleshooting
80+
81+
If you encounter any issues while using the AvailableSpaces service, refer to the following troubleshooting guide to identify and resolve common problems:
82+
83+
1. Request Body Missing:
84+
85+
- Error Message: `{ "message": "Request body is missing" }`
86+
- Cause: The request sent to the service is missing the JSON body.
87+
- Solution: Ensure that your request includes a valid JSON body with the required parameters.
88+
89+
2. Missing Required Fields:
90+
91+
- Error Message: `{ "message": "Missing required fields in request body" }`
92+
- Cause: The request body is missing one or more required fields (dayOfWeek, startTime, endTime).
93+
- Solution: Include all required fields in the request body before sending the request.
94+
95+
3. Invalid Data Types:
96+
97+
- Error Message: `{ "message": "Invalid data types in request body" }`
98+
- Cause: One or more fields in the request body have invalid data types.
99+
- Solution: Ensure that all fields in the request body have the correct data types (dayOfWeek and time fields should be strings).
100+
101+
4. Invalid Day of Week:
102+
103+
- Error Message: `{ "message": "Invalid day of week" }`
104+
- Cause: The dayOfWeek parameter in the request body is not a valid single-letter string representing a day of the week.
105+
- Solution: Check that the dayOfWeek parameter is a single-letter string ('l', 'm', 'i', 'j', 'v', 's', or 'd').
106+
107+
5. Invalid Time Format:
108+
109+
- Error Message: `{ "message": "Invalid time format" }`
110+
- Cause: The startTime or endTime parameter in the request body does not match the expected four-digit string format (hhmm).
111+
- Solution: Ensure that the time parameters follow the four-digit string format (e.g., "0800" for 8:00 AM).
112+
113+
6. Start Time Must be Before End Time:
114+
115+
- Error Message: `{ "message": "Start time must be before end time" }`
116+
- Cause: The startTime parameter is equal to or later than the endTime parameter in the request body.
117+
- Solution: Adjust the startTime and endTime parameters to ensure that the start time comes before the end time.
118+
119+
7. Invalid Time Range:
120+
121+
- Error Message: `{ "message": "Invalid time range" }`
122+
- Cause: The startTime or endTime parameter in the request body is outside the valid time range (00:00 - 23:59).
123+
- Solution: Verify that the time parameters fall within the valid range (00:00 - 23:59).
124+
125+
8. Invalid Minutes:
126+
127+
- Error Message: `{ "message": "Invalid minutes" }`
128+
- Cause: The minutes portion of the startTime or endTime parameter in the request body is greater than 59.
129+
- Solution: Ensure that the minutes portion of the time parameters does not exceed 59.
130+
131+

0 commit comments

Comments
 (0)