mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Mysql connection strings, unit tests, prettier on server
This adds support for the other type of Mysql connection string specified by mysql async. Support for both strings and their respective options are necessary to support backwards compatibility of existing server configurations. This also adds support for jest & unit testing on the server/client and some unit tests for some of the connection string parsing. It runs these test and prettier in a pre-commit hook.
This commit is contained in:
1 parent
8d2e0d9edb
commit
a5d1e54b56
21 files changed
+4136
-505
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { ESX } from './server';
|
||||
import { pool } from './db';
|
||||
import { ESX } from "./server";
|
||||
import { pool } from "./db";
|
||||
|
||||
//db = DatabaseConfig //helper variable for use in server function
|
||||
|
||||
@@ -13,22 +13,22 @@ interface Credentials {
|
||||
phone_number: string;
|
||||
}
|
||||
|
||||
async function getCredentials(identifier: string) : Promise<string> {
|
||||
async function getCredentials(identifier: string): Promise<string> {
|
||||
const query = "SELECT phone_number FROM users WHERE identifier = ?";
|
||||
const [ result ] = await pool.query(query, [identifier]);
|
||||
const [result] = await pool.query(query, [identifier]);
|
||||
const number = <Credentials[]>result;
|
||||
if (number.length === 0) return "###-####";
|
||||
return number[0].phone_number;
|
||||
}
|
||||
|
||||
onNet('phone:getCredentials', async () => {
|
||||
onNet("phone:getCredentials", async () => {
|
||||
try {
|
||||
const _source = (global as any).source;
|
||||
const xPlayer = ESX.GetPlayerFromId(_source);
|
||||
const _identifier = xPlayer.getIdentifier();
|
||||
const number = await getCredentials(_identifier);
|
||||
emitNet('phone:sendCredentials', _source, number)
|
||||
emitNet("phone:sendCredentials", _source, number);
|
||||
} catch (error) {
|
||||
console.log('Failed to get number. ', error);
|
||||
};
|
||||
});
|
||||
console.log("Failed to get number. ", error);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user