NHttp

License deno.land PRs Welcome deps badge cache badge nest.land

Just native HTTP/2 micro framework for Deno. so hot 🚀

Note: Deno native HTTP/2 Hyper requires Deno version 1.9.0 or higher.

Features

  • HTTP/2 support.
  • Middleware support.
  • Router support.
  • Includes body parser (jsonBody, urlencodedBody).
  • No third party modules and no std/lib by default.
  • Easy deploy to Deno Deploy and Cloudflare Workers.

See examples

Benchmark

Here the simple benchmark.

autocannon -c 100 http://localhost:3000/hello

Name Req/sec Throughput
Native 21433 2.5 MB
NHttp 21127 2.5 MB
std/http 14569 626 KB

Note: maybe not relevant if compared with std/http or other Deno framework using std/http. nhttp uses native deno http.

Installation

deno.land

import { NHttp } from "https://deno.land/x/nhttp@0.7.3/mod.ts";

nest.land

import { NHttp } from "https://x.nest.land/nhttp@0.7.3/mod.ts";

Usage

import { NHttp } from "https://deno.land/x/nhttp@0.7.3/mod.ts";

const app = new NHttp();

app.get("/hello", ({ response }) => {
    response.send('Hello');
});

app.get("/json", ({ response }) => {
    response.json({ name: "john" });
});

app.listen(3000, () => {
    console.log("> Running on port 3000");
});

Run

Note: Deno native http is unstable. so just add --unstable flag.

deno run --allow-net --allow-read --unstable yourfile.ts

Full Documentation NHttp

https://nhttp.deno.dev

or

https://nhttp.herudi.workers.dev

Want to contribute to this project? I gladly welcome it.

  • Please fork.
  • Create a branch.
  • Commit changes (before commit, please format the code with the command deno fmt in the src folder).
  • Push to the created branch.
  • Make a PR (Pull Requests).
  • Thanks.

List

  • Server App
  • Middleware
  • Router
  • Body Parser
  • Examples
  • Doc
  • Unit Test
  • Coverage

License

MIT