60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
import os from 'os'
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __dirname = path.dirname(__filename)
|
|
|
|
export const config = {
|
|
get projectRoot(): string {
|
|
if (__dirname.includes('app.asar')) {
|
|
return path.resolve(__dirname, '..').replace('app.asar', 'app.asar.unpacked')
|
|
}
|
|
return path.resolve(__dirname, '../../')
|
|
},
|
|
|
|
get notebookRoot(): string {
|
|
return process.env.NOTEBOOK_ROOT
|
|
? path.resolve(process.env.NOTEBOOK_ROOT)
|
|
: path.join(this.projectRoot, 'notebook')
|
|
},
|
|
|
|
get tempRoot(): string {
|
|
return path.join(os.tmpdir(), 'xcdesktop_uploads')
|
|
},
|
|
|
|
get serverPort(): number {
|
|
return parseInt(process.env.PORT || '3001', 10)
|
|
},
|
|
|
|
get isVercel(): boolean {
|
|
return !!process.env.VERCEL
|
|
},
|
|
|
|
get isElectron(): boolean {
|
|
return __dirname.includes('app.asar')
|
|
},
|
|
|
|
get isDev(): boolean {
|
|
return !this.isElectron && !this.isVercel
|
|
},
|
|
|
|
get minimaxApiKey(): string | undefined {
|
|
return process.env.MINIMAX_API_KEY
|
|
},
|
|
|
|
get minimaxGroupId(): string | undefined {
|
|
return process.env.MINIMAX_GROUP_ID
|
|
},
|
|
|
|
get openaiApiKey(): string | undefined {
|
|
return process.env.OPENAI_API_KEY
|
|
},
|
|
}
|
|
|
|
export const PATHS = {
|
|
get PROJECT_ROOT() { return config.projectRoot },
|
|
get NOTEBOOK_ROOT() { return config.notebookRoot },
|
|
get TEMP_ROOT() { return config.tempRoot },
|
|
}
|