Expand description
autumn-plugin-shopify: build Shopify apps on Autumn.
- Signed webhooks, routed by topic, with a duplicate guard.
- OAuth install with expiring offline tokens and refresh.
- An Admin GraphQL client that retries throttled calls.
use autumn_plugin_shopify::{ShopifyPlugin, WebhookContext};
use autumn_web::prelude::*;
async fn order_created(ctx: WebhookContext) -> AutumnResult<()> {
let order: serde_json::Value = ctx.json().map_err(|e| e.to_autumn_error())?;
tracing::info!(shop = %ctx.shop, id = %order["id"], "order created");
Ok(())
}
#[autumn_web::main]
async fn main() {
autumn_web::app()
.plugin(ShopifyPlugin::new().webhook("orders/create", order_created))
.run()
.await;
}§Modules
| Module | Purpose |
|---|---|
config | [shopify] config, SHOPIFY_* env, builder closures |
types | ShopDomain, Topic, ApiVersion |
verify | Webhook and OAuth HMAC checks |
webhooks | The webhook route, extractor, and topic registry |
delivery | Duplicate-delivery guard |
oauth | Install and callback routes, token exchange, refresh |
tokens | Token storage |
client | Admin GraphQL client |
health | Health check |
plugin | ShopifyPlugin, ShopifyRuntime, Shopify |
error | Error, ErrorKind, HTTP status mapping |
Re-exports§
pub use client::RetryPolicy;pub use client::ShopInfo;pub use client::ShopifyClient;pub use config::ShopifyConfig;pub use delivery::Claim;pub use delivery::DeliveryStore;pub use delivery::InMemoryDeliveryStore;pub use error::Error;pub use error::ErrorKind;pub use error::Result;pub use health::ShopifyHealth;pub use plugin::InstallContext;pub use plugin::Shopify;pub use plugin::ShopifyPlugin;pub use plugin::ShopifyRuntime;pub use tokens::InMemoryTokenStore;pub use tokens::ShopToken;pub use tokens::TokenStore;pub use types::ApiVersion;pub use types::DEFAULT_API_VERSION;pub use types::ShopDomain;pub use types::Topic;pub use verify::SecretSet;pub use verify::sign_query;pub use verify::sign_webhook;pub use verify::verify_query;pub use verify::verify_webhook;pub use webhooks::VerifiedWebhook;pub use webhooks::WebhookContext;pub use webhooks::WebhookOutcome;pub use webhooks::WebhookRegistry;
Modules§
- client
- Admin GraphQL API client.
- config
- Layered configuration for the Shopify plugin.
- delivery
- Duplicate-delivery guard for webhooks.
- error
- Error types for the Shopify plugin.
- health
- Health check for single-store apps.
- oauth
- OAuth install: the authorization code grant with expiring offline tokens.
- plugin
- The Autumn plugin:
ShopifyPlugin,ShopifyRuntime, and theShopifyextractor. - tokens
- Access-token storage.
- types
- Validated domain types:
ShopDomain,Topic,ApiVersion. - verify
- HMAC-SHA256 verification for Shopify webhooks and OAuth redirects.
- webhooks
- Signed webhooks, routed by topic.