GithubHelp home page GithubHelp logo

logo

NHttp

An Simple web-framework for Deno and Friends.

ci coverage codefactor denoland deps size size licence prs nestland


Features

  • Focus on simple and easy to use.
  • Fast Performance. One of the fastest Frameworks.
  • Cross runtime support (Deno, Node, Bun, etc).
  • Low overhead & True handlers (no caching anything).
  • Built-in Middleware.
  • Sub router support.
  • Template engine support (jsx, ejs, nunjucks, eta, pug, ..etc).
  • Return directly on handlers.
  • Auto parses the body (json / urlencoded / multipart / raw).

See Examples

v1.3.0 requires Deno 1.35 or higher.

CLI

Deno

deno run -Ar npm:create-nhttp

Npm

npm create nhttp@latest

Manual Installation

deno.land

import nhttp from "https://deno.land/x/nhttp/mod.ts";

deno-npm

import nhttp from "npm:nhttp-land";

npm/yarn

npm i nhttp-land

// or

yarn add nhttp-land
// module
import nhttp from "nhttp-land";

// commonjs
const nhttp = require("nhttp-land").default;

Simple Usage

Create file app.ts and copy-paste this code.

import nhttp from "https://deno.land/x/nhttp/mod.ts";

const app = nhttp();

app.get("/", () => {
  return "Hello, World";
});

app.get("/cat", () => {
  return { name: "cat" };
});

app.listen(8000);

Run

deno run -A app.ts

Using JSX + Htmx

Create file app.tsx and copy-paste this code.

/** @jsx n */
/** @jsxFrag n.Fragment */

import nhttp from "https://deno.land/x/nhttp/mod.ts";
import { htmx, n, renderToHtml } from "https://deno.land/x/nhttp/lib/jsx.ts";

const app = nhttp();

app.engine(renderToHtml);

app.use(htmx());

app.get("/", () => {
  return (
    <button hx-post="/clicked" hx-swap="outerHTML">
      Click Me
    </button>
  );
});

app.post("/clicked", () => {
  return <span>It's Me</span>;
});

app.listen(8000);

Run

deno run -A app.tsx

more docs => https://nhttp.deno.dev

3rd-party libs

Like std-libs for NHttp.

Usage

// Deno
import {...} from "https://deno.land/x/nhttp/lib/my-libs.ts";

// Deno NPM
import {...} from "npm:nhttp-land/my-libs";

// Node or Bun
import {...} from "nhttp-land/my-libs";

ServeStatic

import nhttp from "https://deno.land/x/nhttp/mod.ts";
import serveStatic from "https://deno.land/x/nhttp/lib/serve-static.ts";

const app = nhttp();

app.use(serveStatic("./my_folder"));

// with prefix
app.use(serveStatic("./my_folder", { prefix: "/assets" }));
// or
// app.use("/assets", serveStatic("./my_folder"));

// with URL
app.use(serveStatic(new URL("./my_folder", import.meta.url)));

more libs => https://nhttp.deno.dev/docs/3rd-party-lib

License

MIT

nhttp's Projects

nhttp icon nhttp

An Simple web-framework for Deno and Friends.

raptor icon raptor

Fast router handler for Deno and Deno Deploy

redge icon redge

A minimal React partial-hydrations on the edge.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.