This commit is contained in:
Benjamin Toby 2025-12-26 12:21:27 +01:00
parent 5caa604b8f
commit f1e0aa9fc4
3 changed files with 8 additions and 7 deletions

View File

@ -1,4 +1,3 @@
import path from "path";
import { import {
APIResponseObject, APIResponseObject,
ClientCrudFetchParams, ClientCrudFetchParams,
@ -24,16 +23,18 @@ export default async function clientCrudFetch<
try { try {
let pathname = basePath || ``; let pathname = basePath || ``;
pathname = path.join(pathname, String(table)); pathname += `/${String(table)}`;
if (targetId) { if (targetId) {
pathname = path.join(pathname, String(targetId)); pathname += `/${String(targetId)}`;
} }
if (query) { if (query) {
pathname = `${pathname}${serializeQuery(query)}`; pathname = `${pathname}${serializeQuery(query)}`;
} }
pathname = pathname.replace(/\/{2,}/g, "/");
pathname = apiOrigin pathname = apiOrigin
? `${apiOrigin}/${pathname}`.replace(/([^:]\/)\/+/g, "$1") ? `${apiOrigin}/${pathname}`.replace(/([^:]\/)\/+/g, "$1")
: pathname; : pathname;

View File

@ -13,20 +13,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.default = clientCrudFetch; exports.default = clientCrudFetch;
const path_1 = __importDefault(require("path"));
const serialize_query_1 = __importDefault(require("../../package-shared/utils/serialize-query")); const serialize_query_1 = __importDefault(require("../../package-shared/utils/serialize-query"));
const fetch_1 = __importDefault(require("../fetch")); const fetch_1 = __importDefault(require("../fetch"));
function clientCrudFetch(_a) { function clientCrudFetch(_a) {
return __awaiter(this, arguments, void 0, function* ({ table, basePath, body, query, targetId, method = "GET", apiOrigin, headers, }) { return __awaiter(this, arguments, void 0, function* ({ table, basePath, body, query, targetId, method = "GET", apiOrigin, headers, }) {
try { try {
let pathname = basePath || ``; let pathname = basePath || ``;
pathname = path_1.default.join(pathname, String(table)); pathname += `/${String(table)}`;
if (targetId) { if (targetId) {
pathname = path_1.default.join(pathname, String(targetId)); pathname += `/${String(targetId)}`;
} }
if (query) { if (query) {
pathname = `${pathname}${(0, serialize_query_1.default)(query)}`; pathname = `${pathname}${(0, serialize_query_1.default)(query)}`;
} }
pathname = pathname.replace(/\/{2,}/g, "/");
pathname = apiOrigin pathname = apiOrigin
? `${apiOrigin}/${pathname}`.replace(/([^:]\/)\/+/g, "$1") ? `${apiOrigin}/${pathname}`.replace(/([^:]\/)\/+/g, "$1")
: pathname; : pathname;

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/datasquirel", "name": "@moduletrace/datasquirel",
"version": "5.6.2", "version": "5.6.3",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {