0c957ed9cc
* frontend update works * starting viewer resources saved view tests * test fix * viewerResources new resolver + adjustment for home views * create/update view fixing up and tests * sort of works? * fixing more race conditions * loading preview * disable home view stuff when federated * fixing up links * tests and home view fix
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { useApolloClientFromNuxt } from '~~/lib/common/composables/graphql'
|
|
import { useAuthCookie } from '~~/lib/auth/composables/auth'
|
|
|
|
export default defineNuxtPlugin(() => {
|
|
const logger = useLogger()
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
|
|
if (!import.meta.dev) return
|
|
if (!import.meta.client) return
|
|
|
|
logger.debug('🚧 Running FE2 in dev mode, extra debugging tools may be available...')
|
|
|
|
const authToken = useAuthCookie()
|
|
const debugRoutes = route.query.debugRoutes === '1'
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-expect-error
|
|
window.AUTH_TOKEN = {
|
|
set: (newVal?: string) => (authToken.value = newVal || undefined),
|
|
get: () => authToken.value
|
|
}
|
|
|
|
const client = useApolloClientFromNuxt()
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-expect-error
|
|
window.APOLLO_CLIENT = client
|
|
|
|
if (debugRoutes) {
|
|
// Debug navigations
|
|
router.beforeEach((to, from) => {
|
|
logger.debug(`BEFORE:\n${from.fullPath} to\n${to.fullPath}`)
|
|
})
|
|
|
|
router.afterEach((to, from) => {
|
|
logger.debug(`AFTER:\n${from.fullPath} to\n${to.fullPath}`)
|
|
})
|
|
}
|
|
|
|
return {
|
|
provide: {
|
|
debugRoutes
|
|
}
|
|
}
|
|
})
|