mirror of
https://github.com/rommapp/romm.git
synced 2026-12-06 07:54:18 +01:00
simplify pass. `v2/router/routes.ts` hand-maintained 34 route-name string literals and a comment saying ROUTES could not be imported without a cycle. `routeNames.ts` is a leaf, so that constraint is gone: key the registry off ROUTES and type it with the new `RouteName`, which turns a mistyped key into a compile error instead of a silent fall-through to the 404 view. Drop the unreachable chunk-load guard in the 401 interceptor: `main.ts` imports the router statically, so it is in the entry chunk and the dynamic import resolves from memory. Restate why that import is lazy. Take `SimpleRom` instead of re-narrowing it, reuse the import specifier already in `router.ts`, drop `circular: true` (already the default), and inline the test roms so the factory is not duplicated across two files. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
export const ROUTES = {
|
|
SETUP: "setup",
|
|
LOGIN: "login",
|
|
RESET_PASSWORD: "reset-password",
|
|
REGISTER: "register",
|
|
MAIN: "main",
|
|
HOME: "home",
|
|
SEARCH: "search",
|
|
MUSIC: "music",
|
|
PLATFORM: "platform",
|
|
COLLECTION: "collection",
|
|
VIRTUAL_COLLECTION: "virtual-collection",
|
|
SMART_COLLECTION: "smart-collection",
|
|
ROM: "rom",
|
|
EMULATORJS: "emulatorjs",
|
|
JSDOS: "jsdos",
|
|
PICO8: "pico8",
|
|
RUFFLE: "ruffle",
|
|
STREAM: "stream",
|
|
STREAM_DESKTOP: "stream-desktop",
|
|
SCAN: "scan",
|
|
UPLOAD: "upload",
|
|
ACTIVITY: "activity",
|
|
USER_PROFILE: "user-profile",
|
|
USER_INTERFACE: "user-interface",
|
|
LIBRARY_MANAGEMENT: "library-management",
|
|
SCAN_SETTINGS: "scan-settings",
|
|
METADATA_SOURCES: "metadata-sources",
|
|
CLIENT_API_TOKENS: "client-api-tokens",
|
|
ADMINISTRATION: "administration",
|
|
SERVER_STATS: "server-stats",
|
|
LOGS: "logs",
|
|
PAIR: "pair",
|
|
PAIR_DEVICE: "pair-device",
|
|
APRIL_FOOLS: "april-fools",
|
|
CONSOLE_HOME: "console-home",
|
|
CONSOLE_PLATFORM: "console-platform",
|
|
CONSOLE_COLLECTION: "console-collection",
|
|
CONSOLE_SMART_COLLECTION: "console-smart-collection",
|
|
CONSOLE_VIRTUAL_COLLECTION: "console-virtual-collection",
|
|
CONSOLE_ROM: "console-rom",
|
|
CONSOLE_PLAY: "console-play",
|
|
PLATFORMS_INDEX: "platforms-index",
|
|
COLLECTIONS_INDEX: "collections-index",
|
|
CONTROLLER_DEBUG: "controller-debug",
|
|
NOT_FOUND: "404",
|
|
} as const;
|
|
|
|
export type RouteName = (typeof ROUTES)[keyof typeof ROUTES];
|
|
|
|
const authExemptRoutes = [
|
|
ROUTES.LOGIN,
|
|
ROUTES.SETUP,
|
|
ROUTES.RESET_PASSWORD,
|
|
ROUTES.REGISTER,
|
|
ROUTES.PAIR,
|
|
] as const;
|
|
|
|
type AuthExemptRoute = (typeof authExemptRoutes)[number];
|
|
|
|
export function isAuthExemptRoute(route: string): route is AuthExemptRoute {
|
|
return (authExemptRoutes as readonly string[]).includes(route);
|
|
}
|