From 268cda59234ee737978e6e5d0ae998549769ccdc Mon Sep 17 00:00:00 2001 From: Andrew Steiger Date: Tue, 21 May 2024 15:56:13 -0400 Subject: [PATCH] Updated to have a configurable scheme; support mock QB server that doesn't require HTTPS --- package.json | 8 ++++++-- src/code-generation/base.ts | 10 +++++++++- src/quickbase.ts | 10 +++++++++- src/tests/quickbase.ts | 1 + 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 11721741e..f1cdc17dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quickbase", - "version": "6.0.0", + "version": "6.0.1", "description": "A lightweight, typed, promise-based Quickbase API, autogenerated from the OpenAPI spec", "keywords": [ "QuickBase", @@ -22,7 +22,11 @@ "email": "contact@tristianflanagan.com" }, "maintainers": [], - "contributors": [], + "contributors": [{ + "name": "Andrew Steiger", + "email": "andrew@andrewsteiger.com", + "url": "https://github.com/7elephants" + }], "main": "./dist/quickbase.js", "types": "./dist/quickbase.d.ts", "repository": { diff --git a/src/code-generation/base.ts b/src/code-generation/base.ts index 4b442d43f..82514d638 100644 --- a/src/code-generation/base.ts +++ b/src/code-generation/base.ts @@ -147,6 +147,7 @@ export class QuickBase { * The default settings of a `QuickBase` instance */ static defaults: Required = { + scheme: 'https', server: 'api.quickbase.com', version: 'v1', realm: IS_BROWSER ? window.location.host.split('.')[0] : '', @@ -215,7 +216,7 @@ export class QuickBase { private getBaseRequest(){ return { method: 'GET', - baseURL: `https://${this.settings.server}/${this.settings.version}`, + baseURL: `${this.settings.scheme}://${this.settings.server}/${this.settings.version}`, headers: { 'Content-Type': 'application/json; charset=UTF-8', [IS_BROWSER ? 'X-User-Agent' : 'User-Agent']: `${this.settings.userAgent} node-quickbase/v${VERSION} ${IS_BROWSER ? (window.navigator ? window.navigator.userAgent : '') : 'nodejs/' + process.version}`.trim(), @@ -393,6 +394,13 @@ export class QuickBase { /* Types */ export type QuickBaseOptions = Partial<{ + /** + * Quickbase API Server scheme + * + * Default is `https` + */ + scheme: string; + /** * Quickbase API Server FQDN * diff --git a/src/quickbase.ts b/src/quickbase.ts index 5e7bd5caf..9d54827db 100644 --- a/src/quickbase.ts +++ b/src/quickbase.ts @@ -148,6 +148,7 @@ export class QuickBase { * The default settings of a `QuickBase` instance */ static defaults: Required = { + scheme: 'https', server: 'api.quickbase.com', version: 'v1', realm: IS_BROWSER ? window.location.host.split('.')[0] : '', @@ -216,7 +217,7 @@ export class QuickBase { private getBaseRequest(){ return { method: 'GET', - baseURL: `https://${this.settings.server}/${this.settings.version}`, + baseURL: `${this.settings.scheme}://${this.settings.server}/${this.settings.version}`, headers: { 'Content-Type': 'application/json; charset=UTF-8', [IS_BROWSER ? 'X-User-Agent' : 'User-Agent']: `${this.settings.userAgent} node-quickbase/v${VERSION} ${IS_BROWSER ? (window.navigator ? window.navigator.userAgent : '') : 'nodejs/' + process.version}`.trim(), @@ -1945,6 +1946,13 @@ export class QuickBase { /* Types */ export type QuickBaseOptions = Partial<{ + /** + * Quickbase API Server scheme + * + * Default is `https` + */ + scheme: string; + /** * Quickbase API Server FQDN * diff --git a/src/tests/quickbase.ts b/src/tests/quickbase.ts index 96b8e91bc..e82d600b5 100644 --- a/src/tests/quickbase.ts +++ b/src/tests/quickbase.ts @@ -20,6 +20,7 @@ const TEST_UTF_16 = process.env.TEST_UTF_16 === 'true'; const TEST_FILE = process.env.TEST_FILE === 'true'; const qbOptions: QuickBaseOptions = { + scheme: 'https', server: 'api.quickbase.com', version: 'v1',