Skip to content

feat: api foundation#15

Open
realtlos wants to merge 21 commits into
mainfrom
feat/api
Open

feat: api foundation#15
realtlos wants to merge 21 commits into
mainfrom
feat/api

Conversation

@realtlos
Copy link
Copy Markdown
Contributor

@realtlos realtlos commented Mar 15, 2026

Platform Configs

  • Add config structs for Discord, Spotify, Kick, Anilist, Trakt, FFZ, STV, BTTV, Steam
  • Update exampleconfig.json with all new platform blocks

Read Routes

  • GET /channels returns all joined channels
  • GET /emotes/stats emote usage stats with optional filters and pagination
  • GET /emotes/history/{login} recent emote history for a channel
  • GET /channel/command-settings fetch command overrides (auth required)

Write Routes

  • PATCH /users/me/settings update the authenticated users settings
  • PATCH /channels/me/settings update a channels settings (broadcaster/ambassador/admin only)
  • PUT /channel/command-settings upsert command overrides for a channel
  • DELETE /channel/command-settings reset a command override back to defaults

Database

  • Add GetAllChannels, GetCommandSettings, GetChannelAmbassadors, GetEmoteStats, GetEmoteHistory
  • Add UpdateUserSettings, UpdateChannelSettings, UpsertCommandSettings, ResetCommandSettings
  • Add UpsertOAuthToken

Auth Routes

  • GET /auth/discord/authorize · GET /auth/discord redirect OAuth flow for Discord
  • GET /auth/discord/join bot invite redirect
  • GET /auth/spotify/authorize · GET /auth/spotify redirect OAuth flow for Spotify
  • GET /auth/kick/authorize · GET /auth/kick PKCE OAuth flow for Kick
  • GET /auth/anilist/authorize · GET /auth/anilist redirect OAuth flow for AniList
  • GET /auth/trakt/authorize · GET /auth/trakt redirect OAuth flow for Trakt
  • GET /auth/ffz/authorize · GET /auth/ffz redirect OAuth flow for FFZ
  • GET /auth/steam/authorize · GET /auth/steam OpenID 2.0 flow for Steam

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 0% with 1413 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
api/routes/get/auth.go 0.00% 623 Missing ⚠️
common/db/postgres.go 0.00% 178 Missing ⚠️
api/routes/get/emotes.go 0.00% 164 Missing ⚠️
api/routes/patch/settings.go 0.00% 99 Missing ⚠️
common/db/clickhouse.go 0.00% 78 Missing ⚠️
api/routes/put/command_settings.go 0.00% 56 Missing ⚠️
api/routes/del/command_settings.go 0.00% 53 Missing ⚠️
api/routes/get/command_settings.go 0.00% 51 Missing ⚠️
api/routes/get/ambassadors.go 0.00% 44 Missing ⚠️
api/routes/get/channels.go 0.00% 28 Missing ⚠️
... and 7 more

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Flag Coverage Δ
go 0.38% <0.00%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
api/api.go 0.00% <0.00%> (ø)
api/middleware/context.go 0.00% <0.00%> (ø)
common/utils/broker.go 0.00% <0.00%> (ø)
main.go 0.00% <0.00%> (ø)
common/db/loops.go 0.00% <0.00%> (ø)
api/routes/get/help.go 0.00% <0.00%> (ø)
api/middleware/authorize.go 0.00% <0.00%> (ø)
api/routes/get/channels.go 0.00% <0.00%> (ø)
api/routes/get/ambassadors.go 0.00% <0.00%> (ø)
api/routes/get/command_settings.go 0.00% <0.00%> (ø)
... and 7 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR lays the groundwork for a broader “API foundation” by expanding platform configuration, adding new API endpoints (read/write + OAuth), and extending database clients (Postgres/ClickHouse) to support those endpoints.

Changes:

  • Add config structs + example config blocks for multiple third-party platforms (Discord/Spotify/Kick/AniList/Trakt/FFZ/7TV/BTTV/Steam).
  • Introduce new API routes for channel listing, emote stats/history, command settings CRUD, user/channel settings updates, and multiple OAuth flows.
  • Extend Postgres and ClickHouse clients with new query/update methods used by the new endpoints.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
uploader/uploader.go Adds linter suppression on response writes.
redirects/redirects_test.go Adds linter suppression in tests.
main.go Blank-imports new route packages so init()-based route registration runs.
haste/haste.go Adds linter suppression on response writes.
exampleconfig.json Adds new platform configuration blocks to the example config.
common/utils/requests.go Adds linter suppression on outbound HTTP request execution.
common/types.go Adds new platform enums and new API response/data types for channels/emotes/reminders; expands settings structs.
common/db/redis.go Adds linter suppression for default host string literal.
common/db/postgres.go Adds new channel/settings/command-settings/reminders/OAuth token DB methods and small logic adjustments.
common/db/loops.go Uses exec.CommandContext for backup command execution.
common/db/clickhouse.go Adds ClickHouse emote stats and emote history query helpers + options struct.
common/config.go Adds platform config structs and fields to the global config model.
api/routes/put/command_settings.go Adds PUT upsert endpoint for command settings with auth checks.
api/routes/post/redirects.go Adds linter suppression on response writes.
api/routes/patch/settings.go Adds PATCH endpoints to update user and channel settings with authorization checks.
api/routes/get/login.go Adds linter suppression on outbound HTTP request execution.
api/routes/get/emotes.go Adds GET emote stats + emote history endpoints with filtering and pagination cursor support.
api/routes/get/command_settings.go Adds authenticated GET endpoint for per-channel command settings with authorization checks.
api/routes/get/channels.go Adds public GET endpoint returning all joined channels.
api/routes/get/auth.go Adds OAuth / OpenID flows for multiple platforms (Discord/Spotify/Kick/AniList/Trakt/FFZ/Steam) plus helper utilities.
api/routes/del/command_settings.go Adds DELETE endpoint intended to reset command overrides to defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/routes/get/auth.go Outdated
Comment thread api/routes/get/emotes.go Outdated
Comment thread api/routes/get/emotes.go Outdated
Comment thread api/routes/del/command_settings.go Outdated
Comment thread api/routes/get/auth.go Outdated
Comment thread api/routes/get/auth.go Outdated
Comment thread api/routes/get/auth.go Outdated
Comment thread api/routes/get/auth.go Outdated
Extract IsChannelAuthorized and GetTwitchPlatformID into
api/middleware/authorize.go, replacing four separate identical
implementations across get, del, put, and patch route packages.
Copy link
Copy Markdown

@RingoMar RingoMar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! Works but I had some problems please confirm if same for you.

Small nitpicks as well.

#S00N

Image

Comment thread common/db/loops.go Outdated
Comment thread common/utils/broker.go
Comment thread main.go
Comment thread exampleconfig.json
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MISC: It would be cool to have a way to import this configuration data directly from the bot. That way, we don’t end up re-entering the same info over and over. A simple two-argument script placed in the bot's scripts folder could handle this seamlessly.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 27 changed files in this pull request and generated 11 comments.

Comment thread common/db/clickhouse.go Outdated
Comment thread common/db/clickhouse.go Outdated
Comment thread api/routes/get/auth.go Outdated
Comment thread main.go Outdated
Comment thread common/types.go Outdated
Comment thread api/routes/patch/settings.go Outdated
Comment thread api/routes/get/emotes.go
Comment thread common/db/postgres.go Outdated
Comment thread common/utils/broker.go Outdated
Comment thread common/db/loops.go
Copy link
Copy Markdown

@RingoMar RingoMar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and fully working.

Comment thread common/db/postgres.go
Comment thread common/db/postgres.go Outdated
Comment thread common/db/postgres.go Outdated
Comment thread common/db/clickhouse.go Outdated
@realtlos realtlos requested a review from JoTurk May 19, 2026 03:48
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.

4 participants