Initial code commit.

This commit is contained in:
Simon Lindh
2019-07-21 17:59:47 +03:00
parent 534359ee76
commit 94132a903f
113 changed files with 5791 additions and 0 deletions

26
backend/src/database.ts Normal file
View File

@@ -0,0 +1,26 @@
const config = require('../mempool-config.json');
import { createPool } from 'mysql2/promise';
export class DB {
static pool = createPool({
host: config.DB_HOST,
port: config.DB_PORT,
database: config.DB_DATABASE,
user: config.DB_USER,
password: config.DB_PASSWORD,
connectionLimit: 10,
supportBigNumbers: true,
});
}
export async function checkDbConnection() {
try {
const connection = await DB.pool.getConnection();
console.log('MySQL connection established.');
connection.release();
} catch (e) {
console.log('Could not connect to MySQL.');
console.log(e);
process.exit(1);
}
}