20 lines
691 B
JavaScript
20 lines
691 B
JavaScript
import path from "path";
|
|
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
|
import grabAPIBasePath from "../../utils/grab-api-base-path";
|
|
export default async function apiCrudPOST({ dbName, tableName, body, update, }) {
|
|
const basePath = grabAPIBasePath({ paradigm: "crud" });
|
|
const passedID = body.id;
|
|
const finalID = update
|
|
? typeof passedID === "number"
|
|
? String(passedID)
|
|
: passedID
|
|
: undefined;
|
|
const finalPath = path.join(basePath, dbName, tableName, finalID || "");
|
|
const GET_RES = await queryDSQLAPI({
|
|
method: update ? "PUT" : "POST",
|
|
path: finalPath,
|
|
body,
|
|
});
|
|
return GET_RES;
|
|
}
|