Back to packages list

Vals using nhttp-land

Description from the NPM package:
An Simple web-framework for Deno and Friends
1
2
3
4
5
6
7
import { denoServer } from "https://esm.town/v/pomdtr/deno_server?v=8";
import nhttp from "npm:nhttp-land@1";
const app = nhttp();
app.get("/", () => "Hello from nhttp");
app.get("/cat", () => ({ name: "cat" }));
export default denoServer(app.handle);
1
2
3
4
5
6
7
8
9
10
11
12
import { nhttp } from "npm:nhttp-land@1";
export const nhttpExample = async (request) => {
const app = nhttp();
app.get("/", () => {
return "Hello from nhttp";
});
app.get("/cat", () => {
return { name: "cat" };
});
return app.handleRequest(request);
};
1
2
3
4
5
6
7
8
9
10
11
12
13
import nhttp from "npm:nhttp-land";
export async function untitled_c5e60f1c(request: Request): Promise<Response> {
const app = nhttp();
app.get("/", () => {
return "- ```javascript\nconsole.log(\"hello\")\n```\n";
});
app.post("/save", (rev) => {
console.log(rev.body);
return `- ${rev.body}`;
});
return app.handleRequest(request);
}

nhttp example

This uses the tiny nhttp framework with the Val Town Web API. New frameworks like nhttp works really well with our system because they rely on the standard Request & Response objects!

Server examples

1
2
3
4
5
6
7
8
9
10
11
export const nhttpExample = async (request) => {
const { nhttp } = await import("npm:nhttp-land@1");
const app = nhttp();
app.get("/", () => {
return "Hello, World";
});
app.get("/cat", () => {
return { name: "cat" };
});
return app.handleRequest(request);
};
1
Next