Skip to content

Events and hooks

This page describes runtime events and Feathers hooks that are useful when diagnosing a nuxt-feathers-zod application.

Authentication events

useAuthRuntime() exposes a session event history. The current event types cover:

EventMeaning
ensure-startSession verification started.
ensure-finishSession verification finished.
session-syncGeneral session synchronization.
sso-session-syncSSO session synchronization.
feathers-session-syncFeathers session synchronization.
authenticateExplicit authentication.
reauth-skippedRestore skipped.
reauth-successRestore succeeded.
reauth-failureRestore failed.
logoutLogout.
keycloak-client-sessionClient-side Keycloak session detected.
keycloak-bridge-successKeycloak to Feathers bridge succeeded.
keycloak-bridge-fallbackKeycloak bridge fallback.
keycloak-bearer-validatedBearer token validated.
keycloak-bearer-missingBearer token missing.
protected-page-readyProtected page authorized.
protected-page-blockedProtected page blocked.

Reading events

ts
const auth = useAuthRuntime()
const snapshot = auth.getStateSnapshot()

console.log(snapshot.events)

Clearing diagnostics

ts
const auth = useAuthRuntime()
auth.clearEvents()
auth.resetDiagnostics()

Feathers hooks

Feathers hooks are the best entry point for tracing business calls.

ts
export const traceHook = async (context, next) => {
  const startedAt = Date.now()

  try {
    await next()
    console.info('service:success', {
      path: context.path,
      method: context.method,
      duration: Date.now() - startedAt,
    })
  }
  catch (error) {
    console.error('service:error', {
      path: context.path,
      method: context.method,
      duration: Date.now() - startedAt,
      error,
    })
    throw error
  }
}

Recommendation

For a business application, combine:

  • useAuthRuntime() events for session diagnostics;
  • around, before, after and error hooks for services;
  • server logs for infrastructure;
  • domain stores or composables for the UI.

nuxt-feathers-zod module documentation