feat(#27): Set up consola logger, make use of log levels in backend and frontend

This commit is contained in:
2025-12-24 10:26:22 +01:00
parent 805c66bc4f
commit 7f7852a66a
36 changed files with 312 additions and 141 deletions

View File

@@ -1,9 +1,14 @@
import type { H3Event } from 'h3'
import { joinURL } from 'ufo'
import { jwtDecode } from 'jwt-decode'
import { createLogger } from '~~/shared/utils/logger'
export default defineEventHandler(async (event: H3Event) => {
const { serverApiBaseUrl, clientProxyBasePath } = useRuntimeConfig().public
const logger = createLogger({
level: useRuntimeConfig().public.logLevel,
tag: '🔀 proxy'
})
const escapedClientProxyBasePath = clientProxyBasePath.replace(/^\//, '\\/')
// Use the escaped value in the regex
const path = event.path.replace(new RegExp(`^${escapedClientProxyBasePath}`), '')
@@ -19,8 +24,10 @@ export default defineEventHandler(async (event: H3Event) => {
})
}
if (accessToken) console.log('🔀 [PROXY] Expiration:', new Date(jwtDecode(accessToken).exp! * 1000).toISOString())
console.log('🔀 [PROXY] Proxying request to:', target)
if (accessToken) {
logger.debug('Expiration:', new Date(jwtDecode(accessToken).exp! * 1000).toISOString())
}
logger.debug('Proxying request to:', target)
return proxyRequest(event, target, {
headers: {