Merge pull request #158 from shivang2607/build-error-fixed
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);
|
export const log = pino(loggerOptions);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { env } from "../config/env.js";
|
import { env } from "../config/env.js";
|
||||||
import { AniwatchAPICache, cache } from "../config/cache.js";
|
import { AniwatchAPICache, cache } from "../config/cache.js";
|
||||||
import type { BlankInput } from "hono/types";
|
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";
|
import type { ServerContext } from "../config/context.js";
|
||||||
|
|
||||||
// Define middleware to add Cache-Control header
|
// 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>(
|
export function withCache<T, P extends string = string>(
|
||||||
getData: (c: Context<ServerContext, P, BlankInput>) => Promise<T>
|
getData: (c: Context<ServerContext, P, BlankInput>) => Promise<T>
|
||||||
) {
|
): Handler<ServerContext, P, BlankInput> {
|
||||||
return async (c: Context<ServerContext, P, BlankInput>) => {
|
return async (c: Context<ServerContext, P, BlankInput>) => {
|
||||||
const cacheConfig = c.get("CACHE_CONFIG");
|
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 });
|
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";
|
import { log } from "../config/logger.js";
|
||||||
|
|
||||||
export const logging: MiddlewareHandler = honoLogger(
|
export const logging: MiddlewareHandler = honoLogger(
|
||||||
(msg: string, ...rest: string[]) => {
|
(msg: string, ...rest: any[]) => {
|
||||||
log.info(msg, ...rest);
|
log.info(msg, ...rest);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user