Skip to content

Commit

Permalink
fix: API key interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Mar 12, 2024
1 parent cc5bea4 commit b9fb417
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion graph-gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub enum ApiKeys {
#[serde_as(as = "DisplayFromStr")]
url: Url,
/// Bearer auth token
auth: String,
auth: Hidden<String>,
/// API keys that won't be blocked for non-payment
#[serde(default)]
special: Vec<String>,
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ async fn main() {
};
let api_keys = match config.api_keys {
Some(ApiKeys::Endpoint { url, auth, .. }) => {
subgraph_studio::api_keys(http_client.clone(), url, auth)
subgraph_studio::api_keys(http_client.clone(), url, auth.0)
}
Some(ApiKeys::Fixed(api_keys)) => Eventual::from_value(Ptr::new(
api_keys
Expand Down
10 changes: 4 additions & 6 deletions graph-gateway/src/subgraph_studio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ pub struct APIKey {
pub key: String,
pub user_address: Address,
pub query_status: QueryStatus,
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
#[serde_as(as = "Option<serde_with::TryFromInto<f64>>")]
#[serde(rename = "max_budget")]
pub max_budget_usd: Option<NotNan<f64>>,
#[serde(default)]
pub deployments: Vec<DeploymentId>,
Expand All @@ -35,13 +36,10 @@ pub enum QueryStatus {

pub fn api_keys(
client: reqwest::Client,
mut url: Url,
url: Url,
auth: String,
) -> Eventual<Ptr<HashMap<String, Arc<APIKey>>>> {
let (writer, reader) = Eventual::new();
if !url.path().ends_with('/') {
url.set_path(&format!("{}/", url.path()));
}
let client: &'static Mutex<Client> = Box::leak(Box::new(Mutex::new(Client {
client,
url,
Expand Down Expand Up @@ -89,7 +87,7 @@ impl Client {

let response = self
.client
.get(self.url.join("gateway-api-keys")?)
.get(self.url.clone())
.bearer_auth(&self.auth)
.send()
.await?
Expand Down

0 comments on commit b9fb417

Please sign in to comment.