a9ae6d4506
La página del reino pasa de /novawow-realm (fija) a una ruta dinámica app/[locale]/[realm] cuyo slug es <nombre-del-reino>-realm, con el nombre tomado de acore_auth.realmlist (LIMIT 1). Ej.: realm «Trinity» → /trinity-realm. realmSlug() normaliza el nombre (minúsculas, sin espacios). Si el slug no coincide con el reino actual → notFound(). Convive con el catch-all [...rest] y las rutas estáticas mantienen prioridad (verificado: /login, /account OK; /foo y /novawow-realm → 404). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
20 lines
629 B
TypeScript
20 lines
629 B
TypeScript
import type { RowDataPacket } from 'mysql2'
|
|
import { db, DB } from './db'
|
|
|
|
/** Nombre del reino desde acore_auth.realmlist (LIMIT 1, por si hay varios). */
|
|
export async function getRealmName(): Promise<string> {
|
|
try {
|
|
const [rows] = await db(DB.auth).query<RowDataPacket[]>(
|
|
'SELECT name FROM realmlist ORDER BY id LIMIT 1',
|
|
)
|
|
return rows[0]?.name || 'NovaWoW'
|
|
} catch {
|
|
return 'NovaWoW'
|
|
}
|
|
}
|
|
|
|
/** Slug del reino para la URL (p. ej. «Nova WoW» → «novawow», «Trinity» → «trinity»). */
|
|
export function realmSlug(name: string): string {
|
|
return name.toLowerCase().replace(/[^a-z0-9]/g, '')
|
|
}
|