feat: moderation locking (#5070)

* feat: base locking impl

* feat: lock logic in place in rev endpoint + fetch rev

* feat: frontend impl and finalize

* feat: auto skip if using the moderation queue page

* fix: qa issues

* fix: async state + locking fix

* fix: lint

* fix: fmt

* fix: qa issue

* fix: qa + redirect bug

* fix: lint

* feat: delete all locks endpoint for admins

* fix: dedupe

* fix: fmt

* fix: project redirect move to middleware

* fix: lint
This commit is contained in:
Calum H.
2026-01-12 17:08:30 +00:00
committed by GitHub
parent 915d8c68bf
commit b46f6d0141
21 changed files with 1644 additions and 321 deletions

View File

@@ -6,7 +6,7 @@ const CACHE_MAX_AGE = 60 * 10 // 10 minutes
export default defineCachedEventHandler(
async (event) => {
const client = useServerModrinthClient(event)
const client = useServerModrinthClient({ event })
const response = await client.request<Labrinth.Tags.v2.GameVersion[]>('/tag/game_version', {
api: 'labrinth',

View File

@@ -1,4 +1,4 @@
import { type NuxtClientConfig, NuxtModrinthClient } from '@modrinth/api-client'
import { AuthFeature, type NuxtClientConfig, NuxtModrinthClient } from '@modrinth/api-client'
import type { H3Event } from 'h3'
async function getRateLimitKeyFromSecretsStore(): Promise<string | undefined> {
@@ -11,14 +11,30 @@ async function getRateLimitKeyFromSecretsStore(): Promise<string | undefined> {
}
}
export function useServerModrinthClient(event: H3Event): NuxtModrinthClient {
const config = useRuntimeConfig(event)
export interface ServerModrinthClientOptions {
event?: H3Event
authToken?: string
}
export function useServerModrinthClient(options?: ServerModrinthClientOptions): NuxtModrinthClient {
const config = useRuntimeConfig(options?.event)
const apiBaseUrl = (config.apiBaseUrl || config.public.apiBaseUrl).replace('/v2/', '/')
const features = []
if (options?.authToken) {
features.push(
new AuthFeature({
token: options.authToken,
tokenPrefix: '',
}),
)
}
const clientConfig: NuxtClientConfig = {
labrinthBaseUrl: apiBaseUrl,
rateLimitKey: config.rateLimitKey || getRateLimitKeyFromSecretsStore,
features: [],
features,
}
return new NuxtModrinthClient(clientConfig)