fix how app_url works
This commit is contained in:
parent
6d7c9b201d
commit
795793ca84
8 changed files with 63 additions and 36 deletions
1
.env
1
.env
|
@ -1,5 +1,6 @@
|
||||||
## COMMON VARIABLES FOR ALL APPS
|
## COMMON VARIABLES FOR ALL APPS
|
||||||
REQUIRED_SALEOR_VERSION="^3.13"
|
REQUIRED_SALEOR_VERSION="^3.13"
|
||||||
|
# only sets port, the host is always 0.0.0.0 (listens to everything). Set this to docker-compose service name
|
||||||
APP_API_BASE_URL="http://10.100.110.234:3000"
|
APP_API_BASE_URL="http://10.100.110.234:3000"
|
||||||
APL="Redis"
|
APL="Redis"
|
||||||
APL_URL="redis://localhost:6380/2"
|
APL_URL="redis://localhost:6380/2"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
## COMMON VARIABLES FOR ALL APPS
|
## COMMON VARIABLES FOR ALL APPS
|
||||||
REQUIRED_SALEOR_VERSION="^3.13"
|
REQUIRED_SALEOR_VERSION="^3.13"
|
||||||
|
# only sets port, the host is always 0.0.0.0 (listens to everything). Set this to docker-compose service name
|
||||||
APP_API_BASE_URL="http://0.0.0.0:3000"
|
APP_API_BASE_URL="http://0.0.0.0:3000"
|
||||||
APL="Redis"
|
APL="Redis"
|
||||||
APL_URL="redis://localhost:6379/1"
|
APL_URL="redis://localhost:6379/1"
|
||||||
|
|
|
@ -2,8 +2,8 @@ mod app;
|
||||||
mod queries;
|
mod queries;
|
||||||
mod routes;
|
mod routes;
|
||||||
|
|
||||||
use anyhow::Context;
|
|
||||||
use saleor_app_sdk::{
|
use saleor_app_sdk::{
|
||||||
|
cargo_info,
|
||||||
config::Config,
|
config::Config,
|
||||||
manifest::{AppManifest, AppPermission},
|
manifest::{AppManifest, AppPermission},
|
||||||
webhooks::{AsyncWebhookEventType, WebhookManifest},
|
webhooks::{AsyncWebhookEventType, WebhookManifest},
|
||||||
|
@ -24,7 +24,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let saleor_app = SaleorApp::new(&config)?;
|
let saleor_app = SaleorApp::new(&config)?;
|
||||||
|
|
||||||
let app_manifest = AppManifest::new(&config)
|
let app_manifest = AppManifest::new(&config, cargo_info!())
|
||||||
.add_webhook(
|
.add_webhook(
|
||||||
WebhookManifest::new(&config)
|
WebhookManifest::new(&config)
|
||||||
.set_query(
|
.set_query(
|
||||||
|
@ -76,12 +76,13 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let app = create_routes(app_state);
|
let app = create_routes(app_state);
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind(
|
let listener = tokio::net::TcpListener::bind(
|
||||||
&config
|
"0.0.0.0:".to_owned()
|
||||||
.app_api_base_url
|
+ config
|
||||||
.split("//")
|
.app_api_base_url
|
||||||
.collect::<Vec<_>>()
|
.split(':')
|
||||||
.get(1)
|
.collect::<Vec<_>>()
|
||||||
.context("APP_API_BASE_URL invalid format")?,
|
.get(2)
|
||||||
|
.unwrap_or(&"3000"),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
tracing::debug!("listening on {}", listener.local_addr().unwrap());
|
tracing::debug!("listening on {}", listener.local_addr().unwrap());
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
## COMMON VARIABLES FOR ALL APPS
|
## COMMON VARIABLES FOR ALL APPS
|
||||||
REQUIRED_SALEOR_VERSION="^3.13"
|
REQUIRED_SALEOR_VERSION="^3.13"
|
||||||
APP_API_BASE_URL="http://0.0.0.0:3001"
|
APP_API_BASE_URL="http://0.0.0.0:3001"
|
||||||
|
MANIFEST_URL="http://0.0.0.0:3001"
|
||||||
|
CONFIG_URL="http://0.0.0.0:3001"
|
||||||
APL="Redis"
|
APL="Redis"
|
||||||
APL_URL="redis://redis-apl:6379/1"
|
APL_URL="redis://redis-apl:6379/1"
|
||||||
LOG_LEVEL="DEBUG"
|
LOG_LEVEL="DEBUG"
|
||||||
|
|
|
@ -192,7 +192,28 @@ impl AppManifestBuilder {
|
||||||
self.manifest
|
self.manifest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub struct CargoInfo {
|
||||||
|
pub name: String,
|
||||||
|
pub description: String,
|
||||||
|
pub authors: String,
|
||||||
|
pub version: String,
|
||||||
|
pub homepage: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! cargo_info {
|
||||||
|
() => {
|
||||||
|
saleor_app_sdk::manifest::CargoInfo {
|
||||||
|
name: env!("CARGO_PKG_NAME").to_owned(),
|
||||||
|
description: env!("CARGO_PKG_DESCRIPTION").to_owned(),
|
||||||
|
authors: env!("CARGO_PKG_AUTHORS").to_owned(),
|
||||||
|
version: env!("CARGO_PKG_VERSION").to_owned(),
|
||||||
|
homepage: env!("CARGO_PKG_HOMEPAGE").to_owned(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use cargo_info;
|
||||||
impl AppManifest {
|
impl AppManifest {
|
||||||
/**
|
/**
|
||||||
* Builder for AppManifest
|
* Builder for AppManifest
|
||||||
|
@ -206,22 +227,22 @@ impl AppManifest {
|
||||||
* To set webhooks and permissions use the add_webhook() and add_permissions()
|
* To set webhooks and permissions use the add_webhook() and add_permissions()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
pub fn new(config: &Config) -> AppManifestBuilder {
|
pub fn new(config: &Config, info: CargoInfo) -> AppManifestBuilder {
|
||||||
AppManifestBuilder {
|
AppManifestBuilder {
|
||||||
manifest: AppManifest {
|
manifest: AppManifest {
|
||||||
id: env!("CARGO_PKG_NAME").to_owned(),
|
id: info.name.clone(),
|
||||||
required_saleor_version: Some(config.required_saleor_version.clone()),
|
required_saleor_version: Some(config.required_saleor_version.clone()),
|
||||||
name: env!("CARGO_PKG_NAME").to_owned(),
|
name: info.name,
|
||||||
about: Some(env!("CARGO_PKG_DESCRIPTION").to_owned()),
|
about: Some(info.description),
|
||||||
author: Some(env!("CARGO_PKG_AUTHORS").to_owned()),
|
author: Some(info.authors),
|
||||||
version: env!("CARGO_PKG_VERSION").to_owned(),
|
version: info.version,
|
||||||
app_url: config.app_api_base_url.clone(),
|
app_url: config.app_api_base_url.clone(),
|
||||||
configuration_url: Some(config.app_api_base_url.clone()),
|
configuration_url: Some(config.app_api_base_url.clone()),
|
||||||
token_target_url: format!("{}/api/register", config.app_api_base_url.clone()),
|
token_target_url: format!("{}/api/register", config.app_api_base_url.clone()),
|
||||||
permissions: vec![],
|
permissions: vec![],
|
||||||
homepage_url: Some(env!("CARGO_PKG_HOMEPAGE").to_owned()),
|
homepage_url: Some(info.homepage.clone()),
|
||||||
data_privacy_url: Some(env!("CARGO_PKG_HOMEPAGE").to_owned()),
|
data_privacy_url: Some(info.homepage.clone()),
|
||||||
support_url: Some(env!("CARGO_PKG_HOMEPAGE").to_owned()),
|
support_url: Some(info.homepage.clone()),
|
||||||
brand: Some(SaleorAppBranding {
|
brand: Some(SaleorAppBranding {
|
||||||
logo: SaleorAppBrandingDefault {
|
logo: SaleorAppBrandingDefault {
|
||||||
default: format!("{}/logo.png", config.app_api_base_url),
|
default: format!("{}/logo.png", config.app_api_base_url),
|
||||||
|
|
|
@ -85,10 +85,10 @@ pub fn get_active_gateways_from_env() -> anyhow::Result<Vec<ActiveGateway>> {
|
||||||
let locale = std::env::var("LOCALE")?;
|
let locale = std::env::var("LOCALE")?;
|
||||||
let locale = LocaleCode::from_str(&locale)?;
|
let locale = LocaleCode::from_str(&locale)?;
|
||||||
let currencies = std::env::var("CURRENCIES")?;
|
let currencies = std::env::var("CURRENCIES")?;
|
||||||
let currencies = currencies.split(",").collect::<Vec<_>>();
|
let currencies = currencies.split(',').collect::<Vec<_>>();
|
||||||
let currencies = currencies
|
let currencies = currencies
|
||||||
.iter()
|
.iter()
|
||||||
.map(|c| Currency::from_str(*c))
|
.map(|c| Currency::from_str(c))
|
||||||
.collect::<Result<Vec<_>, _>>()
|
.collect::<Result<Vec<_>, _>>()
|
||||||
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))?;
|
.map_err(|e| anyhow::anyhow!(format!("{:?}", e)))?;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ mod app;
|
||||||
mod queries;
|
mod queries;
|
||||||
mod routes;
|
mod routes;
|
||||||
|
|
||||||
use anyhow::Context;
|
|
||||||
use saleor_app_sdk::{
|
use saleor_app_sdk::{
|
||||||
|
cargo_info,
|
||||||
config::Config,
|
config::Config,
|
||||||
manifest::{AppManifest, AppPermission},
|
manifest::{AppManifest, AppPermission},
|
||||||
webhooks::{SyncWebhookEventType, WebhookManifest},
|
webhooks::{SyncWebhookEventType, WebhookManifest},
|
||||||
|
@ -33,7 +33,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let saleor_app = SaleorApp::new(&config)?;
|
let saleor_app = SaleorApp::new(&config)?;
|
||||||
|
|
||||||
let app_manifest = AppManifest::new(&config)
|
let app_manifest = AppManifest::new(&config, cargo_info!())
|
||||||
.add_webhook(
|
.add_webhook(
|
||||||
WebhookManifest::new(&config)
|
WebhookManifest::new(&config)
|
||||||
.set_query(sub_transaction_process_session)
|
.set_query(sub_transaction_process_session)
|
||||||
|
@ -93,12 +93,13 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let app = create_routes(app_state);
|
let app = create_routes(app_state);
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind(
|
let listener = tokio::net::TcpListener::bind(
|
||||||
&config
|
"0.0.0.0:".to_owned()
|
||||||
.app_api_base_url
|
+ config
|
||||||
.split("//")
|
.app_api_base_url
|
||||||
.collect::<Vec<_>>()
|
.split(':')
|
||||||
.get(1)
|
.collect::<Vec<_>>()
|
||||||
.context("APP_API_BASE_URL invalid format")?,
|
.get(2)
|
||||||
|
.unwrap_or(&"3000"),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
tracing::debug!("listening on {}", listener.local_addr().unwrap());
|
tracing::debug!("listening on {}", listener.local_addr().unwrap());
|
||||||
|
|
|
@ -4,10 +4,9 @@ mod app;
|
||||||
mod queries;
|
mod queries;
|
||||||
mod routes;
|
mod routes;
|
||||||
|
|
||||||
use anyhow::Context;
|
|
||||||
use saleor_app_sdk::{
|
use saleor_app_sdk::{
|
||||||
config::Config,
|
config::Config,
|
||||||
manifest::{AppManifest, AppPermission},
|
manifest::{cargo_info, AppManifest, AppPermission},
|
||||||
webhooks::{AsyncWebhookEventType, WebhookManifest},
|
webhooks::{AsyncWebhookEventType, WebhookManifest},
|
||||||
SaleorApp,
|
SaleorApp,
|
||||||
};
|
};
|
||||||
|
@ -32,7 +31,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
debug!("Creating saleor App...");
|
debug!("Creating saleor App...");
|
||||||
|
|
||||||
let app_manifest = AppManifest::new(&config)
|
let app_manifest = AppManifest::new(&config, cargo_info!())
|
||||||
.add_permissions(vec![
|
.add_permissions(vec![
|
||||||
AppPermission::ManageProducts,
|
AppPermission::ManageProducts,
|
||||||
AppPermission::ManagePages,
|
AppPermission::ManagePages,
|
||||||
|
@ -90,12 +89,13 @@ async fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let app = create_routes(app_state);
|
let app = create_routes(app_state);
|
||||||
let listener = tokio::net::TcpListener::bind(
|
let listener = tokio::net::TcpListener::bind(
|
||||||
&config
|
"0.0.0.0:".to_owned()
|
||||||
.app_api_base_url
|
+ config
|
||||||
.split("//")
|
.app_api_base_url
|
||||||
.collect::<Vec<_>>()
|
.split(':')
|
||||||
.get(1)
|
.collect::<Vec<_>>()
|
||||||
.context("APP_API_BASE_URL invalid format")?,
|
.get(2)
|
||||||
|
.unwrap_or(&"3000"),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
info!("listening on {}", listener.local_addr().unwrap());
|
info!("listening on {}", listener.local_addr().unwrap());
|
||||||
|
|
Loading…
Reference in a new issue