Toucan reference not valid for Deno
parent
992df19dd1
commit
9dc53e6428
|
@ -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 {
|
||||
// try {
|
||||
await next()
|
||||
} catch (error) {
|
||||
sentry.captureException(error)
|
||||
}
|
||||
// } catch (error) {
|
||||
// sentry.captureException(error)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue