From 070659c7b19d1700e05d6246c982a18a93d5939d Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 3 May 2024 18:00:43 +0100 Subject: [PATCH] Fixing an issue with typing + wrong parameter being passed to the direct Couch call functionality. --- packages/backend-core/src/db/couch/DatabaseImpl.ts | 8 +++++--- packages/backend-core/src/db/couch/utils.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/backend-core/src/db/couch/DatabaseImpl.ts b/packages/backend-core/src/db/couch/DatabaseImpl.ts index e10d0e58c6..b3fce7aa29 100644 --- a/packages/backend-core/src/db/couch/DatabaseImpl.ts +++ b/packages/backend-core/src/db/couch/DatabaseImpl.ts @@ -21,6 +21,7 @@ import { WriteStream, ReadStream } from "fs" import { newid } from "../../docIds/newid" import { SQLITE_DESIGN_DOC_ID } from "../../constants" import { DDInstrumentedDatabase } from "../instrumentation" +import { checkSlashesInUrl } from "../../helpers" const DATABASE_NOT_FOUND = "Database does not exist." @@ -252,17 +253,18 @@ export class DatabaseImpl implements Database { async _sqlQuery( url: string, method: "POST" | "GET", - body?: any + body?: Record ): Promise { + url = checkSlashesInUrl(`${this.couchInfo.sqlUrl}/${url}`) const args: { url: string; method: string; cookie: string; body?: any } = { - url: `${this.couchInfo.sqlUrl}/${url}`, + url, method, cookie: this.couchInfo.cookie, } if (body) { args.body = body } - const response = await directCouchUrlCall(body) + const response = await directCouchUrlCall(args) if (response.status > 300) { throw new Error(await response.text()) } diff --git a/packages/backend-core/src/db/couch/utils.ts b/packages/backend-core/src/db/couch/utils.ts index 005b02a896..270d953320 100644 --- a/packages/backend-core/src/db/couch/utils.ts +++ b/packages/backend-core/src/db/couch/utils.ts @@ -21,7 +21,7 @@ export async function directCouchUrlCall({ url: string cookie: string method: string - body?: any + body?: Record }) { const params: any = { method: method,