misc: migrated existing to new helper

This commit is contained in:
Sheen Capadngan
2024-10-26 03:18:57 +08:00
parent 3552119c7d
commit 3841394eb7
6 changed files with 13 additions and 94 deletions
@@ -1,8 +1,10 @@
import { getConfig } from "@app/lib/config/env";
import { BadRequestError } from "@app/lib/errors";
import { getDbConnectionHost } from "@app/lib/knex";
export const verifyHostInputValidity = (host: string) => {
const appCfg = getConfig();
const dbHost = appCfg.DB_HOST || getDbConnectionHost(appCfg.DB_CONNECTION_URI);
if (
appCfg.isCloud &&
@@ -12,7 +14,7 @@ export const verifyHostInputValidity = (host: string) => {
)
throw new BadRequestError({ message: "Invalid db host" });
if (host === "localhost" || host === "127.0.0.1") {
if (host === "localhost" || host === "127.0.0.1" || dbHost === host) {
throw new BadRequestError({ message: "Invalid db host" });
}
};