Skip to content

Commit

Permalink
remove package json import
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Sep 20, 2024
1 parent 860c9da commit 26a13db
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/api/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
payloadJSON,
payloadSearchParams,
} from "../types";
import { version } from "../../package.json";
import fetch from "cross-fetch";
import log from "loglevel";
import { logPrefix } from "../utils";
Expand All @@ -26,10 +25,17 @@ enum RequestMethod {
export class Router {
private apiKey: string;
private apiVersion: string;
private packageVersion: string;

constructor(apiKey: string, apiVersion: string = "v1") {
constructor(
apiKey: string,
apiVersion: string = "v1",
// TODO: How to dynamically read without importing from pacakge.json
packageVersion: string = "0.2.4",
) {
this.apiKey = apiKey;
this.apiVersion = apiVersion;
this.packageVersion = packageVersion;
}
/**
* Allows a post to any route supported by DuneAPI.
Expand Down Expand Up @@ -86,7 +92,7 @@ export class Router {
method,
headers: {
"x-dune-api-key": this.apiKey,
"User-Agent": `client-sdk@${version} (https://www.npmjs.com/package/@duneanalytics/client-sdk)`,
"User-Agent": `client-sdk@${this.packageVersion} (https://www.npmjs.com/package/@duneanalytics/client-sdk)`,
"Content-Type": content_type,
},
// conditionally add the body property
Expand Down

0 comments on commit 26a13db

Please sign in to comment.