diff --git a/src/config.ts b/src/config.ts index eaf2ab0..34905bd 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,6 +2,7 @@ import { Client, checkKey } from './client.js'; import fsp from 'node:fs/promises'; import Ajv from 'ajv'; +import { existsSync } from 'node:fs'; const ajv = new Ajv(); const config_validate = ajv.compile({ @@ -30,6 +31,11 @@ export class Config { static async load(): Promise { const path = process.env.CONFIG_PATH ?? 'config.json'; + + if (!existsSync(path)) { + throw new Error(`The config file ${path} does not exist`); + } + const raw = JSON.parse( await fsp.readFile(path, { encoding: 'utf8' }), ) as Config;