Skip to content

Commit

Permalink
refactor: re-structure api folders (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgehermo9 authored Oct 22, 2024
1 parent 6bb9f87 commit 2d7c143
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 14 deletions.
4 changes: 3 additions & 1 deletion crates/server/justfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# If there is a .env file located at `crates/server/.env`, it will be loaded automatically
set dotenv-load

# https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md
# The DATABASE_URL env var must be set to run those commands
# If there is a .env file located at `crates/server/.env`, it will be loaded automatically
prepare-check:
cargo sqlx prepare --check --workspace
prepare: # To be able to build the project in offline mode
cargo sqlx prepare --workspace
migrate:
cargo sqlx migrate run
run:
cargo run -p gq-server
2 changes: 2 additions & 0 deletions crates/server/src/api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod dtos;
pub mod routes;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::dtos::share_dto::{DataTypeDTO, ShareDTO};
use crate::routes;
use crate::services::share::GetShareError;
use crate::{
dtos::error_object::ErrorObject,
services::share::{CreateShareError, ShareService},
AppState,
};
use crate::api::dtos::error_object::ErrorObject;
use crate::api::dtos::share_dto::{DataTypeDTO, ShareDTO};
use crate::services::share::{CreateShareError, GetShareError, ShareService};

use crate::api::routes;
use crate::app_state::AppState;

use axum::{
extract::{Path, State},
http::{HeaderMap, StatusCode},
Expand Down
File renamed without changes.
9 changes: 4 additions & 5 deletions crates/server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use app_state::AppState;
use axum::Router;
use sqlx::PgPool;
use state::AppState;

pub mod dtos;
pub mod api;
pub mod app_state;
pub mod model;
pub mod routes;
pub mod services;
pub mod state;

pub fn app(db_connection: PgPool, max_share_expiration_time_secs: i64) -> Router {
let app_state = AppState::new(db_connection, max_share_expiration_time_secs);
routes::router(app_state)
api::routes::router(app_state)
}

0 comments on commit 2d7c143

Please sign in to comment.