Attributes
Includes Deno configuration
Repository
Current version released
3 years ago
Versions
- 2.0.2Latest
- 2.0.1
- 2.0.0
- 1.3.26
- 1.3.25
- 1.3.24
- 1.3.23
- 1.3.22
- 1.3.21
- 1.3.20
- 1.3.19
- 1.3.18
- 1.3.17
- 1.3.16
- 1.3.15
- 1.3.14
- 1.3.13
- 1.3.12
- 1.3.11
- 1.3.10
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.24
- 1.2.23
- 1.2.22
- 1.2.21
- 1.2.20
- 1.2.19
- 1.2.18
- 1.2.16
- 1.2.15
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.20
- 1.1.19
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.8.5
- 0.8.4
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.9
- 0.2.8
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
- 0.1.0
- 0.0.6
- 0.0.5
- 0.0.3
- 0.0.2
- 0.0.1
NHttp
Fast http framework for Deno, Deno Deploy and Cloudflare Workers.
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 (json, urlencoded, raw, multipart).
- Return directly on handlers.
- No third party modules and no std/lib by default.
- Easy deploy to Deno Deploy and Cloudflare Workers.
Benchmark
Here the simple benchmark.
autocannon -c 100 http://localhost:8080/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.
for cloudflare workers visit => https://nhttp.deno.dev/docs/usage/cloudflare-workers
Installation
deno.land
import { NHttp } from "https://deno.land/x/nhttp@1.1.4/mod.ts";
nest.land
import { NHttp } from "https://x.nest.land/nhttp@1.1.4/mod.ts";
Usage
import { NHttp } from "https://deno.land/x/nhttp@1.1.4/mod.ts";
const app = new NHttp();
app.get("/", (rev) => {
return "Hello World";
// return { name: "john" };
// return new Response("Hello World");
// return rev.response.send("Hello World");
});
app.listen(8080, () => {
console.log("> Running on port 8080");
});
METHOD => get | post | put | patch | delete | any | head | options
.
app[METHOD](path: string, …handlers)
Run
deno run --allow-net yourfile.ts
Middleware Example
app.use(...handlers)
or app.use([fn1, fn2])
import { NHttp } from "https://deno.land/x/nhttp@1.1.4/mod.ts";
new NHttp()
.use((rev, next) => {
rev.foo = "foo";
return next();
})
.get("/", ({ foo }) => {
return foo;
})
.listen(8080);
Router Example
app.use(router | router[])
or app.use(basePath, router | router[])
import { NHttp, Router } from "https://deno.land/x/nhttp@1.1.4/mod.ts";
//user router example with base
const user = new Router({ base: "/user" }); // base optional
user.get("/", ...handlers);
user.get("/:id", ...handlers);
user.post("/", ...handlers);
user.put("/:id", ...handlers);
user.delete("/:id", ...handlers);
//item router example without base
const item = new Router();
item.get("/item", ...handlers);
item.get("/item/:id", ...handlers);
item.post("/item", ...handlers);
item.put("/item/:id", ...handlers);
item.delete("/item/:id", ...handlers);
new NHttp()
// register router
.use("/api/v1", [user, item])
.listen(8080);
now, you can access with http://localhost:8080/api/v1/user
Full Documentation NHttp
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
- Deno lint
- Unit Test