mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
DB: Removed need for password and added docs
This commit is contained in:
1 parent
2b52612f65
commit
c91d0729fb
3 files changed
+19
-12
No files matched your search
@@ -4,7 +4,16 @@ The original repo for NPWD
|
||||
|
||||
TODO
|
||||
|
||||
## Production Server Installation
|
||||
### Production Server Installation
|
||||
|
||||
**Database**
|
||||
|
||||
NPWD uses its own database driver compatible with `mysql-async` and `ghmattimysql`'s connection string. If you
|
||||
don't utilize these resources, ensure you have this set in your console.
|
||||
|
||||
```
|
||||
set mysql_connection_string "server=127.0.0.1;database=es_extended;userid=user;password=pass"
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
|
||||
@@ -8,14 +8,13 @@ describe("parseSemiColonFormat", () => {
|
||||
});
|
||||
|
||||
it("Correctly parses configuration options", () => {
|
||||
const test =
|
||||
"server=127.0.0.1;database=es_extended;userid=user;password=pass";
|
||||
const test = "server=127.0.0.1;database=es_extended;userid=user;";
|
||||
const result = db.parseSemiColonFormat(test);
|
||||
|
||||
expect(result.server).toEqual("127.0.0.1");
|
||||
expect(result.database).toEqual("es_extended");
|
||||
expect(result.userid).toEqual("user");
|
||||
expect(result.password).toEqual("pass");
|
||||
expect(result.password).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -80,9 +79,9 @@ describe("getUserId", () => {
|
||||
});
|
||||
|
||||
describe("getPassword", () => {
|
||||
it("returns default", () => {
|
||||
expect(() => db.getPassword({})).toThrowError();
|
||||
});
|
||||
// it("returns default", () => {
|
||||
// expect(() => db.getPassword({})).toThrowError();
|
||||
// });
|
||||
|
||||
it("Correctly returns password", () => {
|
||||
expect(db.getPassword({ password: t })).toEqual(t);
|
||||
|
||||
@@ -15,7 +15,7 @@ export function parseSemiColonFormat(connectionString: string): Map {
|
||||
const parts = connectionString.split(";");
|
||||
if (parts.length === 1) {
|
||||
throw new Error(
|
||||
`Connection string ${connectionString} is in the incorrect format.`
|
||||
`Connection string ${connectionString} is in the incorrect format. Please follow the README.`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,13 +59,12 @@ export function getUserId(config: Map): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: We are allowing no password as many FiveM servers love to not use one for an ungodly reason.
|
||||
* allowed variable names: password | pwd
|
||||
* @param config - database config variables parsed from mysql_connection_string
|
||||
*/
|
||||
export function getPassword(config: Map): string {
|
||||
export function getPassword(config: Map): string | undefined {
|
||||
const password = config.password || config.pwd;
|
||||
if (!password) {
|
||||
throw new Error("Password is a required field");
|
||||
}
|
||||
if (!password) return undefined;
|
||||
return password;
|
||||
}
|
||||
Reference in new issue
Block a user