mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-25 15:06:41 +07:00
initial
This commit is contained in:
commit
ddefc2743a
21 changed files with 873 additions and 0 deletions
18
src/config/index.ts
Normal file
18
src/config/index.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import yaml from 'js-yaml'
|
||||
import fs from 'fs'
|
||||
import path from 'path';
|
||||
import { Config } from './types';
|
||||
import { mergeRight } from 'ramda';
|
||||
import { validateConfig } from './validate';
|
||||
import logger from '../service/logger';
|
||||
|
||||
const defaultConfig = yaml.load<Config>(fs.readFileSync(path.join(__dirname, '../config.example.yml'), 'utf8'));
|
||||
const userConfig = yaml.load<Config>(fs.readFileSync(path.join(__dirname, '../config.yml'), 'utf8'));
|
||||
|
||||
const config = userConfig && mergeRight(defaultConfig, userConfig) || defaultConfig
|
||||
|
||||
export default function prepareConfig() {
|
||||
validateConfig(config)
|
||||
logger.debug('config is ok:', config)
|
||||
return config
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue