From fc27bdcc9868f65eeb3d7fa0de883786b55d4f29 Mon Sep 17 00:00:00 2001 From: Tony Giorgio Date: Sat, 18 Feb 2023 12:34:20 -0600 Subject: [PATCH] env fixes and more logs --- src/lib.rs | 16 +++++++++++----- wrangler.toml | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8a529bf..479ed94 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use crate::nostr::{try_queue_client_msg, NOSTR_QUEUE}; +pub(crate) use crate::nostr::{try_queue_client_msg, NOSTR_QUEUE}; use ::nostr::{ClientMessage, Event}; use futures::StreamExt; use worker::*; @@ -34,10 +34,16 @@ pub async fn main(req: Request, env: Env, _ctx: Context) -> Result { router .post_async("/event", |mut req, ctx| async move { // for any adhoc POST event - let request_text = req.text().await?; - if let Ok(client_msg) = ClientMessage::from_json(request_text) { - let nostr_queue = ctx.env.queue(NOSTR_QUEUE).expect("get queue"); - try_queue_client_msg(client_msg, nostr_queue).await + match req.text().await { + Ok(request_text) => { + if let Ok(client_msg) = ClientMessage::from_json(request_text) { + let nostr_queue = ctx.env.queue(NOSTR_QUEUE).expect("get queue"); + try_queue_client_msg(client_msg, nostr_queue).await + } + } + Err(e) => { + console_log!("could not get request text: {}", e); + } } fetch() diff --git a/wrangler.toml b/wrangler.toml index 3d6c0ae..f2b6e47 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -3,7 +3,7 @@ main = "build/worker/shim.mjs" compatibility_date = "2022-01-20" routes = [ - { pattern = "nostr.mutinywallet.com", zone_id = "2b9268714ce8d1c4431e8046d4ba55d3" } # replace with your info + { pattern = "nostr.mutinywallet.com/*", zone_id = "2b9268714ce8d1c4431e8046d4ba55d3" } # replace with your info ] [vars]