aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nwc.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-11-08 22:06:10 +0000
committerAdam Soltys <[email protected]>2024-11-09 00:45:42 +0000
commit7199b0f72b34e630e358f15f1a9351a58fa3008b (patch)
treece6c1ace9980e162b33e8742415193fc298ab2c3 /lib/nwc.ts
parent6a6b9ab5b5292b51e2570eadb73e2e436c4f1117 (diff)
downloadcoinos-server-7199b0f72b34e630e358f15f1a9351a58fa3008b.tar.gz
coinos-server-7199b0f72b34e630e358f15f1a9351a58fa3008b.zip
logging
Diffstat (limited to 'lib/nwc.ts')
-rw-r--r--lib/nwc.ts34
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/nwc.ts b/lib/nwc.ts
index 0cbced1f..28675291 100644
--- a/lib/nwc.ts
+++ b/lib/nwc.ts
@@ -45,23 +45,27 @@ export default () => {
const uid = await g(pubkey);
const user = await g(`user:${uid}`);
- const result = await handle(method, params, user);
- const payload = JSON.stringify({ result_type: method, ...result });
- content = await nip04.encrypt(sk, pubkey, payload);
+ try {
+ const result = await handle(method, params, user);
+ const payload = JSON.stringify({ result_type: method, ...result });
+ content = await nip04.encrypt(sk, pubkey, payload);
- let response: UnsignedEvent = {
- created_at: Math.floor(Date.now() / 1000),
- kind: 23195,
- pubkey: serverPubkey,
- tags: [
- ["p", pubkey],
- ["e", ev.id],
- ],
- content,
- };
+ let response: UnsignedEvent = {
+ created_at: Math.floor(Date.now() / 1000),
+ kind: 23195,
+ pubkey: serverPubkey,
+ tags: [
+ ["p", pubkey],
+ ["e", ev.id],
+ ],
+ content,
+ };
- response = await finalizeEvent(response, sk);
- r.send(["EVENT", response]);
+ response = await finalizeEvent(response, sk);
+ r.send(["EVENT", response]);
+ } catch(e) {
+ err("problem with nwc", user.username, params, e.message);
+ }
} catch (e) {
err("problem with nwc", e.message);
}