Skip to content

Commit

Permalink
update cli to start connector by default
Browse files Browse the repository at this point in the history
  • Loading branch information
pranshi06 committed Jun 5, 2024
1 parent 7eb3eb4 commit e8258a4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 41 deletions.
2 changes: 1 addition & 1 deletion connector-definition/.hasura-connector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ ENV HASURA_CONNECTOR_PORT=8080
# Expose the port specified by the HASURA_CONNECTOR_PORT environment variable
EXPOSE $HASURA_CONNECTOR_PORT

ENTRYPOINT [ "./dist/cli/index.js", "start" ]
ENTRYPOINT [ "./dist/cli/index.js" ]
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ supportedEnvironmentVariables:
default: "100"
commands:
update: docker run --rm -e AZURE_COSMOS_KEY="$AZURE_COSMOS_KEY" -e AZURE_COSMOS_DB_NAME="$AZURE_COSMOS_DB_NAME" -e AZURE_COSMOS_ENDPOINT="$AZURE_COSMOS_ENDPOINT" -v "$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH":/etc/connector ghcr.io/hasura/ndc-azure-cosmos:v0.1.1 update
start: docker run --rm -e AZURE_COSMOS_KEY="$AZURE_COSMOS_KEY" -e AZURE_COSMOS_DB_NAME="$AZURE_COSMOS_DB_NAME" -e AZURE_COSMOS_ENDPOINT="$AZURE_COSMOS_ENDPOINT" -v "$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH":/etc/connector ghcr.io/hasura/ndc-azure-cosmos:v0.1.1 start
32 changes: 30 additions & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { Command, Option } from "commander";
import * as updateCmd from "./update";
import * as startCmd from "./start";
import { createConnector } from "../connector";
import { version } from "../../package.json"
import * as sdk from "@hasura/ndc-sdk-typescript";
Expand All @@ -12,9 +11,38 @@ function main() {

program.addCommand(updateCmd.cmd);

program.addCommand(startCmd.cmd);
program.action(async (options: sdk.ServerOptions) => {
program.addOption(
new Option("--configuration <directory>")
.env("HASURA_CONFIGURATION_DIRECTORY")
.default(".")
)
program.addOption(
new Option("--port <port>")
.env("HASURA_CONNECTOR_PORT")
.default(8080)
.argParser(parseIntOption)
)
program.addOption(
new Option("--service-token-secret <secret>").env("HASURA_SERVICE_TOKEN_SECRET")
)
program.addOption(new Option("--log-level <level>").env("HASURA_LOG_LEVEL").default("info"))
program.addOption(new Option("--pretty-print-logs").env("HASURA_PRETTY_PRINT_LOGS").default(false))

const connector = createConnector();
await sdk.startServer(connector, options)
});

program.parse(process.argv);
}

function parseIntOption(value: string, _previous: number): number {
// parseInt takes a string and a radix
const parsedValue = parseInt(value, 10);
if (isNaN(parsedValue)) {
console.error("Not a valid integer.");
}
return parsedValue;
}

main()
37 changes: 0 additions & 37 deletions src/cli/start.ts

This file was deleted.

0 comments on commit e8258a4

Please sign in to comment.