mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
initial database integration for twitter
This commit is contained in:
1 parent
660e171789
commit
c19d0ee3aa
7 files changed
+182
-8
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import mysql from 'mysql2/promise';
|
||||
import { ConnectionStringParser } from "connection-string-parser";
|
||||
|
||||
const CONNECTION_STRING = 'mysql_connection_string';
|
||||
// we require set mysql_connection_string "mysql://root:password@localhost/es_extended?charset=utf8mb4" to be set in the config
|
||||
const mysqlConnectionString = GetConvar(CONNECTION_STRING, null);
|
||||
if (mysqlConnectionString === null) {
|
||||
throw new Error(`No connection string provided. make sure ${CONNECTION_STRING} is set in your config.`)
|
||||
}
|
||||
|
||||
const connectionStringParser = new ConnectionStringParser({ scheme: 'mysql', hosts: []});
|
||||
const connectionOjbect = connectionStringParser .parse(mysqlConnectionString);
|
||||
|
||||
export const pool = mysql.createPool({
|
||||
host: connectionOjbect.hosts[0].host,
|
||||
user: connectionOjbect.username,
|
||||
password: connectionOjbect.password,
|
||||
database: connectionOjbect.endpoint,
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0
|
||||
});
|
||||
Reference in new issue
Block a user