Course Compose is a course-review website tailored for Stamford students, providing a platform for sharing and discovering insights about various courses
MIT License
2
stars
0
forks
source link
feat: pagination + jwt authentication for get reviews API #19
the get reviews API now uses JWT auth middleware to determine the number of reviews users can retrieve
if the user is anonymous (no token provided in the request header) or never had their reviews approved --> can fetch only 2 reviews per course
if the user has written a review and it has been approved --> we will use the pageSize and pageNumber from the request for pagination (frontend should limit pageSize to 10 per 1 api call)
Usages
without any query parameters (will use default value of pageSize=2 and pageNumber=1)
GET /api/courses/:courseCode/reviews
Example:
GET http://localhost:8003/api/courses/PHYS101/reviews
with pagination parameters
GET /api/courses/:courseCode/reviews?pageSize=...&pageNumber...
pageSize determines how many items to retrieve in 1 api call
pageNumber determines the offset
Example:
GET http://localhost:8003/api/courses/PHYS101/reviews?pageSize=10&pageNumber=1
Request Headers
Authorization - Bearer token (should be generated from Supabase)
What have I done?
the get reviews API now uses JWT auth middleware to determine the number of reviews users can retrieve
if the user is anonymous (no token provided in the request header) or never had their reviews approved --> can fetch only 2 reviews per course
if the user has written a review and it has been approved --> we will use the
pageSize
andpageNumber
from the request for pagination (frontend should limit pageSize to 10 per 1 api call)Usages
GET /api/courses/:courseCode/reviews
Example:
GET http://localhost:8003/api/courses/PHYS101/reviews
with pagination parameters
GET /api/courses/:courseCode/reviews?pageSize=...&pageNumber...
pageSize
determines how many items to retrieve in 1 api callpageNumber
determines the offsetExample:
GET http://localhost:8003/api/courses/PHYS101/reviews?pageSize=10&pageNumber=1
Request Headers Authorization - Bearer token (should be generated from Supabase)
Example:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImtoaW5nQHN0dWRlbnRzLnN0YW1mb3JkLmVkdSIsImV4cCI6MTcwMzY5NzA2Miwic3ViIjoiOGE3YjNjMmUtM2U1Zi00ZjFhLWE4YjctM2MyZTFhNGY1YjZkIn0.4S2QplWtjfoNe9v8cCpjWrl77Dsvjd4TQ9mJghWmJtg
Response:
Tests?