@hono/node-server
Advanced tools
Comparing version 1.3.5 to 1.4.0
@@ -1,2 +0,2 @@ | ||
import { MiddlewareHandler } from 'hono'; | ||
import { Context, MiddlewareHandler } from 'hono'; | ||
@@ -11,2 +11,3 @@ type ServeStaticOptions = { | ||
rewriteRequestPath?: (path: string) => string; | ||
onNotFound?: (path: string, c: Context) => void | Promise<void>; | ||
}; | ||
@@ -13,0 +14,0 @@ declare const serveStatic: (options?: ServeStaticOptions) => MiddlewareHandler; |
@@ -174,2 +174,3 @@ "use strict"; | ||
if (!(0, import_fs.existsSync)(path)) { | ||
await options.onNotFound?.(path, c); | ||
return next(); | ||
@@ -176,0 +177,0 @@ } |
{ | ||
"name": "@hono/node-server", | ||
"version": "1.3.5", | ||
"version": "1.4.0", | ||
"description": "Node.js Adapter for Hono", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -165,2 +165,18 @@ # Node.js Adapter for Hono | ||
#### `onNotFound` | ||
The `onNotFound` is useful for debugging. You can write a handle for when a file is not found. | ||
```ts | ||
app.use( | ||
'/static/*', | ||
serveStatic({ | ||
root: './non-existent-dir', | ||
onNotFound: (path, c) => { | ||
console.log(`${path} is not found, request to ${c.req.path}`) | ||
}, | ||
}) | ||
) | ||
``` | ||
## Related projects | ||
@@ -167,0 +183,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120719
3762
193