Rename
parent
f7c2dfdbb3
commit
855ce4eba4
|
@ -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,
|
||||||
|
|
|
@ -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)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue