From 6495038aba28c332050768cecf062418a25d5a96 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Wed, 13 Aug 2025 17:42:42 +0100 Subject: remove schist_backend --- schist_backend/src/main.rs | 48 ---------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 schist_backend/src/main.rs (limited to 'schist_backend/src/main.rs') diff --git a/schist_backend/src/main.rs b/schist_backend/src/main.rs deleted file mode 100644 index 83da9b6..0000000 --- a/schist_backend/src/main.rs +++ /dev/null @@ -1,48 +0,0 @@ -use diesel::SqliteConnection; -use diesel_migrations::MigrationHarness; -use rocket::fairing::AdHoc; -use rocket::http::ContentType; -use rocket::{launch, routes, Build, Rocket}; -use schist_schema::migrations::MIGRATIONS; - -use crate::databases::UserDataDb; - -pub mod databases; -pub mod routes; - -fn run_database_migrations(connection: &mut SqliteConnection) { - connection - .run_pending_migrations(MIGRATIONS) - .expect("Error running database migrations"); -} - -#[launch] -async fn rocket() -> Rocket { - rocket::build() - .attach(UserDataDb::fairing()) - .attach(AdHoc::on_liftoff("Database Migration", |rocket| { - Box::pin(async move { - let user_data_db = UserDataDb::get_one(rocket).await.expect( - "Failed to get connection to user data database in order to run migrations", - ); - user_data_db.run(run_database_migrations).await; - }) - })) - .attach(AdHoc::on_response("Add CORS headers", |_req, res| { - Box::pin(async move { - res.set_header(ContentType::JSON); - res.set_header(rocket::http::Header::new( - "Access-Control-Allow-Origin", - "http://localhost:5173", - )); - }) - })) - .mount( - "/", - routes![ - routes::account::get_all_accounts, - routes::account::create_account, - routes::category::get_all_categories, - ], - ) -} -- cgit v1.2.3