This commit is contained in:
Benjamin Toby
2025-07-05 15:16:31 +01:00
parent 7e8bb37c09
commit 3730e4722e
25 changed files with 58 additions and 22 deletions
@@ -10,7 +10,6 @@ import grabHostNames from "../../utils/grab-host-names";
import serializeQuery from "../../utils/serialize-query";
type Param<T = { [k: string]: any }> = {
key?: string;
body?: T;
query?: T;
useDefault?: boolean;
@@ -18,6 +17,7 @@ type Param<T = { [k: string]: any }> = {
method?:
| (typeof DataCrudRequestMethods)[number]
| (typeof DataCrudRequestMethodsLowerCase)[number];
apiKey?: string;
};
/**
@@ -27,12 +27,12 @@ export default async function queryDSQLAPI<
T = { [k: string]: any },
P = { [k: string]: any }
>({
key,
body,
query,
useDefault,
path: passedPath,
method,
apiKey,
}: Param<T>): Promise<APIResponseObject<P>> {
const grabedHostNames = grabHostNames({ useDefault });
const { host, port, scheme } = grabedHostNames;
@@ -49,7 +49,7 @@ export default async function queryDSQLAPI<
let headers: OutgoingHttpHeaders = {
"Content-Type": "application/json",
Authorization:
key ||
apiKey ||
(!method || method == "GET" || method == "get"
? process.env.DSQL_READ_ONLY_API_KEY
: undefined) ||