Compare commits

..

No commits in common. "092df2986918d94b90993b78212238463d60b612" and "0950a01f9609373f69e742cd897c35a4f73c0460" have entirely different histories.

2 changed files with 9 additions and 8 deletions

10
app.js
View File

@ -6,8 +6,6 @@ const NTFY = require('./lib/ntfy')
const Constants = require('./lib/constants')
new class LottoAutomation {
#configFilename = process.env.LOTTO_AUTOMATION_CONFIG_FILENAME ?? 'config.json'
#configPath = `${process.env.LOTTO_AUTOMATION_CONFIG_DIR ?? __dirname}/${this.#configFilename}`
#config = {}
#_start() {
@ -15,15 +13,15 @@ new class LottoAutomation {
setImmediate(this.#_buyLotto.bind(this))
}
#_loadConfig() {
if(!Fs.existsSync(this.#configPath))
throw new Error('config.json 파일이 존재하지 않습니다.')
if(!Fs.existsSync(Constants.CONFIG_PATH))
throw new Error('Config.json 파일이 존재하지 않습니다.')
try {
const configString = Fs.readFileSync(this.#configPath)
const configString = Fs.readFileSync(Constants.CONFIG_PATH)
this.#config = JSON.parse(configString)
NTFY.Init(this.#config.ntfyUrl, this.#config.ntfyToken)
} catch(e) {
throw new Error('config.json 파일이 올바르지 않습니다.')
throw new Error('Config.json 파일이 올바르지 않습니다.')
}
}
async #_buyLotto() {

View File

@ -36,6 +36,9 @@ class Constants {
'2': '반자동',
'3': '자동'
}
static CONFIG_FILENAME = process.env.LOTTO_AUTOMATION_CONFIG_FILENAME ?? 'Config.json'
static CONFIG_PATH = `${process.env.LOTTO_AUTOMATION_CONFIG_DIR ?? '.'}/${Constants.CONFIG_FILENAME}`
}
module.exports = Constants