mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-14 13:45:28 +01:00
37 lines
1 KiB
TypeScript
37 lines
1 KiB
TypeScript
|
import dotenv from 'dotenv';
|
||
|
import {injectable} from 'inversify';
|
||
|
import path from 'path';
|
||
|
dotenv.config();
|
||
|
|
||
|
export const DATA_DIR = path.resolve(process.env.DATA_DIR ? process.env.DATA_DIR : './data');
|
||
|
|
||
|
const CONFIG_MAP = {
|
||
|
DISCORD_TOKEN: process.env.DISCORD_TOKEN,
|
||
|
YOUTUBE_API_KEY: process.env.YOUTUBE_API_KEY,
|
||
|
SPOTIFY_CLIENT_ID: process.env.SPOTIFY_CLIENT_ID,
|
||
|
SPOTIFY_CLIENT_SECRET: process.env.SPOTIFY_CLIENT_SECRET,
|
||
|
DATA_DIR,
|
||
|
CACHE_DIR: path.join(DATA_DIR, 'cache')
|
||
|
} as const;
|
||
|
|
||
|
@injectable()
|
||
|
export default class Config {
|
||
|
readonly DISCORD_TOKEN!: string;
|
||
|
readonly YOUTUBE_API_KEY!: string;
|
||
|
readonly SPOTIFY_CLIENT_ID!: string;
|
||
|
readonly SPOTIFY_CLIENT_SECRET!: string;
|
||
|
readonly DATA_DIR!: string;
|
||
|
readonly CACHE_DIR!: string;
|
||
|
|
||
|
constructor() {
|
||
|
for (const [key, value] of Object.entries(CONFIG_MAP)) {
|
||
|
if (typeof value === 'undefined') {
|
||
|
console.error(`Missing environment variable for ${key}`);
|
||
|
process.exit(1);
|
||
|
}
|
||
|
|
||
|
this[key as keyof typeof CONFIG_MAP] = value;
|
||
|
}
|
||
|
}
|
||
|
}
|