diff --git a/src/connections/cloudflare.ts b/src/connections/cloudflare.ts index 3c4580c..b4b2c11 100644 --- a/src/connections/cloudflare.ts +++ b/src/connections/cloudflare.ts @@ -2,6 +2,12 @@ import { QueryType } from '../query-params' import { Query, constructRawQuery } from '../query' import { Connection } from './index' +export type CloudflareD1ConnectionDetails = { + apiKey: string, + accountId: string, + databaseId: string +}; + export class CloudflareD1Connection implements Connection { // The Cloudflare API key with D1 access apiKey: string | undefined @@ -16,11 +22,13 @@ export class CloudflareD1Connection implements Connection { * account ID, and database ID. * * @param apiKey - The API key to be used for authentication. + * @param accountId - The account ID to be used for authentication. + * @param databaseId - The database ID to be used for querying. */ - constructor(apiKey: string, accountId: string, databaseId: string) { - this.apiKey = apiKey - this.accountId = accountId - this.databaseId = databaseId + constructor(private _: CloudflareD1ConnectionDetails) { + this.apiKey = _.apiKey; + this.accountId = _.accountId; + this.databaseId = _.databaseId; } /** diff --git a/src/connections/outerbase.ts b/src/connections/outerbase.ts index 22d6fb0..3519e5d 100644 --- a/src/connections/outerbase.ts +++ b/src/connections/outerbase.ts @@ -3,6 +3,10 @@ import { Query, constructRawQuery } from '../query' import { Connection } from './index' export const API_URL = 'https://app.outerbase.com' +export type OuterbaseConnectionDetails = { + apiKey: string +}; + export class OuterbaseConnection implements Connection { // The API key used for Outerbase authentication api_key: string | undefined @@ -15,8 +19,10 @@ export class OuterbaseConnection implements Connection { * * @param apiKey - The API key to be used for authentication. */ - constructor(private apiKey: string) { - this.api_key = apiKey + constructor(private _: { + apiKey: string + }) { + this.api_key = _.apiKey; } /** diff --git a/tests/connections/cloudflare.test.ts b/tests/connections/cloudflare.test.ts index 74d9249..5112aa2 100644 --- a/tests/connections/cloudflare.test.ts +++ b/tests/connections/cloudflare.test.ts @@ -5,11 +5,11 @@ import { QueryType } from 'src/query-params' describe('CloudflareD1Connection', () => { describe('Query Type', () => { - const connection = new CloudflareD1Connection( - 'API_KEY', - 'ACCOUNT_ID', - 'DATABASE_ID' - ) + const connection = new CloudflareD1Connection({ + apiKey: 'API_KEY', + accountId: 'ACCOUNT_ID', + databaseId: 'DATABASE_ID' + }) test('Query type is set to positional', () => { expect(connection.queryType).toBe(QueryType.positional) diff --git a/tests/connections/outerbase.test.ts b/tests/connections/outerbase.test.ts index 83205e0..4597001 100644 --- a/tests/connections/outerbase.test.ts +++ b/tests/connections/outerbase.test.ts @@ -5,7 +5,9 @@ import { QueryType } from 'src/query-params' describe('OuterbaseConnection', () => { describe('Query Type', () => { - const connection = new OuterbaseConnection('FAKE_API_KEY') + const connection = new OuterbaseConnection({ + apiKey: 'FAKE_API_KEY' + }) test('Query type is set to named', () => { expect(connection.queryType).toBe(QueryType.named) diff --git a/tests/to-string.test.ts b/tests/to-string.test.ts index 1bb505c..e36396f 100644 --- a/tests/to-string.test.ts +++ b/tests/to-string.test.ts @@ -5,7 +5,9 @@ import { Outerbase, equals, equalsNumber } from 'src/index' describe('toString', () => { describe('SELECT statements', () => { - const connection = new OuterbaseConnection('FAKE_API_KEY') + const connection = new OuterbaseConnection({ + apiKey: 'FAKE_API_KEY' + }) const db = Outerbase(connection) test('Select from one table, one column', () => { @@ -62,7 +64,9 @@ describe('toString', () => { }) describe('queryBuilder - Reserved keywords get quotes', () => { - const connection = new OuterbaseConnection('FAKE_API_KEY') + const connection = new OuterbaseConnection({ + apiKey: 'FAKE_API_KEY' + }) const db = Outerbase(connection) test('toString – Not reserved keyword "users" is not wrapped in quotes', () => {