readmes, move config to sdk
This commit is contained in:
parent
1e59523f7a
commit
4a9ef170fe
5 changed files with 77 additions and 7 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -959,6 +959,8 @@ name = "saleor-app-sdk"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dotenvy",
|
||||
"envy",
|
||||
"redis",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
14
README.md
14
README.md
|
@ -2,11 +2,11 @@
|
|||
|
||||
This repo contains the following main components:
|
||||
|
||||
| Crate | Description |
|
||||
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
|
||||
| [**saleor-app-sdk**](https://crates.io/crates/saleor-app-sdk) | Types and utilities for making Saleor Apps |
|
||||
| [**saleor-app-template**](https://github.com/djkato/saleor-app-template-rs/tree/master/saleor-app-template) | Simple template for making Saleor apps using axum |
|
||||
| [**saleor-app-sitemap**](https://crates.io/crates/saleor-app-sitemap) | Saleor App for keeping sitemap.xml uptodate |
|
||||
| Crate | Description |
|
||||
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
|
||||
| [**saleor-app-sdk**](https://crates.io/crates/saleor-app-sdk) | Types and utilities for making Saleor Apps |
|
||||
| [**saleor-app-template**](https://github.com/djkato/saleor-apps-rs/tree/master/saleor-app-template) | Simple template for making Saleor apps using axum |
|
||||
| [**saleor-app-sitemap**](https://crates.io/crates/saleor-app-sitemap) | Saleor App for keeping sitemap.xml uptodate |
|
||||
|
||||
# Using this repo
|
||||
|
||||
|
@ -27,7 +27,7 @@ If using the `saleor-app-template`, create a new workspace member `cargo new <pr
|
|||
|
||||
## Adding new dependencies
|
||||
|
||||
Workspace dependencies need to be managed manually. If you wanna add a new dependency to a single member do `cargo add <dep> <project-name>`.
|
||||
Workspace dependencies need to be managed manually. If you wanna add a new dependency to a single member do `cargo add <dep> --package <project-name>`.
|
||||
If you want to use a shared dependency, add it to the root level `Cargo.toml`,
|
||||
then inside your member `Cargo.toml`add it under depencency like: `<dependency> = { workspace = true, features = [ "..." ] }`.
|
||||
|
||||
|
@ -38,4 +38,4 @@ Each workspace member has it's licensed in it's own directory.
|
|||
### TL;DR:
|
||||
|
||||
- saleor-app-sdk, saleor-app-template and the root structure fall under either MIT or Apache 2.0 at your convenience.
|
||||
- Any other workspace members fall under `FSL-1.1-MIT.md`. If you want to use my apps in commercial environment, each app costs 10€ (or voluntarily more). Upon payment/donation you can automatically use the given app as if it had MIT-1 or Apache 2.0.
|
||||
- Any other workspace members fall under FSL-1.1-MIT. If you want to use my apps in commercial environment, each app costs 10€ (or voluntarily more). Upon payment/donation you can automatically use the given app as if it had MIT-1 or Apache 2.0.
|
||||
|
|
|
@ -18,3 +18,5 @@ serde.workspace = true
|
|||
tracing.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
serde_json.workspace = true
|
||||
envy.workspace = true
|
||||
dotenvy.workspace = true
|
||||
|
|
17
saleor-app-sdk/README.md
Normal file
17
saleor-app-sdk/README.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Unofficial Saleor App SDK
|
||||
|
||||
SDK for building [Saleor Apps](https://github.com/saleor/apps), inspired by The [Official Saleor SDK](https://github.com/saleor/apps)
|
||||
This repo is very likely to introduce breaking changes as it's very early in development. Made specifically for the [Saleor App Template for Rust](https://github.com/djkato/saleor-apps-rs)
|
||||
|
||||
Current Coverage: ~10%
|
||||
[x] Base Types (Manifest, Webhooks, SaleorApp etc.)
|
||||
[x] APLs (Only redis currently implemented)
|
||||
[ ] JWT Management
|
||||
[ ] Webhook utilities
|
||||
[ ] Settings Manager
|
||||
[ ] App Bridge
|
||||
[ ] Handlers
|
||||
|
||||
## Usage
|
||||
|
||||
Check the git repo for example use in saleor-app-template
|
49
saleor-app-sdk/src/config.rs
Normal file
49
saleor-app-sdk/src/config.rs
Normal file
|
@ -0,0 +1,49 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
use tracing::{debug, Level};
|
||||
|
||||
use crate::apl::AplType;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(remote = "Level")]
|
||||
pub enum LocalTracingLevel {
|
||||
TRACE,
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARN,
|
||||
ERROR,
|
||||
}
|
||||
|
||||
fn version_default() -> String {
|
||||
">=3.11.7<4".to_owned()
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
//#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
pub struct Config {
|
||||
#[serde(default = "version_default")]
|
||||
pub required_saleor_version: String,
|
||||
pub saleor_app_id: String,
|
||||
pub app_api_base_url: String,
|
||||
pub apl: AplType,
|
||||
pub apl_url: String,
|
||||
#[serde(with = "LocalTracingLevel")]
|
||||
pub log_level: tracing::Level,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Config {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn load() -> Result<Self, envy::Error> {
|
||||
dotenvy::dotenv().unwrap();
|
||||
let env = envy::from_env::<Config>();
|
||||
if let Ok(e) = &env {
|
||||
debug!("{}", e);
|
||||
}
|
||||
env
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue