import { promises as fs } from 'fs' import path from 'path' import { getUserFromToken } from '../../utils/auth.js' async function readPackageVersion() { const packageJsonPath = path.join(process.cwd(), 'package.json') const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8')) return String(packageJson.version || '') } export default defineEventHandler(async (event) => { const token = getCookie(event, 'auth_token') const user = token ? await getUserFromToken(token) : null if (!user) { throw createError({ statusCode: 401, statusMessage: 'Nicht authentifiziert' }) } return { version: await readPackageVersion() } })