Skip to content

Commit 635f7ed

Browse files
committed
Cleanup code
1 parent 710a8dd commit 635f7ed

File tree

6 files changed

+20
-23
lines changed

6 files changed

+20
-23
lines changed

src/export/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// import { enqueueOperation, processNextOperation } from '../operation';
2-
31
import { DataSource } from "..";
42
import { executeTransaction } from "../operation";
53

src/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ export interface Env {
1717

1818
// External database source details
1919
EXTERNAL_DB_TYPE?: string;
20-
EXTERNAL_DB_HOST?: string;
21-
EXTERNAL_DB_NAME?: string;
22-
EXTERNAL_DB_USER?: string;
23-
EXTERNAL_DB_PASS?: string;
24-
EXTERNAL_DB_PORT?: string;
20+
OUTERBASE_API_KEY?: string;
2521

2622
// ## DO NOT REMOVE: TEMPLATE INTERFACE ##
2723
}
@@ -50,6 +46,19 @@ type DatabaseStub = DurableObjectStub & {
5046
executeTransaction(queries: { sql: string; params?: any[] }[], isRaw: boolean): any[];
5147
};
5248

49+
enum RegionLocationHint {
50+
AUTO = 'auto',
51+
WNAM = 'wnam', // Western North America
52+
ENAM = 'enam', // Eastern North America
53+
SAM = 'sam', // South America
54+
WEUR = 'weur', // Western Europe
55+
EEUR = 'eeur', // Eastern Europe
56+
APAC = 'apac', // Asia Pacific
57+
OC = 'oc', // Oceania
58+
AFR = 'afr', // Africa
59+
ME = 'me', // Middle East
60+
}
61+
5362
export default {
5463
/**
5564
* This is the standard fetch handler for a Cloudflare Worker
@@ -113,8 +122,7 @@ export default {
113122
durableObject: stub as unknown as DatabaseStub,
114123
},
115124
externalConnection: {
116-
// TODO: Should the API key instead live in the `wrangler.toml` file instead of request headers?
117-
outerbaseApiKey: request.headers.get('X-Outerbase-Source-Token') ?? url.searchParams.get('outerbaseApiKey') ?? '',
125+
outerbaseApiKey: env.OUTERBASE_API_KEY ?? ''
118126
},
119127
};
120128

src/literest/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ export class LiteREST {
179179
}
180180

181181
private async buildSelectQuery(tableName: string, id: string | undefined, searchParams: URLSearchParams): Promise<{ query: string, params: any[] }> {
182-
console.log('Building SELECT Query');
183-
184182
let query = `SELECT * FROM ${tableName}`;
185183
const params: any[] = [];
186184
const conditions: string[] = [];

src/operation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function executeQuery(sql: string, params: any | undefined, isRaw:
5555

5656
let results: any = await response.json();
5757
let items = results.response.results?.items;
58-
return this.afterQuery(sql, items, isRaw, dataSource);
58+
return afterQuery(sql, items, isRaw, dataSource);
5959
}
6060
}
6161

@@ -92,7 +92,7 @@ export async function executeTransaction(queries: { sql: string; params?: any[]
9292

9393
const result: any = await response.json();
9494
const items = result.response.results?.items;
95-
results.push(this.afterQuery(query.sql, items, isRaw, dataSource));
95+
results.push(afterQuery(query.sql, items, isRaw, dataSource));
9696
}
9797

9898
return results;

worker-configuration.d.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
interface Env {
44
AUTHORIZATION_TOKEN: "ABC123";
5+
REGION: "auto";
56
EXTERNAL_DB_TYPE: "postgres";
6-
EXTERNAL_DB_HOST: "";
7-
EXTERNAL_DB_NAME: "";
8-
EXTERNAL_DB_USER: "";
9-
EXTERNAL_DB_PASS: "";
10-
EXTERNAL_DB_PORT: "0";
7+
OUTERBASE_API_KEY: "";
118
DATABASE_DURABLE_OBJECT: DurableObjectNamespace<import("./src/index").DatabaseDurableObject>;
129
}

wrangler.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,4 @@ REGION = "auto"
3838
# External database source details
3939
# This enables Starbase to connect to an external data source
4040
EXTERNAL_DB_TYPE = "postgres"
41-
EXTERNAL_DB_HOST = ""
42-
EXTERNAL_DB_NAME = ""
43-
EXTERNAL_DB_USER = ""
44-
EXTERNAL_DB_PASS = ""
45-
EXTERNAL_DB_PORT = "0"
41+
OUTERBASE_API_KEY = ""

0 commit comments

Comments
 (0)