Cleanup MySQL unix socket code and add to sample config

This commit is contained in:
wiz 2022-03-14 13:11:04 +00:00
parent 465529b03f
commit 2023d36603
No known key found for this signature in database
GPG Key ID: A394E332255A6173
3 changed files with 8 additions and 6 deletions

View File

@ -44,6 +44,7 @@
"ENABLED": true,
"HOST": "127.0.0.1",
"PORT": 3306,
"SOCKET": "/var/run/mysql/mysql.sock",
"DATABASE": "mempool",
"USERNAME": "mempool",
"PASSWORD": "mempool"

View File

@ -43,7 +43,7 @@ interface IConfig {
DATABASE: {
ENABLED: boolean;
HOST: string,
SOCKET: string | undefined,
SOCKET: string,
PORT: number;
DATABASE: string;
USERNAME: string;
@ -122,7 +122,7 @@ const defaults: IConfig = {
'DATABASE': {
'ENABLED': true,
'HOST': '127.0.0.1',
'SOCKET': undefined,
'SOCKET': '',
'PORT': 3306,
'DATABASE': 'mempool',
'USERNAME': 'mempool',

View File

@ -15,10 +15,11 @@ export class DB {
timezone: '+00:00',
}
if (config.DATABASE.SOCKET && config.DATABASE.SOCKET != "")
poolConfig.socketPath = config.DATABASE.SOCKET
else
poolConfig.host = config.DATABASE.HOST
if (config.DATABASE.SOCKET !== "") {
poolConfig.socketPath = config.DATABASE.SOCKET;
} else {
poolConfig.host = config.DATABASE.HOST;
}
return poolConfig;
}