Files
speckle-server/packages/frontend-2/server/plugins/001-devLogsSync.ts
T
Kristaps Fabians Geikins 9d9a456b28 chore(fe2): upgrade to nuxt 4 (#5306)
* actual npm update

* migrating plugin

* fix hydration (todo redis)

* fix dashboard title

* linting fixes

* fix ssr dev logs

* fix shared build

* more linting fixes

* more lint fixes

* preview dockerfile fix

* fix max stack trace issue
2025-08-27 10:26:32 +03:00

26 lines
727 B
TypeScript

import { getContext } from 'unctx'
import { consola, type ConsolaInstance } from 'consola'
import { AsyncLocalStorage } from 'node:async_hooks'
interface DevLogsServerContext {
consola: ConsolaInstance
}
const asyncContext = getContext<DevLogsServerContext>('nuxt-dev-logs', {
asyncContext: true,
AsyncLocalStorage
})
/**
* Importing `consola` from a nuxt plugin scope will give us a different instance. We have to pass through the nitro version
* through an async context.
*/
export default defineNitroPlugin((nitroApp) => {
if (!import.meta.dev) return
const handler = nitroApp.h3App.handler
nitroApp.h3App.handler = (event) => {
return asyncContext.callAsync({ consola }, () => handler(event))
}
})