hono-absolute-serve-static
v1.0.0
Published
Absolute path version of @hono/node-server.
Downloads
10
Maintainers
Readme
serveStaticWithAbsolutePath
Absolute path version of @hono/node-server.
It has everything in common with serveStatic of @hono/node-server except that path and root are treated as absolute paths. (All options are also common.)
This feature has been tested only on nodejs. We cannot guarantee that it will work on non-nodejs environments.
This repository will be archived when absolute paths are officially introduced to serveStatic in @hono/node-server.
Usage
import { Hono } from "hono";
import { join } from "node:path";
import { serve } from "@hono/node-server";
import { serveStaticWithAbsolutePath } from "hono-absolute-serve-static";
const app = new Hono();
app.use(
"/static/*",
serveStaticWithAbsolutePath({
root: join(import.meta.dirname, "./assets")
})
);
serve({
fetch: app.fetch,
port: 3000
});