From 9dc53e6428b5ac31f133fd4dc49dead9357e9ff6 Mon Sep 17 00:00:00 2001 From: Samuel Lippert Date: Tue, 9 Aug 2022 11:32:06 -0500 Subject: [PATCH] Toucan reference not valid for Deno --- deno_dist/index.ts | 25 ++++++++++++------------- deno_test/index.test.ts | 11 +++++------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/deno_dist/index.ts b/deno_dist/index.ts index 1e620330..282ef1f8 100644 --- a/deno_dist/index.ts +++ b/deno_dist/index.ts @@ -1,19 +1,18 @@ import type { Handler } from 'https://raw.githubusercontent.com/honojs/hono/v2.0.6/deno_dist/mod.ts' -import Toucan from 'toucan-js' -export const hello = (): Handler => { +export const sentry = (): Handler => { return async (c, next) => { - const sentry = new Toucan({ - dsn: c.env.SENTRY_DSN, - request: c.req, - allowedHeaders: ['user-agent'], - allowedSearchParams: /(.*)/, - }) + // const sentry = new Toucan({ + // dsn: c.env.SENTRY_DSN, + // request: c.req, + // allowedHeaders: ['user-agent'], + // allowedSearchParams: /(.*)/, + // }) - try { - await next() - } catch (error) { - sentry.captureException(error) - } + // try { + await next() + // } catch (error) { + // sentry.captureException(error) + // } } } diff --git a/deno_test/index.test.ts b/deno_test/index.test.ts index 46cd989b..54b5d6ce 100644 --- a/deno_test/index.test.ts +++ b/deno_test/index.test.ts @@ -1,15 +1,14 @@ -import { hello } from '../deno_dist/mod.ts' +import { sentry } from '../deno_dist/mod.ts' import { assertEquals, Hono } from './deps.ts' // Test just only minimal patterns. // Because others are tested well in Cloudflare Workers environment already. -Deno.test('Hello Middleware', async () => { +Deno.test('Sentry Middleware', async () => { const app = new Hono() - app.use('/hello/*', hello()) - app.get('/hello/foo', (c) => c.text('foo')) + app.use('/sentry/*', sentry()) + app.get('/sentry/foo', (c) => c.text('foo')) - let res = await app.request('http://localhost/hello/foo') + const res = await app.request('http://localhost/sentry/foo') assertEquals(res.status, 200) - assertEquals(res.headers.get('X-Message'), 'Hello') })