Some checks failed
Code Analysis and Production Deploy / analyze (push) Successful in 2m49s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 1m54s
Code Analysis and Production Deploy / analyze (pull_request) Failing after 11s
Code Analysis and Production Deploy / deploy-production (pull_request) Has been skipped
Code Analysis and Production Deploy / deploy-test (pull_request) Has been skipped
- Updated Footer.vue to show the application version for logged-in users. - Added a new API endpoint to return the application version from package.json. - Enhanced code-analysis.yml to require package version changes for main PRs.
26 lines
682 B
JavaScript
26 lines
682 B
JavaScript
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()
|
|
}
|
|
})
|