Skip to content

Commit

Permalink
remove debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Oct 24, 2023
1 parent 85b4c02 commit 9291611
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@
//! and then manage it internally using the name provided by the user.
//! This version is fully on-memory, and will drop every managed service
//! if killed.
use axum::{body::Body, extract::FromRef, routing::post, Router, Server};
use axum::{
body::Body,
extract::FromRef,
routing::{get, post},
Router, Server,
};
use hyper::client::HttpConnector;

use std::error::Error;

use tower_http::cors::{Any, CorsLayer};
use tracing::{debug, info};
use tracing::info;
use tracing_subscriber::{EnvFilter, FmtSubscriber};

mod db;
use db::{ProxifierDb, SqlxDb};
use db::SqlxDb;

mod docker_manager;
use docker_manager::DockerManager;
Expand Down Expand Up @@ -56,17 +61,12 @@ async fn main() -> Result<(), Box<dyn Error>> {

sqlx::any::install_default_drivers();

let mut db = SqlxDb::new_any("sqlite::memory:").await?;
let db = SqlxDb::new_any("sqlite::memory:").await?;

sqlx::migrate!("./migrations")
.run(db.get_pool_ref())
.await?;

let u1 = db.user_from_api_key("my-key").await?;
let u = db.user_add("ahah", Some("key2".to_string())).await?;

debug!("DB {:?}\n{:?}\n{:?}", db, u, u1);

let docker = DockerManager::new("katana");
let http: HttpClient = hyper::Client::builder().build(HttpConnector::new());

Expand All @@ -76,20 +76,19 @@ async fn main() -> Result<(), Box<dyn Error>> {
docker,
};

let _dev_cors = CorsLayer::new()
let dev_cors = CorsLayer::new()
.allow_methods(Any)
.allow_headers(Any)
.allow_origin(Any);

// db.user_add("glihm", Some("my-key".to_string())).await?;

// build our application with a route
let app = Router::new()
.route("/start", post(handlers::start_katana))
.route("/:name/stop", post(handlers::stop_katana))
.route("/:name/logs", post(handlers::logs_katana))
.route("/start", get(handlers::start_katana))
.route("/:name/stop", get(handlers::stop_katana))
.route("/:name/logs", get(handlers::logs_katana))
.route("/:name/katana", post(handlers::proxy_request_katana))
.with_state(state);
.with_state(state)
.layer(dev_cors);

let ip = "127.0.0.1:5050";
info!("{}", format!("📡 waiting for requests on http://{ip}..."));
Expand Down

0 comments on commit 9291611

Please sign in to comment.