# burnserve

> Fast, zero dependency HTTP Server for Bun.js runtime

Latest version **1.0.7** (published 2022-08-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install burnserve
pnpm add burnserve
yarn add burnserve
bun add burnserve
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2022-08-21 |
| First published | 2022-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 21.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Der_Googler |
| Maintainers | der_googler |
| Keywords | bun, web, framework, http, backend |

## Links

- npm: https://www.npmjs.com/package/burnserve
- Repository: https://github.com/DerGoogler/BurnServe
- Homepage: https://github.com/DerGoogler/BurnServe#README
- Issues: https://github.com/DerGoogler/BurnServe/issues
- npm.io page: https://npm.io/package/burnserve

## Dependencies (1)

- [bun-types](https://npm.io/package/bun-types.md) ^0.1.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2022-08-21
- 1.0.6 — 2022-08-21
- 1.0.5 — 2022-08-19
- 1.0.4 — 2022-08-19
- 1.0.3 — 2022-08-19
- 1.0.2 — 2022-08-19
- 1.0.1 — 2022-08-19
- 1.0.0 — 2022-08-19

## README

# BurnServe

This library requires [Bun](https://bun.sh)

> This library is currently experimental and under development. Everything can CHANGE!

## Quickstart

```ts
import BurnServe from "burnserve";

const app = new BurnServe();

app.get("/", ctx => {
  ctx.sendHTML("lol");
});

app.get("/test", ctx => {
  ctx.sendHTML("You're on a test page");
});

app.get(/\/public\/.*/, ctx => {
  ctx.sendHTML("Public folder");
});

app.get(/\/ab(cd)?e/, ctx => {
  ctx.sendHTML("You're on a test page");
});

app.listen(
  {
    port: 3030,
  },
  opts => {
    console.log(`Server listening on port ${opts.port}`);
  }
);
```

## Documentation

## Any routing

The helper `anyRoute` make this possible

```ts
import BurnServe, { anyRoute } from "burnserve";

const app = new BurnServe();

app.get(anyRoute(["test", "public"]), ctx => {
  ctx.sendHTML("Hello, world!");
});

// If you don't exclude these path, they won't never show up
app.get("/test", ctx => {
  ctx.sendHTML("You're on a test page");
});

// Same here
app.get(/\/public\/.*/, ctx => {
  ctx.sendHTML("Public folder");
});

app.listen({
  port: 3030,
});
```

## Custom context

**main.ts**

```ts
import { BurnServe } from "./../src";
import { PPContext } from "./PPContex";

const app = new BurnServe<PPContext>({
  context: PPContext,
});

// Exclude public from any rotung
app.getAR(["public"], ctx => {
  ctx.log("Test log");
  ctx.sendHTML("Im' up!");
});

app.get(/\/public\/.*/, ctx => {
  ctx.sendHTML("Public folder");
});

app.listen({
  port: 3030,
});
```

**PPContext.ts**

```ts
import { Context } from "../src";

export class PPContext extends Context {
  public constructor(req: Request) {
    super(req);
  }

  public log(text: string): this {
    console.log(text);
    return this;
  }
}
```

---
_Source: https://npm.io/package/burnserve · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
