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 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) => {
|
return async (c, next) => {
|
||||||
const sentry = new Toucan({
|
// const sentry = new Toucan({
|
||||||
dsn: c.env.SENTRY_DSN,
|
// dsn: c.env.SENTRY_DSN,
|
||||||
request: c.req,
|
// request: c.req,
|
||||||
allowedHeaders: ['user-agent'],
|
// allowedHeaders: ['user-agent'],
|
||||||
allowedSearchParams: /(.*)/,
|
// allowedSearchParams: /(.*)/,
|
||||||
})
|
// })
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
await next()
|
await next()
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
sentry.captureException(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'
|
import { assertEquals, Hono } from './deps.ts'
|
||||||
|
|
||||||
// Test just only minimal patterns.
|
// Test just only minimal patterns.
|
||||||
// Because others are tested well in Cloudflare Workers environment already.
|
// Because others are tested well in Cloudflare Workers environment already.
|
||||||
|
|
||||||
Deno.test('Hello Middleware', async () => {
|
Deno.test('Sentry Middleware', async () => {
|
||||||
const app = new Hono()
|
const app = new Hono()
|
||||||
app.use('/hello/*', hello())
|
app.use('/sentry/*', sentry())
|
||||||
app.get('/hello/foo', (c) => c.text('foo'))
|
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.status, 200)
|
||||||
assertEquals(res.headers.get('X-Message'), 'Hello')
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue