fix: build error in logger, cache, and logging middleware
This commit is contained in:
@@ -20,7 +20,6 @@ const loggerOptions: LoggerOptions = {
|
||||
};
|
||||
},
|
||||
},
|
||||
timestamp: pino.stdTimeFunctions.isoTime,
|
||||
};
|
||||
|
||||
export const log = pino(loggerOptions);
|
||||
|
||||
@@ -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) => {};
|
||||
// }
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user