const handlers: { [key: string]: Function[] } = {} export function onRouteRedirect (hook: string, handler: Function) { const list = handlers[hook] = handlers[hook] || [] list.push(handler) } export async function handleRouteRedirects (hook: string) { const fns = handlers[hook] if (fns) { for (const fn of fns) { const result = await fn() if (result != null) { return result } } } }