Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (app *application) mount() http.Handler {
r.Route("/public", func(r chi.Router) {
r.Use(app.APIKeyMiddleware)
r.Get("/schedule", app.getPublicScheduleHandler)
r.Get("/sponsors", app.getPublicSponsorsHandler)
})

// Auth endpoints not handled by SuperTokens
Expand Down Expand Up @@ -218,6 +219,17 @@ func (app *application) mount() http.Handler {
r.Delete("/{scheduleID}", app.deleteScheduleHandler)
})
})

// Sponsors
r.Route("/sponsors", func(r chi.Router) {
r.Get("/", app.listSponsorsHandler)

// TODO: Protect Under a AdminSponsorEditPermissionMiddleware
r.Post("/", app.createSponsorHandler)
r.Put("/{sponsorID}", app.updateSponsorHandler)
r.Delete("/{sponsorID}", app.deleteSponsorHandler)
r.Post("/{sponsorID}/logo-upload-url", app.generateLogoUploadURLHandler)
})
})
})

Expand Down Expand Up @@ -251,7 +263,6 @@ func (app *application) mount() http.Handler {
r.Get("/", app.searchUsersHandler)
r.Patch("/{userID}/role", app.updateUserRoleHandler)
})

})
})
})
Expand Down
15 changes: 15 additions & 0 deletions cmd/api/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,18 @@ import (
func (app *application) getPublicScheduleHandler(w http.ResponseWriter, r *http.Request) {
app.listScheduleHandler(w, r)
}

// getPublicSponsorsHandler returns all sponsors (public, API key auth)
//
// @Summary Get sponsors (Public)
// @Description Returns all sponsors, ordered by display order, with public logo URLs
// @Tags public
// @Produce json
// @Param X-API-Key header string true "API Key"
// @Success 200 {object} SponsorListResponse
// @Failure 401 {object} object{error=string}
// @Failure 500 {object} object{error=string}
// @Router /public/sponsors [get]
func (app *application) getPublicSponsorsHandler(w http.ResponseWriter, r *http.Request) {
app.listSponsorsHandler(w, r)
}
7 changes: 4 additions & 3 deletions cmd/api/resume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestGenerateResumeUploadURL(t *testing.T) {
mockApps.On("GetByUserID", user.ID).Return(application, nil).Once()
mockGCS.On(
"GenerateUploadURL",
mock.Anything,
mock.MatchedBy(func(path string) bool {
return strings.HasPrefix(path, "resumes/"+user.ID+"/") && strings.HasSuffix(path, ".pdf")
}),
Expand Down Expand Up @@ -103,7 +104,7 @@ func TestGenerateResumeUploadURL(t *testing.T) {
user := newTestUser()
application := &store.Application{ID: "app-1", UserID: user.ID, Status: store.StatusDraft}
mockApps.On("GetByUserID", user.ID).Return(application, nil).Once()
mockGCS.On("GenerateUploadURL", mock.AnythingOfType("string")).Return("", errors.New("gcs failed")).Once()
mockGCS.On("GenerateUploadURL", mock.Anything, mock.AnythingOfType("string")).Return("", errors.New("gcs failed")).Once()

req, err := http.NewRequest(http.MethodPost, "/", nil)
require.NoError(t, err)
Expand Down Expand Up @@ -133,7 +134,7 @@ func TestDeleteResume(t *testing.T) {
}

mockApps.On("GetByUserID", user.ID).Return(application, nil).Once()
mockGCS.On("DeleteObject", resumePath).Return(nil).Once()
mockGCS.On("DeleteObject", mock.Anything, resumePath).Return(nil).Once()
mockApps.On("Update", mock.AnythingOfType("*store.Application")).Run(func(args mock.Arguments) {
updated := args.Get(0).(*store.Application)
assert.Nil(t, updated.ResumePath)
Expand Down Expand Up @@ -202,7 +203,7 @@ func TestGetResumeDownloadURL(t *testing.T) {
resumePath := "resumes/user-1/file.pdf"
application := &store.Application{ID: "app-1", ResumePath: &resumePath}
mockApps.On("GetByID", "app-1").Return(application, nil).Once()
mockGCS.On("GenerateDownloadURL", resumePath).Return("https://download.example.com", nil).Once()
mockGCS.On("GenerateDownloadURL", mock.Anything, resumePath).Return("https://download.example.com", nil).Once()

req, err := http.NewRequest(http.MethodGet, "/", nil)
require.NoError(t, err)
Expand Down
Loading
Loading