This commit is contained in:
Joshua Coles 2024-07-27 21:08:54 +01:00
parent eca0a825dc
commit 67827bd051
2 changed files with 24 additions and 11 deletions

View File

@ -1,9 +1,9 @@
use chrono::NaiveDate;
use sqlx::{Connection, PgConnection};
use toggl::TogglApi;
use worker::Worker;
mod sensitive;
mod server;
mod toggl;
mod worker;
@ -17,6 +17,9 @@ enum AppError {
#[error("User modified since time delta is too large. Max allowed is 90 days.")]
LookBackTooLarge,
#[error("IO error: {0}")]
IO(#[from] std::io::Error),
}
struct TableSummary {
@ -46,14 +49,5 @@ async fn main() {
let mut worker = Worker { db, toggl_api: api };
worker.update_tags().await.unwrap();
let start = NaiveDate::from_ymd_opt(2024, 2, 1).expect("Invalid date");
let end = NaiveDate::from_ymd_opt(2024, 2, 2).expect("Invalid date");
worker
.fetch_within(start, end)
.await
.expect("Failed to fetch time entries");
server::serve().await.expect("Failed to start server")
}

19
src/server.rs Normal file
View File

@ -0,0 +1,19 @@
use axum::{
http::StatusCode,
routing::{get, post},
Json, Router,
};
use crate::AppError;
pub async fn serve() -> Result<(), AppError> {
// build our application with a route
let app = Router::new();
// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
axum::serve(listener, app).await?;
Ok(())
}