-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(paypal): store generated invoices to local filesystem
- Loading branch information
Showing
15 changed files
with
91 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
target | ||
.env | ||
result | ||
result-* | ||
repl-result-* | ||
.direnv | ||
.devenv | ||
.lcov* | ||
.invoices |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use std::{future::Future, path::Path}; | ||
|
||
#[cfg_attr(feature = "mock", mockall::automock)] | ||
pub trait FsService: Send + Sync + 'static { | ||
/// Write `content` into the file at `path`, creating the file if it does | ||
/// not exist yet and otherwise overwriting its previous content. | ||
fn store_file( | ||
&self, | ||
path: &Path, | ||
content: &[u8], | ||
) -> impl Future<Output = anyhow::Result<()>> + Send; | ||
} | ||
|
||
#[cfg(feature = "mock")] | ||
impl MockFsService { | ||
pub fn with_store_file(mut self, path: std::path::PathBuf, content: Vec<u8>) -> Self { | ||
self.expect_store_file() | ||
.once() | ||
.with( | ||
mockall::predicate::eq(path), | ||
mockall::predicate::eq(content), | ||
) | ||
.return_once(|_, _| Box::pin(std::future::ready(Ok(())))); | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod captcha; | ||
pub mod fs; | ||
pub mod hash; | ||
pub mod id; | ||
pub mod jwt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::path::Path; | ||
|
||
use academy_di::Build; | ||
use academy_shared_contracts::fs::FsService; | ||
|
||
#[derive(Debug, Clone, Build)] | ||
pub struct FsServiceImpl; | ||
|
||
impl FsService for FsServiceImpl { | ||
async fn store_file(&self, path: &Path, content: &[u8]) -> anyhow::Result<()> { | ||
if let Some(parent) = path.parent() { | ||
tokio::fs::create_dir_all(parent).await?; | ||
} | ||
tokio::fs::write(path, content).await.map_err(Into::into) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod captcha; | ||
pub mod fs; | ||
pub mod hash; | ||
pub mod id; | ||
pub mod jwt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[http] | ||
address = "127.0.0.1:8000" | ||
allowed_origins = [".*"] # RegexSet | ||
allowed_origins = [".*"] | ||
|
||
[database] | ||
url = "postgres://[email protected]:5432/academy" # https://docs.rs/tokio-postgres/latest/tokio_postgres/config/struct.Config.html | ||
|
@@ -38,6 +38,9 @@ client_secret = "test-secret" | |
[render] | ||
chrome_bin = "/usr/bin/chromium" | ||
|
||
[finance] | ||
invoices_archive = ".invoices" | ||
|
||
[oauth2.providers.test] | ||
enable = true | ||
name = "Test" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters