summaryrefslogtreecommitdiff
path: root/backend/src/main.rs
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2024-09-17 11:28:56 +0100
committerJoe Carstairs <me@joeac.net>2024-09-17 11:28:56 +0100
commitf0e3e0cfb183253e03b1a61ddecb7b9330d47fdb (patch)
tree722eca369743dcfbb95f1efd58cc4cecc0fb8677 /backend/src/main.rs
parentc737b6df94eae4981bb03dda3583e24046e24865 (diff)
Refactors backend
Diffstat (limited to 'backend/src/main.rs')
-rw-r--r--backend/src/main.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/backend/src/main.rs b/backend/src/main.rs
index db47ceb..cdf4699 100644
--- a/backend/src/main.rs
+++ b/backend/src/main.rs
@@ -2,14 +2,17 @@ use diesel::SqliteConnection;
use diesel_migrations::MigrationHarness;
use diesel_migrations::{embed_migrations, EmbeddedMigrations};
use rocket::fairing::AdHoc;
+use rocket::http::ContentType;
use rocket::{launch, routes, Build, Rocket};
use crate::databases::UserDataDb;
pub mod databases;
pub mod models;
+pub mod queries;
pub mod routes;
pub mod schema;
+pub mod utils;
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
@@ -31,11 +34,23 @@ async fn rocket() -> Rocket<Build> {
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::account::create_account,
+ routes::balance::get_all_category_balances,
+ routes::budget::get_all_category_budgets,
+ routes::category::get_all_categories,
],
)
}