Skip to content

Commit

Permalink
feat(hono): add generic type parameter to useHonoLogger function
Browse files Browse the repository at this point in the history
  • Loading branch information
kiki-kanri committed Jul 11, 2024
1 parent e1686c2 commit 43a355b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hono.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { HonoBase } from 'hono/hono-base';
import { logger as honoLogger } from 'hono/logger';
import type { Env, Schema } from 'hono/types';

import logger from './logger';

export const useHonoLogger = (honoApp: HonoBase, logIncoming: boolean = false) => {
export const useHonoLogger = <E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'>(honoApp: HonoBase<E, S, BasePath>, logIncoming: boolean = false) => {
if (process.env.NODE_ENV === 'production') return;
const logFunction = logIncoming ? (text: string) => logger.info(text.slice(6)) : (text: string) => !text.startsWith(' <--') && logger.info(text.slice(6));
honoApp.use(honoLogger(logFunction));
Expand Down

0 comments on commit 43a355b

Please sign in to comment.