100HP
  1. DDL-example
100HP
  • 100HP API for partners v2.9.1
    • General
      • Overview
      • FAQ
        • Rollback and billing resolver general flow
        • HTTP status codes and custom error codes
        • IP Whitelisting
    • Integration
      • Preparation for integration
      • General API provision
    • 100HP Gaming API
      • Game list
      • Launch game url
      • Video replay
    • 100HP Game flow API
      • Player authorization
      • Get balance
      • Withdrawal money
      • Deposit money
      • Rollback money
    • Implementation Guide
      • YourCasino.js
      • Casino.js
      • TestCasino.js
      • DDL-example
        • mongodb.js
        • mysql.js
        • postgres.js
    • Testing
      • Automated Test Service
    • API INFO
      • API Changelog
  1. DDL-example

mysql.js

import mysql from 'mysql';
import * as util from 'node:util';

export default ({ user, password, database, host, port }) => {

  const pool = mysql.createPool({
    user, password, database, host, port,
  });

  console.log('[mysql]: Connected to database', host);

  pool.query = util.promisify(pool.query);
  pool.queryRow = (...args) => pool.query(...args).then(res => res[0]);
  pool.getConnection = util.promisify(pool.getConnection);

  const originalGetConnection = pool.getConnection;

  pool.getConnection = async function (...args) {
    const connection = await originalGetConnection.apply(this, args);

    if (!connection.query[util.promisify.custom]) {
      connection.query = util.promisify(connection.query);
    }

    connection.queryRow = (...qArgs) =>
      connection.query(...qArgs).then((rows) => rows[0]);

    return connection;
  };

  return pool;
};
Modified at 2026-01-28 14:18:55
Previous
mongodb.js
Next
postgres.js
Built with