feature/authentication service #9
1
apps/api/src/helpers.rs
Normal file
1
apps/api/src/helpers.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod database;
|
||||||
13
apps/api/src/helpers/database.rs
Normal file
13
apps/api/src/helpers/database.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#[macro_export]
|
||||||
|
macro_rules! with_conn {
|
||||||
|
// Usage: with_conn!(connection, tx_option, ident, |conn|-> { ... })
|
||||||
|
($conn:expr, $tx:expr, $ident:ident, $body:block) => {{
|
||||||
|
if let Some(t) = $tx {
|
||||||
|
let $ident = t;
|
||||||
|
$body
|
||||||
|
} else {
|
||||||
|
let $ident = $conn;
|
||||||
|
$body
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
mod cmd;
|
mod cmd;
|
||||||
mod configs;
|
mod configs;
|
||||||
mod errors;
|
mod errors;
|
||||||
|
mod helpers;
|
||||||
mod log;
|
mod log;
|
||||||
mod middlewares;
|
mod middlewares;
|
||||||
mod routes;
|
mod routes;
|
||||||
|
|||||||
Reference in New Issue
Block a user