Skip to content

Sponsors 1#58

Open
NoelVarghese2006 wants to merge 6 commits intomainfrom
sponsors_1
Open

Sponsors 1#58
NoelVarghese2006 wants to merge 6 commits intomainfrom
sponsors_1

Conversation

@NoelVarghese2006
Copy link
Collaborator

feat(sponsors): implement sponsors public API with GCS logo support

Summary

This PR implements the backend for the Sponsors Public API, following the same architecture and patterns used by the existing schedule API.

It introduces full CRUD management for sponsors, superadmin routes for sponsor management, and a public endpoint used by the marketing site to retrieve sponsors with permanent logo URLs.

Additionally, the GCS client is extended to support generating permanent public URLs and signed image upload URLs for sponsor logos.


Changes

Database

  • Added migration 000023_create_sponsors.up/down.sql

  • Creates a sponsors table with fields for:

    • id
    • name
    • tier
    • logo_path
    • website_url
    • description
    • display_order
    • created_at
    • updated_at

Store Layer

  • Added internal/store/sponsors.go

  • Implemented SponsorsStore with:

    • List
    • Create
    • Update
    • Delete
    • GetByID
  • Wired the store into internal/store/storage.go


GCS Client

Extended the GCS client interface and implementation with:

  • GeneratePublicURL(objectPath string) string

    • Returns permanent public URLs for sponsor logos

    • Format:

      https://storage.googleapis.com/{bucket}/{path}
      
  • GenerateImageUploadURL(ctx, objectPath)

    • Generates signed PUT URLs for direct browser uploads to GCS
    • Supports image uploads (existing upload generator was restricted to PDFs)
  • Updated:

    • Client interface
    • MockClient for testing

API Handlers

Added sponsor API handlers in:

cmd/api/sponsors.go

Superadmin Routes

Mounted under:

/v1/superadmin/sponsors

Endpoints:

  • POST / → create sponsor
  • GET / → list sponsors
  • PUT /{id} → update sponsor metadata
  • DELETE /{id} → delete sponsor (best-effort logo deletion from GCS)
  • POST /{id}/logo-upload-url → generate signed upload URL for sponsor logo

Public Sponsors Endpoint

Added API-key-protected route:

GET /v1/public/sponsors

Returns:

  • sponsor metadata
  • logo_url generated via GeneratePublicURL

This endpoint is consumed by the marketing Next.js site.


Testing

  • Added and updated tests for:

    • sponsor CRUD handlers
    • logo upload URL generation
    • public sponsors endpoint
  • Updated mocks to support new GCS client methods.


Notes

  • Public logo URLs are permanent (not signed) so they can be safely used by the marketing site.
  • After deployment, the sponsors/ prefix in the GCS bucket will need to be made publicly readable.

Per project instructions, GCS bucket configuration is not modified in this PR.


This commit introduces the backend implementation for the sponsors public API, following the same patterns as the existing schedule public API.

The changes include:
- A new database migration to create the `sponsors` table.
- A `SponsorsStore` in the store layer with methods for listing, creating, updating, deleting, and retrieving sponsors by ID.
- Wiring the `SponsorsStore` into `internal/store/storage.go`.
- Adding a `GeneratePublicURL` method to the GCS client interface and implementation.
- Adding a separate image upload URL generator to the GCS client.
Adds `GeneratePublicURL` to the GCS client for generating permanent public URLs
(e.g. for logos) and `GenerateImageUploadURL` to support image uploads, as the
existing upload method is restricted to PDFs.

Updates the Client interface and MockClient to include these new methods.
Implements a full CRUD interface for managing sponsors, available to
superadmins under `/v1/superadmin/sponsors`. This includes creating,
listing, updating, and deleting sponsors, along with generating signed
URLs for direct-to-GCS logo uploads.

A new public, API-key-protected endpoint is also added at
`/v1/public/sponsors` to list all sponsors with their public logo URLs.

This is supported by:
- A new `Sponsors` store for database interactions.
- GCS client enhancements for generating public URLs and image-specific
  upload URLs.
@NoelVarghese2006 NoelVarghese2006 linked an issue Mar 15, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: sponsors public API (backend)

1 participant