Attributes
Includes Deno configuration
Repository
Current version released
2 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
An Simple Http Route framework for Deno and Friends.
Features
- Simple Performance.
- Middleware support.
- Sub Router support.
- Return directly on handlers.
- Includes body parser with verify body.
- Cross Runtime support (Deno, Bun, Node, etc).
Installation
deno.land
import { nhttp } from "https://deno.land/x/nhttp@1.1.13/mod.ts";
deno-npm
import { nhttp } from "npm:nhttp-land@1.1.13";
nest.land
import { nhttp } from "https://x.nest.land/nhttp@1.1.13/mod.ts";
npm/yarn
npm i nhttp-land
// or
yarn add nhttp-land
import { nhttp } from "nhttp-land";
Usage
import { nhttp } from "https://deno.land/x/nhttp@1.1.13/mod.ts";
const app = nhttp();
app.get("/", (rev) => {
rev.send("Hello, World");
});
// return directly
app.get("/cat", () => {
return "Hello, Cat";
// or json
// return { name: "cat" };
});
app.listen(8000, () => {
console.log("> Running on port 8000");
});
Run
deno run -A myapp.ts
Deno Flash
requires
--unstable
flag.
const app = nhttp({ flash: true });
Middleware
const app = nhttp();
app.use((rev, next) => {
rev.foo = "bar";
return next();
});
app.get("/", ({ foo }) => foo);
Body Parser
Support json / urlencoded / multipart / text
.
note: nhttp automatically parses the body.
const app = nhttp();
// if want disable bodyParser
// const app = nhttp({ bodyParser: false });
app.post("/save", (rev) => {
console.log(rev.body);
return "success save";
});
// inline bodyParser
// app.post("/save", bodyParser(), (rev) => {...});
Other Runtime (Bun / Node)
import { multipart, nhttp } from "nhttp-land";
const app = nhttp();
app.get("/", () => "hello, world");
// example upload
const upload = multipart.upload({
name: "image",
writeFile: Bun.write, /* or fs.writeFileSync */
});
app.post("/upload", upload, (rev) => {
console.log(rev.file);
console.log(rev.body);
return "success upload";
});
app.listen(8000, () => {
console.log("> Running on port 8000");
});
// if cfw or other runtime, just invoke app.handle
// export default { fetch: app.handle };
tsconfig
{
"compilerOptions": {
// if bun
// "types": ["bun-types"],
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
]
}
}