Rename
parent
f7c2dfdbb3
commit
855ce4eba4
|
@ -1,7 +1,7 @@
|
|||
import type { Handler } from 'hono'
|
||||
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,
|
||||
|
|
|
@ -1,24 +1,15 @@
|
|||
import { Hono } from 'hono'
|
||||
import { hello } from '../src'
|
||||
import { sentry } from '../src'
|
||||
|
||||
describe('Hello middleware', () => {
|
||||
describe('Sentry middleware', () => {
|
||||
const app = new Hono()
|
||||
|
||||
app.use('/hello/*', hello())
|
||||
app.use('/hello/*', sentry())
|
||||
app.get('/hello/foo', (c) => c.text('foo'))
|
||||
|
||||
app.use('/x/*', hello())
|
||||
app.get('/x/foo', (c) => c.text('foo'))
|
||||
|
||||
it('Should be hello message', async () => {
|
||||
it('Should initialize Toucan', async () => {
|
||||
const res = await app.request('http://localhost/hello/foo')
|
||||
expect(res).not.toBeNull()
|
||||
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)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue