nhttp

An Simple web-framework for Deno and Friends.

MIT License

Downloads
4.4K
Stars
88
Committers
7

Bot releases are visible (Hide)

nhttp - 1.3.9

Published by herudi about 1 year ago

  • fix(lib/file-router): fix when [...slug].tsx.
  • perf(node): check promise in handlers.
nhttp - 1.3.8

Published by herudi about 1 year ago

Features

feat(lib/file-router): File System Router a`la Nextjs.

// routes/index.ts
import { RequestEvent } from "https://deno.land/x/[email protected]/mod.ts";

export function GET(rev: RequestEvent) {
  return "Hello, Home Index";
}
// app.ts
import { nhttp } from "https://deno.land/x/[email protected]/mod.ts";
import { generateRoute } from "https://deno.land/x/[email protected]/lib/file-router.ts";

const app = nhttp();

await generateRoute(app, "routes", (file) => import("./" + file));

app.listen(8000);

Lookup route from dir :

import { getRouteFromDir } from "https://deno.land/x/[email protected]/lib/file-router.ts";

const route = await getRouteFromDir("my_dir");

console.log(route);
nhttp - 1.3.7

Published by herudi about 1 year ago

  • fix(lib/cors): check origin and vary. support fn. #33
nhttp - 1.3.6

Published by herudi about 1 year ago

  • just resend to apiland.
nhttp - 1.3.5

Published by herudi about 1 year ago

Features

  • feat(query): enable url in query
nhttp - 1.3.4

Published by herudi about 1 year ago

New Libs

  • yoga-grahpql handler
import yogaHandler from "https://deno.land/x/nhttp/lib/yoga.ts"; 
import { createSchema, createYoga } from "npm:graphql-yoga";

const yoga = createYoga({
  schema: createSchema({...}),
});

app.any("/graphql", yogaHandler(yoga));
  • http-logger
import logger from "https://deno.land/x/nhttp/lib/logger.ts";

app.use(logger());

app.get("/", (rev) => {
  rev.log("hello log from home");
  return "home";
});

// try this will print the errors.
app.get("/noop", (rev) => {
  noop();
  return "noop";
});
nhttp - 1.3.3

Published by herudi about 1 year ago

Features

  • feat(jsx): add Client as components for interactive.
const Home = () => {
  return (
    <Client src="/assets/js/home.js" id="home">
       <h1 id="text">hello world</h1>
    </Client>
  )
}

client /assets/js/home.js

const root = document.querySelector("#home");
const text = root.querySelector("#text");
text.innerText = "Hello Home";
nhttp - 1.3.2

Published by herudi over 1 year ago

Minor Update

  • add jsdoc to libs for ease of use.
nhttp - 1.3.1

Published by herudi over 1 year ago

  • fix(zod-validator): mutate rev.body #27
  • feat(serve-static): support URL
nhttp - 1.3.0

Published by herudi over 1 year ago

Features

  • feat(Deno) Adopt Deno.serve to default http-server (requires Deno 1.35.x or letter).
  • feat(jsx) rewrite better Helmet.
nhttp - 1.2.24

Published by herudi over 1 year ago

  • feat(rev): introduce rev.newRequest clone new Request.
  • feat(rev): introduce rev.requestEvent() invoke self RequestEvent.
nhttp - 1.2.23

Published by herudi over 1 year ago

  • feat(core): change to var respondWith and waitUntil
app.get("/", ({ respondWith }) => {
  respondWith(new Response("hello"));
})
nhttp - 1.2.22

Published by herudi over 1 year ago

  • fix(engine): enable chaining by @eevleevs.
nhttp()
  .engine(...)
  .get(...)
  .listen(8000);
  • fix(Deno.serve): don't await app.listen.
const app = nhttp({ flash: true });

// Bad
await app.listen(8000);

// Good
app.listen(8000);
nhttp - 1.2.21

Published by herudi over 1 year ago

  • feat(node): expose app.handle.
http.createServer(app.handle).listen(3000);
  • feat(jsx): expose requestEvent to options.
options.onRenderElement = (elem, rev) => {...};
  • optimized bodyParser.
nhttp - 1.2.20

Published by herudi over 1 year ago

  • (feat/jsx): support async in options.
options.onRenderElement = async (elem) => {...};

options.onRenderHtml = async (html) => {...};
nhttp - 1.2.19

Published by herudi over 1 year ago

  • Allow for BigInt serialization in JSON by @af280cf94190a54043e947948a0031ce7ed71dc
app.get("/", () => ({ int: BigInt(9007199254740991) }));
nhttp - 1.2.18

Published by herudi over 1 year ago

  • multipart change flag writeFile boolean or function.
  • jsx add options to render.
nhttp - 1.2.16

Published by herudi over 1 year ago

  • Add showInfo flag to app.listen.
  • Add storage function to multipart. to support custom storage like (s3, supabase-storage, gdrive, etc).
const upload = multipart.upload({
  async storage(file) {
    // code
  }
});
nhttp - 1.2.15

Published by herudi over 1 year ago

  • add preflight flag to cors libs.
  • support error as string.
app.get("/", () => {
  throw "noop";
  // => { status: 500, message: "noop" };
})
nhttp - 1.2.14

Published by herudi over 1 year ago

  • Add new lib CORS.
import nhttp from "https://deno.land/x/[email protected]/mod.ts";
import cors from "https://deno.land/x/[email protected]/lib/cors.ts";

const app = nhttp();

app.use(cors());

app.get("/", () => "Hello with cors");

app.listen(8000);
  • (internals) change npm: to url in lib.
  • Add onAuth in jwt libs.