How do I get rid of annoying console log message when serveStatic files are not found? #3068
Replies: 1 comment
-
Found the culprit https://github.com/honojs/hono/blob/main/src/adapter/deno/serve-static.ts#L19 need a option to disable console messages like this. I just replicated the file and took out the console.warn. import type { ServeStaticOptions } from "hono/serve-static";
import { serveStatic as baseServeStatic } from 'hono/serve-static';
import type { Env, MiddlewareHandler } from "hono";
const { open } = Deno
export const serveStatic = <E extends Env = Env>(
options: ServeStaticOptions<E>
): MiddlewareHandler => {
return async function serveStatic(c, next) {
const getContent = async (path: string) => {
try {
const file = await open(path)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return file ? (file.readable as any) : null
} catch {
//
}
}
const pathResolve = (path: string) => {
return `./${path}`
}
return baseServeStatic({
...options,
getContent,
pathResolve,
})(c, next)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using Hono with Deno and I keep getting this annoying console log message when an attempt is made to request a static file that doesn't exist.
"NotFound: The system cannot find the file specified. (os error 2):"
I don't want Hono logging messages unless I tell it too. In production I don't want thousands of log messages of people trying to access files that don't exist.
Beta Was this translation helpful? Give feedback.
All reactions