semantic bufo search find-bufo.com
bufo
at main 29 lines 950 B view raw
1use anyhow::{Context, Result}; 2use std::env; 3 4#[derive(Clone, Debug)] 5pub struct Config { 6 pub host: String, 7 pub port: u16, 8 pub turbopuffer_api_key: String, 9 pub turbopuffer_namespace: String, 10 pub voyage_api_key: String, 11} 12 13impl Config { 14 pub fn from_env() -> Result<Self> { 15 Ok(Config { 16 host: env::var("HOST").unwrap_or_else(|_| "0.0.0.0".to_string()), 17 port: env::var("PORT") 18 .unwrap_or_else(|_| "8080".to_string()) 19 .parse() 20 .context("failed to parse PORT")?, 21 turbopuffer_api_key: env::var("TURBOPUFFER_API_KEY") 22 .context("TURBOPUFFER_API_KEY must be set")?, 23 turbopuffer_namespace: env::var("TURBOPUFFER_NAMESPACE") 24 .unwrap_or_else(|_| "bufos".to_string()), 25 voyage_api_key: env::var("VOYAGE_API_TOKEN") 26 .context("VOYAGE_API_TOKEN must be set")?, 27 }) 28 } 29}