From b13b0f468420fc4f5242e9affc171bcdfab03024 Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Thu, 26 Sep 2024 14:04:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20MySQL=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=98=AF=E5=90=A6enbale=E7=9A=84=E9=85=8D=E7=BD=AE=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.ts | 1 + src/lib/Database/MySQLConnection.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/config.ts b/src/config.ts index 285d6ea..e01988b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -5,6 +5,7 @@ const config = { methods: ['GET', 'POST'] }, mysql: { + enable: false, host: 'localhost', port: 3306, database: '', diff --git a/src/lib/Database/MySQLConnection.ts b/src/lib/Database/MySQLConnection.ts index b72b181..f4fd8e7 100644 --- a/src/lib/Database/MySQLConnection.ts +++ b/src/lib/Database/MySQLConnection.ts @@ -12,6 +12,10 @@ class MySQLConnectPool { private logger = new Logger('MySQLConnection'); constructor() { + if(!config.mysql.enable){ + this.logger.warn('Database is disabled, initialization terminated'); + return; + } this.pool = this.createConnectPool(); this.logger.info("Database connection pool created") setTimeout(async () => {