Add a basic sync route
This commit is contained in:
+17
-1
@@ -1,3 +1,4 @@
|
||||
use axum::response::IntoResponse;
|
||||
use sqlx::{Connection, PgPool};
|
||||
use toggl::TogglApi;
|
||||
use worker::Worker;
|
||||
@@ -22,6 +23,19 @@ enum AppError {
|
||||
IO(#[from] std::io::Error),
|
||||
}
|
||||
|
||||
impl IntoResponse for AppError {
|
||||
fn into_response(self) -> axum::http::Response<axum::body::Body> {
|
||||
let status = match &self {
|
||||
AppError::SqlxError(_) => axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
AppError::TogglError(_) => axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
AppError::LookBackTooLarge => axum::http::StatusCode::BAD_REQUEST,
|
||||
AppError::IO(_) => axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
};
|
||||
|
||||
(status, self.to_string()).into_response()
|
||||
}
|
||||
}
|
||||
|
||||
struct TableSummary {
|
||||
client_ids: Vec<u64>,
|
||||
workspace_ids: Vec<u64>,
|
||||
@@ -49,5 +63,7 @@ async fn main() {
|
||||
|
||||
let worker = Worker { db, toggl_api };
|
||||
|
||||
server::serve().await.expect("Failed to start server")
|
||||
server::serve(
|
||||
worker
|
||||
).await.expect("Failed to start server")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user