From fefea214d392c306d1b9c54baa9a5762d702e12c Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 20 Jun 2023 14:54:05 +0100 Subject: remove database --- src/main.rs | 62 +++++++++++++++++++++---------------------------------------- 1 file changed, 21 insertions(+), 41 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 833a7ae..ab65f8e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,41 +1,18 @@ -use rocket::fairing::{self, AdHoc}; -use rocket::fs::{relative, FileServer}; -use rocket::http::Status; -use rocket::State; -use rocket::{Build, Request, Rocket}; -use rocket_db_pools::sqlx; -use rocket_db_pools::Database; -use rocket_dyn_templates::{context, Template}; -use std::borrow::Cow; - +mod error; mod posts; mod scrobbles; mod skweets; -#[derive(Database)] -#[database("blossom")] -struct Blossom(sqlx::SqlitePool); +use std::borrow::Cow; -async fn run_migrations(rocket: Rocket) -> fairing::Result { - match Blossom::fetch(&rocket) { - Some(db) => match sqlx::migrate!().run(&**db).await { - Ok(_) => Ok(rocket), - Err(e) => { - error!("failed to init blossom database: {}", e); - Err(rocket) - } - }, - None => Err(rocket), - } -} +use rocket::fs::{relative, FileServer}; +use rocket::http::Status; +use rocket::{Request, State}; +use rocket_dyn_templates::{context, Template}; -fn stage() -> AdHoc { - AdHoc::on_ignite("blossom database stage", |rocket| async { - rocket - .attach(Blossom::init()) - .attach(AdHoc::try_on_ignite("database migrations", run_migrations)) - }) -} +use error::BlossomError; + +type Result = std::result::Result; struct Clients { listenbrainz: listenbrainz::raw::Client, @@ -46,13 +23,20 @@ struct Clients { extern crate rocket; #[get("/")] -async fn home(clients: &State) -> Result { +async fn home(clients: &State) -> Result