Implement Labrinth Canary API flag (#5531)

This commit is contained in:
aecsocket
2026-03-11 15:28:09 +00:00
committed by GitHub
parent 086508be23
commit 3b21944a75
7 changed files with 71 additions and 1 deletions

View File

@@ -1,7 +1,9 @@
import {
type AuthConfig,
AuthFeature,
CanaryCookieFeature,
type FeatureConfig,
LABRINTH_CANARY_COOKIE,
type NuxtClientConfig,
NuxtModrinthClient,
} from '@modrinth/api-client'
@@ -20,6 +22,7 @@ async function getRateLimitKeyFromSecretsStore(): Promise<string | undefined> {
export interface ServerModrinthClientOptions {
event?: H3Event
authToken?: string
canaryCookie?: boolean
}
export function useServerModrinthClient(options?: ServerModrinthClientOptions): NuxtModrinthClient {
@@ -37,6 +40,10 @@ export function useServerModrinthClient(options?: ServerModrinthClientOptions):
)
}
if (options?.canaryCookie) {
features.push(new CanaryCookieFeature({ getCookie: () => LABRINTH_CANARY_COOKIE }))
}
const clientConfig: NuxtClientConfig = {
labrinthBaseUrl: apiBaseUrl,
rateLimitKey: config.rateLimitKey || getRateLimitKeyFromSecretsStore,