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
+3 -1
View File
@@ -8,11 +8,12 @@ type Params<T extends { [key: string]: any } = { [key: string]: any }> = {
tableName: string;
deleteSpec?: T & { deleteKeyValues?: SQLDeleteData<T>[] };
targetID?: string | number;
apiKey?: string;
};
export default async function apiCrudDELETE<
T extends { [key: string]: any } = { [key: string]: any }
>({ dbName, tableName, deleteSpec, targetID }: Params<T>) {
>({ dbName, tableName, deleteSpec, targetID, apiKey }: Params<T>) {
const basePath = grabAPIBasePath({ paradigm: "crud" });
const finalID = typeof targetID === "number" ? String(targetID) : targetID;
@@ -23,6 +24,7 @@ export default async function apiCrudDELETE<
method: "DELETE",
path: finalPath,
body: deleteSpec,
apiKey,
});
return GET_RES;
+3
View File
@@ -8,6 +8,7 @@ type Params<T extends { [key: string]: any } = { [key: string]: any }> = {
tableName: string;
query?: DsqlCrudQueryObject<T>;
targetId?: string | number;
apiKey?: string;
};
export default async function apiCrudGET<
@@ -17,6 +18,7 @@ export default async function apiCrudGET<
tableName,
query,
targetId,
apiKey,
}: Params<T>): Promise<APIResponseObject> {
const basePath = grabAPIBasePath({ paradigm: "crud" });
@@ -28,6 +30,7 @@ export default async function apiCrudGET<
method: "GET",
path: finalPath,
query,
apiKey,
});
return GET_RES;
+3
View File
@@ -10,6 +10,7 @@ export type APICrudPostParams<
tableName: string;
body: T;
update?: boolean;
apiKey?: string;
};
export default async function apiCrudPOST<
@@ -19,6 +20,7 @@ export default async function apiCrudPOST<
tableName,
body,
update,
apiKey,
}: APICrudPostParams<T>): Promise<APIResponseObject> {
const basePath = grabAPIBasePath({ paradigm: "crud" });
@@ -36,6 +38,7 @@ export default async function apiCrudPOST<
method: update ? "PUT" : "POST",
path: finalPath,
body,
apiKey,
});
return GET_RES;
+3 -1
View File
@@ -5,11 +5,12 @@ type Params<T extends { [key: string]: any } = { [key: string]: any }> = Omit<
"update"
> & {
targetID: string | number;
apiKey?: string;
};
export default async function apiCrudPUT<
T extends { [key: string]: any } = { [key: string]: any }
>({ dbName, tableName, body, targetID }: Params<T>) {
>({ dbName, tableName, body, targetID, apiKey }: Params<T>) {
const updatedBody = { ...body } as any;
if (targetID) {
@@ -21,5 +22,6 @@ export default async function apiCrudPUT<
tableName,
body: updatedBody,
update: true,
apiKey,
});
}