Implement Labrinth Canary API flag (#5531)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user