0.0.45 • Published 2 months ago

@hattip/adapter-deno v0.0.45

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@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.

0.0.45

2 months ago

0.0.44

2 months ago

0.0.43

3 months ago

0.0.42

3 months ago

0.0.41

4 months ago

0.0.40

4 months ago

0.0.39

4 months ago

0.0.38

4 months ago

0.0.37

5 months ago

0.0.36

5 months ago

0.0.35-canary.2

10 months ago

0.0.35-canary.7

9 months ago

0.0.35-canary

10 months ago

0.0.35

8 months ago

0.0.34

12 months ago

0.0.33

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.20

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago