Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
robertherber committed Jan 21, 2025
1 parent 64b4d4c commit f754eba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/bull/bullboard-hono-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
AppControllerRoute, AppViewRoute, BullBoardQueues, ControllerHandlerReturnType, HTTPMethod, IServerAdapter, UIConfig,
} from '@bull-board/api/dist/typings/app'
import type { Context, Env } from 'hono'
import type { ContentfulStatusCode } from 'hono/utils/http-status'

export default class HonoAdapter<HonoEnv extends Env> implements IServerAdapter {
protected app: Hono<HonoEnv>
Expand Down Expand Up @@ -84,17 +85,19 @@ export default class HonoAdapter<HonoEnv extends Env> implements IServerAdapter
query: c.req.query(),
body: hasJSONBody ? await c.req.json() : {},
})
return c.json(response.body, response.status || 200)
const status = response.status || 200
return c.json(response.body, status as ContentfulStatusCode)
} catch (e) {
if (!this.errorHandler || !(e instanceof Error)) {
throw e
}

const response = this.errorHandler(e)
if (typeof response.body === 'string') {
return c.text(response.body, response.status)
const status = response.status || 500
return c.text(response.body, status as ContentfulStatusCode)
}
return c.json(response.body, response.status)
return c.json(response.body, response.status as ContentfulStatusCode)
}
})
})
Expand Down

0 comments on commit f754eba

Please sign in to comment.