0.0.49 • Published 8 months ago

@hattip/adapter-bun v0.0.49

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

@hattip/adapter-bun

Hattip adapter for Bun.

Usage

Assuming you have your Hattip handler defined in handler.js and your static assets are in the public directory, create an entry-bun.js file like the following and use bun entry-bun.js to run it:

import bunAdapter from "@hattip/adapter-bun";
import handler from "./handler.js";
import url from "node:url";
import path from "node:path";

const dir = path.resolve(
  path.dirname(url.fileURLToPath(new URL(import.meta.url))),
  "public",
);

export default bunAdapter(handler, { staticDir: dir });

You can leave out the staticDir option if you don't want to serve static assets.

Options

  • staticDir: The directory to serve static assets from. Leave undefined to not serve static assets.
  • trustProxy: Whether to trust the X-Forwarded-For header.

The remaining options (port, hostname etc.) are passed to Bun.serve.

context.platform

export interface BunPlatformInfo {
  /** Platform name */
  name: "bun";
  /** Bun server instance */
  server: Server;
}

Environment variables

The ctx.env() function is implemented using process.env.

Limitations

Bun support is preliminary and Bun itself is in early development:

  • No way to determine the IP address of the client when trustProxy is false.
  • No streaming, everything is cached.
0.0.49

8 months ago

0.0.46

1 year ago

0.0.47

11 months ago

0.0.48

10 months ago

0.0.45

1 year ago

0.0.44

1 year ago

0.0.43

1 year ago

0.0.42

1 year ago

0.0.41

1 year ago

0.0.40

1 year ago

0.0.39

1 year ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35-canary.2

2 years ago

0.0.35-canary.7

2 years ago

0.0.35-canary

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.20

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago