File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import crypto from 'node:crypto'
2- import { readFileSync } from 'node:fs'
3- import { fileURLToPath } from 'node:url'
4- import { dirname , join } from 'node:path'
52import { H3 , HTTPError , handleCors , type H3Event } from 'h3'
63import type { CorsOptions } from 'h3'
74
@@ -26,19 +23,9 @@ import {
2623} from './npm-client.ts'
2724
2825// Read version from package.json
29- const __dirname = dirname ( fileURLToPath ( import . meta. url ) )
30- function getConnectorVersion ( ) : string {
31- try {
32- const pkgPath = join ( __dirname , '..' , 'package.json' )
33- const pkg = JSON . parse ( readFileSync ( pkgPath , 'utf-8' ) )
34- return pkg . version || '0.0.0'
35- } catch {
36- // Fallback if package.json can't be read (e.g., in bundled builds)
37- return '0.0.0'
38- }
39- }
26+ import pkg from '../package.json' with { type : 'json' }
4027
41- export const CONNECTOR_VERSION = getConnectorVersion ( )
28+ export const CONNECTOR_VERSION = pkg . version
4229
4330function generateToken ( ) : string {
4431 return crypto . randomBytes ( 16 ) . toString ( 'hex' )
You can’t perform that action at this time.
0 commit comments