@hattip/adapter-deno v0.0.45
@hattip/adapter-deno
Hattip adapter for Deno. It requires Deno version 1.35.0 or higher.
Usage
Assuming you have your Hattip handler defined in handler.ts
, create an entry file like the following and run with deno run -A entry.ts
:
import { createServeHandler } from "npm:@hattip/adapter-deno";
import handler from "./handler.ts";
Deno.serve(createServeHandler(handler));
Serving static files
If you want to serve static files, you can use the serveDir
function from std/http/file_server.ts
. Assuming your static files are in the public
directory, you can use the following:
import { createRequestHandler } from "npm:@hattip/adapter-deno";
import hattipHandler from "./handler.js";
import { serveDir } from "https://deno.land/std/http/file_server.ts";
const handler = createRequestHandler(hattipHandler);
Deno.serve(async (request, connInfo) => {
const staticResponse = await serveDir(request, { fsRoot: "./public" });
if (staticResponse.status !== 404) {
return staticResponse;
}
return handler(request, connInfo);
});
context.platform
contex.platform.info
is a Deno.ServeHandlerInfo
object.
Environment variables
Usage of ctx.env()
function requires --allow-env
flag.
2 months ago
2 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
10 months ago
9 months ago
10 months ago
8 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago