Skip to main content

Router

A router like application, you can add HTTP method (get, put, post, or other) to it. For example:

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

const app = nhttp();

// user router
const userRouter = nhttp.Router();
// or
// const userRouter = nhttp.Router({ base: "/user" });

userRouter.get("/user", () => "hello user");

// item router
const itemRouter = nhttp.Router();
itemRouter.get("/item", () => "hello item");

// register the router
app.use("/api", [userRouter, itemRouter]);

app.listen(3000);