Merge pull request #158 from shivang2607/build-error-fixed

fix: build error in logger, cache, and logging middleware
This commit is contained in:
Ritesh Ghosh
2025-09-28 00:42:35 +05:30
committed by GitHub
3 changed files with 4 additions and 11 deletions
-1
View File
@@ -20,7 +20,6 @@ const loggerOptions: LoggerOptions = {
};
},
},
timestamp: pino.stdTimeFunctions.isoTime,
};
export const log = pino(loggerOptions);
+3 -9
View File
@@ -1,7 +1,7 @@
import { env } from "../config/env.js";
import { AniwatchAPICache, cache } from "../config/cache.js";
import type { BlankInput } from "hono/types";
import type { Context, MiddlewareHandler } from "hono";
import type { Context, MiddlewareHandler, Handler } from "hono";
import type { ServerContext } from "../config/context.js";
// Define middleware to add Cache-Control header
@@ -41,9 +41,10 @@ export function cacheConfigSetter(keySliceIndex: number): MiddlewareHandler {
};
}
// FIXED: add explicit return type
export function withCache<T, P extends string = string>(
getData: (c: Context<ServerContext, P, BlankInput>) => Promise<T>
) {
): Handler<ServerContext, P, BlankInput> {
return async (c: Context<ServerContext, P, BlankInput>) => {
const cacheConfig = c.get("CACHE_CONFIG");
@@ -56,10 +57,3 @@ export function withCache<T, P extends string = string>(
return c.json({ status: 200, data }, { status: 200 });
};
}
// export function _withCache<T>(
// context: Context<ServerContext>,
// promise: Promise<T>
// ): MiddlewareHandler {
// return async (c) => {};
// }
+1 -1
View File
@@ -3,7 +3,7 @@ import { logger as honoLogger } from "hono/logger";
import { log } from "../config/logger.js";
export const logging: MiddlewareHandler = honoLogger(
(msg: string, ...rest: string[]) => {
(msg: string, ...rest: any[]) => {
log.info(msg, ...rest);
}
);