Skip to content

Commit 5272e5d

Browse files
authored
Fix questions routes (#73)
Fix question routes being unaccessible on production
1 parent 097b6b7 commit 5272e5d

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

frontend/src/_services/question.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { ApiService } from './api.service';
1414
providedIn: 'root',
1515
})
1616
export class QuestionService extends ApiService {
17-
protected apiPath = 'question';
17+
protected apiPath = 'question/questions';
1818

1919
private httpOptions = {
2020
headers: new HttpHeaders({

services/question/README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This endpoint allows the retrieval of all the questions in the database. If filt
3131
that matches with parameters will be returned; if no parameters are provided, all questions will be returned.
3232

3333
- **HTTP Method**: `GET`
34-
- **Endpoint**: `/api/question`
34+
- **Endpoint**: `/api/question/questions`
3535

3636
#### Parameters:
3737

@@ -51,25 +51,25 @@ that matches with parameters will be returned; if no parameters are provided, al
5151

5252
```
5353
Retrieve all Questions:
54-
curl -X GET http://localhost:8081/api/question
54+
curl -X GET http://localhost:8081/api/question/questions
5555
5656
Retrieve Questions by Title:
57-
curl -X GET "http://localhost:8081/api/question?title=Reverse%20a%20String"
57+
curl -X GET "http://localhost:8081/api/question/questions?title=Reverse%20a%20String"
5858
5959
Retrieve Questions by Description:
60-
curl -X GET "http://localhost:8081/api/question?description=string"
60+
curl -X GET "http://localhost:8081/api/question/questions?description=string"
6161
6262
Retrieve Questions by Topics:
63-
curl -X GET "http://localhost:8081/api/question?topics=Algorithms,Data%20Structures"
63+
curl -X GET "http://localhost:8081/api/question/questions?topics=Algorithms,Data%20Structures"
6464
6565
Retrieve Questions by Difficulty:
66-
curl -X GET "http://localhost:8081/api/question?difficulty=Easy"
66+
curl -X GET "http://localhost:8081/api/question/questions?difficulty=Easy"
6767
6868
Retrieve Questions by Title and Difficulty:
69-
curl -X GET "http://localhost:8081/api/question?title=Reverse%20a%20String&difficulty=Easy"
69+
curl -X GET "http://localhost:8081/api/question/questions?title=Reverse%20a%20String&difficulty=Easy"
7070
7171
Retrieve Questions by Title, Description, Topics, and Difficulty:
72-
curl -X GET "http://localhost:8081/api/question?title=Reverse%20a%20String&description=string&topics=Algorithms&difficulty=Easy"
72+
curl -X GET "http://localhost:8081/api/question/questions?title=Reverse%20a%20String&description=string&topics=Algorithms&difficulty=Easy"
7373
```
7474

7575
#### Parameter Format Details:
@@ -117,7 +117,7 @@ encoding and readability concerns.
117117
This endpoint allows the retrieval of the question by using the question ID.
118118

119119
- **HTTP Method**: `GET`
120-
- **Endpoint**: `/api/question/{id}`
120+
- **Endpoint**: `/api/question/questions/{id}`
121121

122122
#### Parameters:
123123

@@ -135,7 +135,7 @@ This endpoint allows the retrieval of the question by using the question ID.
135135

136136
```
137137
Retrieve Question by ID:
138-
curl -X GET http://localhost:8081/api/question/1
138+
curl -X GET http://localhost:8081/api/question/questions/1
139139
```
140140

141141
#### Example of Response Body for Success:
@@ -165,7 +165,7 @@ curl -X GET http://localhost:8081/api/question/1
165165
This endpoint allows the retrieval of random questions that matches the parameters provided.
166166

167167
- **HTTP Method**: `GET`
168-
- **Endpoint**: `/api/question/search`
168+
- **Endpoint**: `/api/question/questions/search`
169169

170170
#### Parameters:
171171

@@ -187,10 +187,10 @@ This endpoint allows the retrieval of random questions that matches the paramete
187187

188188
```
189189
Retrieve Random Question by Topics and Difficulty:
190-
curl -X GET "http://localhost:8081/api/question/search?topics=Algorithms&difficulty=Medium"
190+
curl -X GET "http://localhost:8081/api/question/questions/search?topics=Algorithms&difficulty=Medium"
191191
192192
Retrieve Random Question by Topics, Difficulty, and Limit:
193-
curl -X GET "http://localhost:8081/api/question/search?topics=Algorithms,Data%20Structures&difficulty=Easy&limit=5"
193+
curl -X GET "http://localhost:8081/api/question/questions/search?topics=Algorithms,Data%20Structures&difficulty=Easy&limit=5"
194194
```
195195

196196
#### Example of Response Body for Success:
@@ -243,7 +243,7 @@ curl -X GET "http://localhost:8081/api/question/search?topics=Algorithms,Data%20
243243
This endpoint retrieves all unique topics in the database
244244

245245
- **HTTP Method**: `GET`
246-
- **Endpoint**: `/api/question/topics`
246+
- **Endpoint**: `/api/question/questions/topics`
247247

248248
#### Responses:
249249

@@ -256,7 +256,7 @@ This endpoint retrieves all unique topics in the database
256256

257257
```
258258
Retrieve Topics:
259-
curl -X GET http://localhost:8081/api/question/topics
259+
curl -X GET http://localhost:8081/api/question/questions/topics
260260
```
261261

262262
#### Example of Response Body for Success:
@@ -286,7 +286,7 @@ This endpoint allows the addition of a new question. The `id` is now automatical
286286
uniqueness.
287287

288288
- **HTTP Method**: `POST`
289-
- **Endpoint**: `/api/question`
289+
- **Endpoint**: `/api/question/questions`
290290

291291
#### Request Body:
292292

@@ -307,7 +307,7 @@ uniqueness.
307307

308308
```
309309
Add Question:
310-
curl -X POST http://localhost:8081/api/question -H "Content-Type: application/json" -d "{\"title\": \"New Question\", \"description\": \"This is a description for a new question.\", \"topics\": [\"Data Structures\", \"Algorithms\"], \"difficulty\": \"Medium\"}"
310+
curl -X POST http://localhost:8081/api/question/questions -H "Content-Type: application/json" -d "{\"title\": \"New Question\", \"description\": \"This is a description for a new question.\", \"topics\": [\"Data Structures\", \"Algorithms\"], \"difficulty\": \"Medium\"}"
311311
```
312312

313313
#### Example of Response Body for Success:
@@ -334,7 +334,7 @@ curl -X POST http://localhost:8081/api/question -H "Content-Type: application/js
334334
This endpoint allows updating an existing question. Only the title, description, topics, and difficulty can be updated.
335335

336336
- **HTTP Method**: `PUT`
337-
- **Endpoint**: `/api/question/{id}`
337+
- **Endpoint**: `/api/question/questions/{id}`
338338

339339
#### Request Parameters:
340340

@@ -360,7 +360,7 @@ This endpoint allows updating an existing question. Only the title, description,
360360

361361
```
362362
Update Question:
363-
curl -X PUT http://localhost:8081/api/question/21 -H "Content-Type: application/json" -d "{\"title\": \"Updated Question Title\", \"description\": \"This is the updated description.\", \"topics\": [\"Updated Topic\"], \"difficulty\": \"Hard\"}"
363+
curl -X PUT http://localhost:8081/api/question/questions/21 -H "Content-Type: application/json" -d "{\"title\": \"Updated Question Title\", \"description\": \"This is the updated description.\", \"topics\": [\"Updated Topic\"], \"difficulty\": \"Hard\"}"
364364
```
365365

366366
#### Example of Response Body for Success:
@@ -387,7 +387,7 @@ curl -X PUT http://localhost:8081/api/question/21 -H "Content-Type: application/
387387
This endpoint allows the deletion of a question by the question ID.
388388

389389
- **HTTP Method**: `DELETE`
390-
- **Endpoint**: `/api/question/{id}`
390+
- **Endpoint**: `/api/question/questions/{id}`
391391

392392
#### Parameters:
393393

@@ -405,7 +405,7 @@ This endpoint allows the deletion of a question by the question ID.
405405

406406
```
407407
Delete Question:
408-
curl -X DELETE http://localhost:8081/api/question/21
408+
curl -X DELETE http://localhost:8081/api/question/questions/21
409409
```
410410

411411
#### Example of Response Body for Success:
@@ -432,7 +432,7 @@ curl -X DELETE http://localhost:8081/api/question/21
432432
This endpoint allows the deletion of multiple questions by their question IDs.
433433

434434
- **HTTP Method**: `POST`
435-
- **Endpoint**: `/api/question/delete`
435+
- **Endpoint**: `/api/question/questions/delete`
436436

437437
#### Parameters:
438438

@@ -451,7 +451,7 @@ This endpoint allows the deletion of multiple questions by their question IDs.
451451

452452
```
453453
Delete Questions:
454-
curl -X POST http://localhost:8081/api/question/delete -H "Content-Type: application/json" -d '{"ids": [21, 22]}'
454+
curl -X POST http://localhost:8081/api/question/questions/delete -H "Content-Type: application/json" -d '{"ids": [21, 22]}'
455455
```
456456

457457
#### Example of Response Body for Success:

services/question/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ app.use(
2323

2424
// Routes
2525
app.use('/', router);
26-
app.use('/api/question', questionRouter);
26+
app.use('/api/question/questions', questionRouter);
2727

2828
export default app;

0 commit comments

Comments
 (0)