pull/31/head
Samuel Lippert 2022-08-03 18:33:14 -05:00
parent f7c2dfdbb3
commit 855ce4eba4
No known key found for this signature in database
GPG Key ID: 3762857AF8948B2C
2 changed files with 5 additions and 14 deletions

View File

@ -1,7 +1,7 @@
import type { Handler } from 'hono' import type { Handler } from 'hono'
import Toucan from 'toucan-js' 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,

View File

@ -1,24 +1,15 @@
import { Hono } from 'hono' import { Hono } from 'hono'
import { hello } from '../src' import { sentry } from '../src'
describe('Hello middleware', () => { describe('Sentry middleware', () => {
const app = new Hono() const app = new Hono()
app.use('/hello/*', hello()) app.use('/hello/*', sentry())
app.get('/hello/foo', (c) => c.text('foo')) app.get('/hello/foo', (c) => c.text('foo'))
app.use('/x/*', hello()) it('Should initialize Toucan', async () => {
app.get('/x/foo', (c) => c.text('foo'))
it('Should be hello message', async () => {
const res = await app.request('http://localhost/hello/foo') const res = await app.request('http://localhost/hello/foo')
expect(res).not.toBeNull() expect(res).not.toBeNull()
expect(res.status).toBe(200) expect(res.status).toBe(200)
}) })
it('Should be X', async () => {
const res = await app.request('http://localhost/x/foo')
expect(res).not.toBeNull()
expect(res.status).toBe(200)
})
}) })