Skip to content

Commit

Permalink
Release alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
JijoBose committed Jan 8, 2024
1 parent 33c7cc3 commit 1bf5239
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always
Expand All @@ -20,7 +22,9 @@ jobs:
run: cargo test --verbose

deploy:
if: startsWith(github.ref, 'refs/tags/v')
# if: startsWith(github.ref, 'refs/tags/v')
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
runs-on: ubuntu-latest
steps:
- uses: shuttle-hq/deploy-action@main
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
test.db
.DS_Store
Secrets.toml
.env
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ env_logger = "0.10"
log = "0.4"
strum_macros = "0.25.3"
strum = { version = "0.25.0", features = ["derive"]}
shuttle-actix-web = "0.35.1"
shuttle-runtime = "0.35.1"
shuttle-actix-web = "0.35.2"
shuttle-runtime = "0.35.2"
tokio = "1.35.1"
59 changes: 26 additions & 33 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
use actix_web::{middleware::Logger, web::{self}, App, HttpServer};
use actix_web::{
web::ServiceConfig,
web::{self},
};
use shuttle_actix_web::ShuttleActixWeb;

pub mod app;
pub mod schema;

use app::api::home::{
all_homes,
add_home,
find_home,
delete_home
};

use app::api::room::{add_room, get_room};
use app::api::home::{add_home, all_homes, delete_home, find_home};
use app::api::item::{add_item, get_items};
use app::api::room::{add_room, get_room};

use app::db::{
initialize_db_pool,
initial_migration
};
use app::db::{initial_migration, initialize_db_pool};

// #[cfg(debug_assertions)]
#[actix_web::main]
async fn main() -> std::io::Result<()> {
#[shuttle_runtime::main]
async fn main() -> ShuttleActixWeb<impl FnOnce(&mut ServiceConfig) + Send + Clone + 'static> {
dotenvy::dotenv().ok();
std::env::set_var("RUST_LOG", "debug");
std::env::set_var("RUST_BACKTRACE", "1");
Expand All @@ -31,21 +25,20 @@ async fn main() -> std::io::Result<()> {
log::info!("starting HTTP server at http://localhost:8080");
initial_migration();

HttpServer::new(move || {
let logger = Logger::default();
App::new()
.app_data(web::Data::new(pool.clone()))
.wrap(logger)
.service(all_homes)
.service(add_home)
.service(find_home)
.service(delete_home)
.service(add_room)
.service(get_room)
.service(get_items)
.service(add_item)
})
.bind(("127.0.0.1", 8080))?
.run()
.await
let config = move |cfg: &mut ServiceConfig| {
cfg.app_data(web::Data::new(pool.clone()));
// Homes
cfg.service(all_homes);
cfg.service(add_home);
cfg.service(find_home);
cfg.service(delete_home);
// Rooms
cfg.service(add_room);
cfg.service(get_room);
// Items
cfg.service(add_item);
cfg.service(get_items);
};

Ok(config.into())
}

0 comments on commit 1bf5239

Please sign in to comment.