Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
d34f75f
Refactor section aggregation pipelines; unify courses & professors; h…
Krish-Patel656 Nov 1, 2025
017f681
controllers: fix section aggregation; unify pipeline so ById returns …
Krish-Patel656 Nov 27, 2025
0c7b829
Rewrite Filter System, created unit tests, updated queryable fields
SoggyRhino Feb 15, 2026
994303e
Updated documentation
SoggyRhino Feb 15, 2026
240b98b
Fix bugs with slices and base fields. Changed queryable fields
SoggyRhino Feb 15, 2026
58beb4b
Fix bugs with slices and base types, changed queryable fields, fixed …
SoggyRhino Feb 15, 2026
66e9c43
Merge branch 'UTDNebula:develop' into feat-filterQuery
SoggyRhino Feb 15, 2026
0f6606b
Fix comment typo in drillType function
SoggyRhino Feb 15, 2026
859534e
Fix doc
SoggyRhino Feb 15, 2026
f0c56ae
Remove $in on multiple values
SoggyRhino Feb 15, 2026
795fef5
Merge remote-tracking branch 'origin/feat-filterQuery' into feat-filt…
SoggyRhino Feb 15, 2026
5f204af
Create Initial Email Endpoint
justinschwerdtfeger Feb 27, 2026
182d72d
Merge branch 'develop' into email
mikehquan19 Mar 2, 2026
2a62987
Add basic queue
justinschwerdtfeger Mar 2, 2026
625999e
Merge branch 'email' of github.com:justinschwerdtfeger/nebula-api int…
justinschwerdtfeger Mar 2, 2026
92b0161
go mod tidy after merge
justinschwerdtfeger Mar 2, 2026
47fe494
Add basic email route similar to storage.go
justinschwerdtfeger Mar 2, 2026
6d8ceee
Use singletons
justinschwerdtfeger Mar 2, 2026
e5df25f
Update env template and readme for new env variables
justinschwerdtfeger Mar 2, 2026
2e72636
Split email route keys
justinschwerdtfeger Mar 2, 2026
acbb30a
Update swaggo docs
justinschwerdtfeger Mar 2, 2026
c2f274a
Move EmailRequest to schema. Still not sure on the schema
justinschwerdtfeger Mar 2, 2026
60dd1bc
Merge branch 'UTDNebula:develop' into feat-filterQuery
SoggyRhino Mar 5, 2026
288b03d
Merge branch 'develop' into feat-filterQuery
mikehquan19 Mar 5, 2026
79a86e1
Merge branch 'develop' into email
mikehquan19 Mar 5, 2026
a9f4ac3
Add embed support
justinschwerdtfeger Mar 6, 2026
99d1672
Merge branch 'email' of github.com:justinschwerdtfeger/nebula-api int…
justinschwerdtfeger Mar 6, 2026
9f089d1
Add swagger internal tags
justinschwerdtfeger Mar 6, 2026
ad1506d
Formatting and swagger update
justinschwerdtfeger Mar 6, 2026
a45491a
Merge remote-tracking branch 'upstream/develop' into email
justinschwerdtfeger Mar 6, 2026
71afc25
Update docs.go again
justinschwerdtfeger Mar 6, 2026
cce298a
Remove TODO:
justinschwerdtfeger Mar 6, 2026
72b8692
Merge branch 'develop' into feat-filterQuery
SoggyRhino Mar 6, 2026
055d31e
Update discounts endpoints
mikehquan19 Mar 7, 2026
3c2306e
Comments docs, I'm passing out
mikehquan19 Mar 7, 2026
1a9a941
Much cleaner query params parsing now
mikehquan19 Mar 10, 2026
c749aaa
Merge remote-tracking branch 'upstream/develop' into email
justinschwerdtfeger Mar 11, 2026
38d1b3c
tidy code
justinschwerdtfeger Mar 11, 2026
080f37f
Fetch the list of discount categories dynamically
mikehquan19 Mar 12, 2026
3c4a6fb
Get rid of offset since no need for pagination on discounts
mikehquan19 Mar 12, 2026
79283a6
Bump google.golang.org/grpc from 1.71.0 to 1.79.3 in /api
dependabot[bot] Mar 19, 2026
722dd2c
Bump go version and dependency beyond current version of dependabot
mikehquan19 Mar 19, 2026
1f1d5fc
Use WithAuthCredentialsJSON since WithCredentialsJSON is deprecated d…
mikehquan19 Mar 19, 2026
dac0987
Update some doc
mikehquan19 Mar 19, 2026
b5b20c0
Merge pull request #360 from UTDNebula/dependabot/go_modules/api/goog…
mikehquan19 Mar 19, 2026
d44f50c
Merge from origin/develop
mikehquan19 Mar 19, 2026
c693cf0
Upgrade the pipeline
mikehquan19 Mar 19, 2026
fba7f53
Some swag update
mikehquan19 Mar 19, 2026
a2933e3
Yeah no newlines with error
mikehquan19 Mar 19, 2026
79fd3f0
No . with error
mikehquan19 Mar 19, 2026
0ca0681
Merge pull request #361 from UTDNebula/docker-fix
mikehquan19 Mar 19, 2026
44ed369
Merge from origin/develop
mikehquan19 Mar 19, 2026
6a87a80
Merge branch 'develop' into develop
Krish-Patel656 Mar 20, 2026
280a5a0
Merge branch 'develop' into feat-filterQuery
mikehquan19 Mar 20, 2026
28d2b1f
Merge pull request #306 from Krish-Patel656/develop
mikehquan19 Mar 20, 2026
fbcb1cf
Minor documentation changes, update cache to use type as key, not typ…
SoggyRhino Mar 23, 2026
ae4790f
Merge pull request #334 from SoggyRhino/feat-filterQuery
mikehquan19 Mar 23, 2026
163b3eb
Merge pull request #363 from UTDNebula/264-rewrite-filter-query
mikehquan19 Mar 24, 2026
38c834f
Merge branch 'develop' into email-endpoint
mikehquan19 Mar 24, 2026
cba5f4c
Merge branch 'develop' into 280-implement-pipeline-builder-for-section
mikehquan19 Mar 24, 2026
1e7c655
Use the context that is tied to the request instead of creating another
mikehquan19 Mar 25, 2026
afeedc0
changed DiscountProgram.Address type to []string
bvaic Mar 27, 2026
8070666
Merge pull request #366 from bvaic/develop
mikehquan19 Mar 27, 2026
ff441f6
Merge branch 'develop' into email-endpoint
mikehquan19 Mar 29, 2026
8ea59e7
Remove smtp_from env variable
justinschwerdtfeger Mar 30, 2026
e4fcb68
Add missing headers to queueEmail
justinschwerdtfeger Mar 30, 2026
1c1b8c6
Revert "Implement pipline builder for section aggregate endpoints"
Krish-Patel656 Mar 20, 2026
40bdb0d
Fix structure based on course and section files
Krish-Patel656 Apr 2, 2026
fe767d7
Merge branch 'develop' into 280-implement-pipeline-builder-for-section
Krish-Patel656 Apr 2, 2026
547bd81
Merge pull request #362 from UTDNebula/280-implement-pipeline-builder…
mikehquan19 Apr 13, 2026
6de7a4c
feat: implement maximum upload size and fix storage routes
SiddhaarthB11 Apr 14, 2026
a9a40b3
Added url field to AcademicCalendar schema
kimbow231 Apr 15, 2026
679e039
Merge branch 'develop' into email-endpoint
mikehquan19 Apr 15, 2026
7f1bd48
fixed formating error
kimbow231 Apr 16, 2026
4ef45c1
Merge pull request #381 from UTDNebula/academic-calendar-schema
mikehquan19 Apr 16, 2026
ff1fbfd
signed-url-upload-size-changes
SiddhaarthB11 Apr 19, 2026
a104f00
Merge branch 'develop' into email-endpoint
justinschwerdtfeger Apr 20, 2026
5725e16
Remove redundant gin context variables in email
justinschwerdtfeger Apr 21, 2026
116ee35
Merge pull request #359 from UTDNebula/email-endpoint
mikehquan19 Apr 21, 2026
5d5c02c
Next release
mikehquan19 Apr 21, 2026
659e5c6
Add multi email recipients
justinschwerdtfeger Apr 23, 2026
fbd987e
Spread send email to recepients to allow email with many recipients
justinschwerdtfeger Apr 23, 2026
a9ad569
Update swagger
justinschwerdtfeger Apr 23, 2026
c5680f5
Merge branch 'develop' into feature/upload-limit
SiddhaarthB11 Apr 23, 2026
a1ae075
feat: add /combined/sections/trends endpoint
Kumud-Arora Apr 23, 2026
15c372b
feat: add combined professor + course trends endpoint
Kumud-Arora Apr 23, 2026
3a4ac49
Add timeout for Queue Email
justinschwerdtfeger Apr 24, 2026
0cac14e
Add timeout to Send Email
justinschwerdtfeger Apr 24, 2026
e10f19e
Merge pull request #393 from UTDNebula/email-multi-recipient
mikehquan19 Apr 24, 2026
eda4d09
feat: add Mazevo event routes for building- and room-specific querying
ruba0s Apr 27, 2026
1112161
Merge branch 'develop' into feature/upload-limit
mikehquan19 Apr 29, 2026
5d83395
Budget schema v1
TyHil Apr 30, 2026
a6f69f3
Add comment to Academic Calendar schema
TyHil Apr 30, 2026
668fce9
Parse per school tables separately
TyHil Apr 30, 2026
60f2c84
Merge pull request #380 from UTDNebula/feature/upload-limit
mikehquan19 Apr 30, 2026
687de7d
Merge branch 'develop' into budget-parse
TyHil May 1, 2026
0dea4ac
Merge pull request #397 from UTDNebula/budget-parse
TyHil May 1, 2026
ca38387
Merge branch 'develop' into 301-mazevo-route-for-specific-query
mikehquan19 May 2, 2026
88035af
Merge pull request #396 from UTDNebula/301-mazevo-route-for-specific-…
mikehquan19 May 5, 2026
a3109d9
Merge branch 'develop' into feature/combined-sections-trends
Kumud-Arora May 6, 2026
2599ecd
Merge pull request #394 from Kumud-Arora/feature/combined-sections-tr…
mikehquan19 May 6, 2026
f82526c
Merge from develop
mikehquan19 May 6, 2026
1531537
Fix the swag and bump the version
mikehquan19 May 6, 2026
195be36
move email context timeout to inside for loop
justinschwerdtfeger May 7, 2026
3e40fd7
Merge pull request #399 from UTDNebula/email-context-timeout-fix
mikehquan19 May 9, 2026
805d530
Timeout context for each task creation
mikehquan19 May 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v6
with:
go-version: '1.24'
go-version: '1.25'
cache-dependency-path: "**/go.sum"

- name: Setup
Expand All @@ -34,14 +34,14 @@ jobs:
- name: Check
run: make check

- name: Build
run: make build

- name: Test
env:
MONGODB_URI: ${{ secrets.MONGODB_URI }}
run: make test

- name: Build
run: make build

build_windows:
runs-on: windows-latest
defaults:
Expand All @@ -67,10 +67,10 @@ jobs:
- name: Check
run: .\build.bat checks

- name: Build
run: .\build.bat build

- name: Test
env:
MONGODB_URI: ${{ secrets.MONGODB_URI }}
run: .\build.bat test

- name: Build
run: .\build.bat build
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project maintained by [Nebula Labs](https://about.utdnebula.com).

Documentation for the current production API can be found [here.](https://api.utdnebula.com/swagger/index.html)

## How to use
## How to use Nebula API in your own project

- Visit our [Discord](https://discord.utdnebula.com) and ask to be provisioned an API key (please provide details on your use case)
- Read the documentation listed above (and authenticate with your key for interactive demos)
Expand All @@ -21,7 +21,8 @@ Contributions are welcome!

This project uses the MIT License.

Please visit our [Discord](https://discord.utdnebula.com) and talk to us if you'd like to contribute!
Please visit our [Discord](https://discord.utdnebula.com) and talk to us if you'd like to contribute! Don't be afraid to ask for help!

### How to Contribute

Create your own fork by [forking this repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo#forking-a-repository)
Expand All @@ -32,7 +33,7 @@ Submit proposed changes via a [Pull Request](https://docs.github.com/en/pull-req

## Building
### Requirements
- [Golang 1.23 or Higher](https://go.dev/dl/)
- [Golang 1.24 or Higher](https://go.dev/dl/)

### Building for Windows
cd into `nebula-api\api`
Expand All @@ -43,6 +44,8 @@ Setup Go Dependencies with
Build with
`.\build.bat build`

This will create an executable named `go-api.exe` in the `api` directory

Run with
`.\go-api.exe`
> Note: some have experienced issues with Windows Defender or other antivirus blocking `go-api.exe` from reading files, editing files, or causing slowed performance. Consider adding a exception to your `nebula-api` folder.
Expand All @@ -56,17 +59,23 @@ Setup Go dependencies with
Build with
`make build`

This will create an executable named `go-api` in the `api` directory

> Note: If Make fails with "swag: No such file or directory" or similar, you may need to add GOPATH/bin to your path to your path, On Mac, use ``echo 'export PATH=${PATH}:`go env GOPATH`/bin' >> ~/.zshrc && source ~/.zshrc`` to add it permanently to your .zshrc

Run with
`./go-api`

## Running to API locally
## Running API locally
Copy `.env.template` to `.env` with
`cp .env.template .env`

Enter Nebula MongoDB URI in `.env`
Enter Nebula MongoDB URI in `.env` (ask for help in the [Discord](https://discord.utdnebula.com))

Run `go-api`

Check command output to see the route serving traffic. It's likely port 8080

Visit `http://localhost:8080` to access nebula-api locally

> Storage and email routes require additional environment variables. If you're working on these routes, ask for help in the [Discord](https://discord.utdnebula.com)
20 changes: 17 additions & 3 deletions api/.env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# See README.MD for more information

# DATABASE URI
MONGODB_URI=
CLUBS_DB_URI=
Expand All @@ -9,9 +11,21 @@ CLUBS_DB_URI=
#PORT=
#GIN_MODE=release

# CLOUD STORAGE (internal use only)
# SENRTY
SENTRY_ENVIRONMENT=development

# For Google Cloud Routes /storage /email (internal use only)
GOOGLE_APPLICATION_CREDENTIALS=
STORAGE_ROUTE_KEY=
# MAX_UPLOAD_SIZE=104857600
EMAIL_SEND_ROUTE_KEY=
EMAIL_QUEUE_ROUTE_KEY=

# SENRTY
SENTRY_ENVIRONMENT=
# For SMTP email sending
SMTP_HOST=smtp.gmail.com
SMTP_USERNAME=
SMTP_PASSWORD=

# For Email Google Cloud Task Queueing
GCLOUD_EMAIL_QUEUE_PATH=
GCLOUD_EMAIL_QUEUE_URL=
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

FROM docker.io/golang:1.24 AS builder
FROM docker.io/golang:1.25 AS builder
WORKDIR /build

COPY ./configs ./configs
Expand Down
6 changes: 3 additions & 3 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ check:
gofmt -w ./..
goimports -w ./..

test:
go test ./... -count=1

build: server.go
swag fmt
swag init -g server.go --outputTypes yaml,go
go build -o $(EXEC_NAME) server.go

test:
go test ./...

clean: $(EXEC_NAME)
rm $(EXEC_NAME)

Expand Down
17 changes: 9 additions & 8 deletions api/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@ echo Checks done!
echo[
if "%1"=="checks" exit

:test
echo Testing...
go test ./... -count=1
if ERRORLEVEL 1 exit /b %ERRORLEVEL% :: fail if error occurred
echo Testing complete!
echo[
if "%1"=="build" exit

:build
echo Building...
go build -o %EXEC_NAME% server.go
if ERRORLEVEL 1 exit /b %ERRORLEVEL% :: fail if error occurred
echo Build complete!
echo[
if "%1"=="build" exit

:test
echo Testing...
go test ./...
if ERRORLEVEL 1 exit /b %ERRORLEVEL% :: fail if error occurred
echo Testing complete!
echo[
if "%1"=="build" exit
23 changes: 23 additions & 0 deletions api/configs/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,26 @@ func GetEnvLimit() int64 {

return limit
}

func GetEnvMaxUploadSize() int64 {
const (
defaultLimit int64 = 30 * 1024 * 1024
hardCapLimit int64 = 50 * 1024 * 1024
)

limitString, exist := os.LookupEnv("MAX_UPLOAD_SIZE")
if !exist {
return defaultLimit
}

limit, err := strconv.ParseInt(limitString, 10, 64)
if err != nil {
return defaultLimit
}

if limit > hardCapLimit {
return hardCapLimit
}

return limit
}
6 changes: 3 additions & 3 deletions api/controllers/astra.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var astraCollection *mongo.Collection = configs.GetCollection("astra")
// @Success 200 {object} schema.APIResponse[schema.MultiBuildingEvents[schema.AstraEvent]] "All AstraEvents with events on the inputted date"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
func AstraEvents(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

date := c.Param("date")
Expand Down Expand Up @@ -61,7 +61,7 @@ func AstraEvents(c *gin.Context) {
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 404 {object} schema.APIResponse[string] "A string describing the error"
func AstraEventsByBuilding(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

date := c.Param("date")
Expand Down Expand Up @@ -120,7 +120,7 @@ func AstraEventsByBuilding(c *gin.Context) {
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 404 {object} schema.APIResponse[string] "A string describing the error"
func AstraEventsByBuildingAndRoom(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

date := c.Param("date")
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/autocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var DAGCollection *mongo.Collection = configs.GetCollection("DAG")
// @Success 200 {object} schema.APIResponse[[]schema.Autocomplete] "An aggregation of courses for use in generating autocomplete DAGs"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
func AutocompleteDAG(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
defer cancel()

var autocompleteDAG []schema.Autocomplete
Expand Down
6 changes: 3 additions & 3 deletions api/controllers/calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var cometCalendarCollection *mongo.Collection = configs.GetCollection("cometCale
// @Success 200 {object} schema.APIResponse[schema.MultiBuildingEvents[schema.Event]] "All CometCalendarEvents with events on the inputted date"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
func CometCalendarEvents(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

date := c.Param("date")
Expand Down Expand Up @@ -63,7 +63,7 @@ func CometCalendarEvents(c *gin.Context) {
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 404 {object} schema.APIResponse[string] "A string describing the error"
func CometCalendarEventsByBuilding(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

date := c.Param("date")
Expand Down Expand Up @@ -135,7 +135,7 @@ func CometCalendarEventsByBuilding(c *gin.Context) {
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 404 {object} schema.APIResponse[string] "A string describing the error"
func CometCalendarEventsByBuildingAndRoom(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

date := c.Param("date")
Expand Down
4 changes: 2 additions & 2 deletions api/controllers/club.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 400 {object} schema.APIResponse[string] "A string describing the error"
func ClubDirectoryInfo(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

var clubsDatabase *sql.DB = configs.ConnectClubsDB()
Expand Down Expand Up @@ -88,7 +88,7 @@ func ClubDirectoryInfo(c *gin.Context) {
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 400 {object} schema.APIResponse[string] "A string describing the error"
func ClubSearch(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

var clubsDatabase *sql.DB = configs.ConnectClubsDB()
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/controller_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func respond[T any](c *gin.Context, status int, message string, data T) {
func getQuery[T any](flag string, c *gin.Context) (bson.M, error) {
switch flag {
case "Search":
query, err := schema.FilterQuery[T](c)
query, err := schema.FilterQuery[T](c.Request.URL.Query())
if err != nil {
respond(c, http.StatusBadRequest, "Invalid query parameters", err.Error())
return nil, err
Expand Down
13 changes: 5 additions & 8 deletions api/controllers/course.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ var courseCollection *mongo.Collection = configs.GetCollection("courses")
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
// @Failure 400 {object} schema.APIResponse[string] "A string describing the error"
func CourseSearch(c *gin.Context) {
//name := c.Query("name") // value of specific query parameter: string
//queryParams := c.Request.URL.Query() // map of all query params: map[string][]string

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

var courses []schema.Course
Expand Down Expand Up @@ -122,7 +119,7 @@ func CourseById(c *gin.Context) {
// @Success 200 {object} schema.APIResponse[[]schema.Course] "All courses"
// @Failure 500 {object} schema.APIResponse[string] "A string describing the error"
func CourseAll(c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 30*time.Second)
defer cancel()

var courses []schema.Course
Expand Down Expand Up @@ -223,7 +220,7 @@ func CourseProfessorById(c *gin.Context) {

// courseAggregate is a generic function that gets a specified field of the courses, filters depending on the flag
func courseAggregate[T any](flag string, c *gin.Context) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(c.Request.Context(), 10*time.Second)
defer cancel()

var queryResults []T
Expand All @@ -243,6 +240,7 @@ func courseAggregate[T any](flag string, c *gin.Context) {
}

// Determine the endpoint based on the type of the desired query results

var zero T
var endpoint string
switch any(zero).(type) {
Expand Down Expand Up @@ -295,7 +293,7 @@ func buildCoursePipeline(endpoint string, courseQuery bson.M, paginate map[strin
var lookupStages, dedupStages mongo.Pipeline
switch endpoint {
case "sections":
lookupStages, dedupStages = mongo.Pipeline{}, mongo.Pipeline{}
// No extra stages middle stages

case "professors":
// Lookup the list of professors from the list of sections
Expand Down Expand Up @@ -336,7 +334,6 @@ func buildCoursePipeline(endpoint string, courseQuery bson.M, paginate map[strin
middleStages := append(append(lookupStages, replaceStages...), dedupStages...)

paginateStages := mongo.Pipeline{
// Keep order deterministic between calls
bson.D{{Key: "$sort", Value: bson.D{{Key: "_id", Value: 1}}}},

paginate["latter_offset"],
Expand Down
Loading
Loading