summaryrefslogtreecommitdiff
path: root/schist_backend/src/main.rs
diff options
context:
space:
mode:
authorJoe Carstairs <jcarstairs@scottlogic.com>2025-08-13 17:42:42 +0100
committerJoe Carstairs <jcarstairs@scottlogic.com>2025-08-13 17:43:23 +0100
commit6495038aba28c332050768cecf062418a25d5a96 (patch)
tree97debc923ef76051ad669a432b128265a3975173 /schist_backend/src/main.rs
parentee3cd780e21260257b401c3f5cbababd9e27a15a (diff)
remove schist_backend
Diffstat (limited to 'schist_backend/src/main.rs')
-rw-r--r--schist_backend/src/main.rs48
1 files changed, 0 insertions, 48 deletions
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<Build> {
- 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,
- ],
- )
-}