Skip to content

Commit

Permalink
update to fix connector-metadata.yaml and add guard for env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
TristenHarr committed Mar 13, 2024
1 parent 3eeab7d commit 2af9e67
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This changelog documents changes between release tags.
## [Unreleased]
Upcoming changes for the next versioned release.

## [0.0.7]
* Fix the connector-metadata.yaml
* Add check for if environment variables are a blank string for optional env vars

## [0.0.6]
* Fixing github workflow

Expand Down
4 changes: 2 additions & 2 deletions connector-definition/connector-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
packagingDefinition:
type: PrebuiltDockerImage
dockerImage: ghcr.io/hasura/ndc-turso:0.0.6
dockerImage: ghcr.io/hasura/ndc-turso:v0.0.7
supportedEnvironmentVariables:
- name: TURSO_URL
description: The url for the Turso database
Expand All @@ -9,7 +9,7 @@ supportedEnvironmentVariables:
- name: TURSO_SYNC_URL
description: The Sync URL for Turso for replicas
commands:
update: docker run -it --rm -e TURSO_URL="$TURSO_URL" -e TURSO_AUTH_TOKEN="$TURSO_AUTH_TOKEN" -e TURSO_SYNC_URL="$TURSO_SYNC_URL" -v "$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH":/etc/connector ghcr.io/hasura/ndc-turso:0.0.6 update
update: docker run -it --rm -e TURSO_URL="$TURSO_URL" -e TURSO_AUTH_TOKEN="$TURSO_AUTH_TOKEN" -e TURSO_SYNC_URL="$TURSO_SYNC_URL" -v "$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH":/etc/connector ghcr.io/hasura/ndc-turso:v0.0.7 update
dockerComposeWatch:
- path: ./
target: /etc/connector
Expand Down
14 changes: 10 additions & 4 deletions generate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ import { BASE_FIELDS, BASE_TYPES } from "./src/constants";
import { Configuration, ObjectFieldDetails } from "./src";
const writeFile = promisify(fs.writeFile);

const url = process.env["TURSO_URL"] as string;
const syncUrl = process.env["TURSO_SYNC_URL"] as string | undefined;
const authToken = process.env["TURSO_AUTH_TOKEN"] as string | undefined;
let client = get_turso_client({ url: url, syncUrl: syncUrl, authToken: authToken});
const TURSO_URL = process.env["TURSO_URL"] as string;
let TURSO_SYNC_URL = process.env["TURSO_SYNC_URL"] as string | undefined;
if (TURSO_SYNC_URL?.length === 0){
TURSO_SYNC_URL = undefined;
}
let TURSO_AUTH_TOKEN = process.env["TURSO_AUTH_TOKEN"] as string | undefined;
if (TURSO_AUTH_TOKEN?.length === 0){
TURSO_AUTH_TOKEN = undefined;
}
let client = get_turso_client({ url: TURSO_URL, syncUrl: TURSO_SYNC_URL, authToken: TURSO_AUTH_TOKEN});

async function main() {
const tables_result = await client.execute(
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
{
"name": "ndc-turso",
"version": "0.0.6",
"version": "0.0.7",
"main": "index.js",
"author": "Tristen Harr",
"scripts": {
"start": "ts-node ./src/index.ts serve --configuration=configuration.json --service-token-secret=abc",
"start-bun": "bun run ./src/index.ts serve --configuration=configuration.json",
"start-server": "ts-node ./src/index.ts configuration serve",
"generate-config": "ts-node generate-config"
},
"scripts": {},
"dependencies": {
"@hasura/ndc-sdk-typescript": "^4.2.1",
"@json-schema-tools/meta-schema": "^1.7.0",
Expand Down
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ import { Client } from "@libsql/client/.";
import { readFileSync } from "fs"; // Import synchronous file read function

const TURSO_URL = process.env["TURSO_URL"] as string;
const TURSO_SYNC_URL = process.env["TURSO_SYNC_URL"] as string | undefined;
const TURSO_AUTH_TOKEN = process.env["TURSO_AUTH_TOKEN"] as string | undefined;
let TURSO_SYNC_URL = process.env["TURSO_SYNC_URL"] as string | undefined;
if (TURSO_SYNC_URL?.length === 0){
TURSO_SYNC_URL = undefined;
}
let TURSO_AUTH_TOKEN = process.env["TURSO_AUTH_TOKEN"] as string | undefined;
if (TURSO_AUTH_TOKEN?.length === 0){
TURSO_AUTH_TOKEN = undefined;
}


// import { do_update_configuration } from "./handlers/updateConfiguration";
Expand Down

0 comments on commit 2af9e67

Please sign in to comment.