mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-12 11:56:06 -05:00
* bot can login to discord * changed node and npm to iron lts * added typescript runnables * more dev scripts * readme update on scripts * event handling skeleton * fixed compiler target issue
21 lines
626 B
TypeScript
21 lines
626 B
TypeScript
import { resolve } from "path"
|
|
import { config } from "dotenv"
|
|
|
|
// Find config - ONLY WORKS WITH NODEMON
|
|
const envFile = process.env.NODE_ENV === "development" ? ".dev.env" : ".env"
|
|
|
|
// resolve config file
|
|
const envFilePath = resolve(process.cwd(), envFile)
|
|
|
|
// set current environment variable file
|
|
config({ path: envFilePath })
|
|
|
|
// Getter for environment variables
|
|
export function getEnvVar(name: string, fallback?: string): string {
|
|
const value = process.env[name] ?? fallback
|
|
if (value == undefined)
|
|
throw new Error(`Environment variable ${name} is not set.`)
|
|
|
|
// return env variable
|
|
return value
|
|
} |