@racla-dev/node-iris
Version:
TypeScript port of Python irispy-client module for KakaoTalk bot development
58 lines • 1.52 kB
JavaScript
;
/**
* Configuration management using environment variables
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const dotenv_1 = require("dotenv");
// Load environment variables from .env file
(0, dotenv_1.config)();
class Config {
constructor() {
this.config = this.loadConfig();
}
static getInstance() {
if (!Config.instance) {
Config.instance = new Config();
}
return Config.instance;
}
loadConfig() {
const irisUrl = process.env.IRIS_URL;
if (!irisUrl) {
throw new Error('IRIS_URL environment variable is required');
}
const maxWorkers = process.env.MAX_WORKERS
? parseInt(process.env.MAX_WORKERS)
: undefined;
const bannedUsers = process.env.BANNED_USERS
? process.env.BANNED_USERS.split(',').map((id) => id.trim())
: [];
return {
irisUrl,
maxWorkers,
bannedUsers,
};
}
get(key) {
return this.config[key];
}
getAll() {
return { ...this.config };
}
update(key, value) {
this.config[key] = value;
}
// Convenience getters
get irisUrl() {
return this.config.irisUrl;
}
get maxWorkers() {
return this.config.maxWorkers;
}
get bannedUsers() {
return this.config.bannedUsers || [];
}
}
exports.Config = Config;
//# sourceMappingURL=config.js.map