From a15e28e48f0dbb8aaf7b026538a9c2968df33556 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 5 Oct 2023 19:58:47 -0500 Subject: [PATCH] Add Sentry hono middleware --- src/app.ts | 7 +++++++ src/deps.ts | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app.ts b/src/app.ts index f9eaac2..4cf6afe 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,3 +1,4 @@ +import { Conf } from '@/config.ts'; import '@/cron.ts'; import { type User } from '@/db/users.ts'; import { @@ -9,6 +10,7 @@ import { type HonoEnv, logger, type MiddlewareHandler, + sentryMiddleware, serveStatic, } from '@/deps.ts'; import '@/firehose.ts'; @@ -81,6 +83,11 @@ type AppController = Handler; const app = new Hono(); +if (Conf.sentryDsn) { + // @ts-ignore Mismatched hono types. + app.use('*', sentryMiddleware({ dsn: Conf.sentryDsn })); +} + app.use('*', logger()); app.get('/api/v1/streaming', streamingController); diff --git a/src/deps.ts b/src/deps.ts index b0d5a63..7694d30 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -6,8 +6,8 @@ export { Hono, HTTPException, type MiddlewareHandler, -} from 'https://deno.land/x/hono@v3.3.4/mod.ts'; -export { cors, logger, serveStatic } from 'https://deno.land/x/hono@v3.3.4/middleware.ts'; +} from 'https://deno.land/x/hono@v3.7.5/mod.ts'; +export { cors, logger, serveStatic } from 'https://deno.land/x/hono@v3.7.5/middleware.ts'; export { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts'; export { Author, RelayPool } from 'https://dev.jspm.io/nostr-relaypool@0.6.28'; export { @@ -73,5 +73,6 @@ export { default as IpfsHash } from 'npm:ipfs-only-hash@^4.0.0'; export { default as uuid62 } from 'npm:uuid62@^1.0.2'; export { Machina } from 'https://gitlab.com/soapbox-pub/nostr-machina/-/raw/08a157d39f2741c9a3a4364cb97db36e71d8c03a/mod.ts'; export * as Sentry from 'npm:@sentry/node@^7.73.0'; +export { sentry as sentryMiddleware } from 'npm:@hono/sentry@^1.0.0'; export type * as TypeFest from 'npm:type-fest@^4.3.0';