Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more
Module

x/denorest/lib/router.ts>Router

Lightweight, Minimalist Framework For REST API πŸ¦• πŸš€
Latest
class Router
import { Router } from "https://deno.land/x/denorest@v4.2/lib/router.ts";

Use the Router class to create modular, mountable route handlers.

Properties

all: (
path: string,
hand: (req: Req, res: Res) => void,
hook?: ((req: Req, res: Res) => void)[],
) => unknown

for all req method

delete: (
path: string,
hand: (req: Req, res: Res) => void,
hook?: ((req: Req, res: Res) => void)[],
) => unknown

for only DELETE method

get: (
path: string,
hand: (req: Req, res: Res) => void,
hook?: ((req: Req, res: Res) => void)[],
) => unknown

for only GET method

getRoutes: (m?: boolean) => unknown

get all routes in current router

head: (
path: string,
hand: (req: Req, res: Res) => void,
hook?: ((req: Req, res: Res) => void)[],
) => unknown

for only HEAD method

hook: ((req: Req, res: Res) => void)[]
options: (
path: string,
hand: (req: Req, res: Res) => void,
hook?: ((req: Req, res: Res) => void)[],
) => unknown

for only OPTIONS method

patch: (
path: string,
hand: (req: Req, res: Res) => void,
hook?: ((req: Req, res: Res) => void)[],
) => unknown

for only PATCH method

post: (
path: string,
hand: (req: Req, res: Res) => void,
hook?: ((req: Req, res: Res) => void)[],
) => unknown

for only POST method

pre: (path: string, r: Router) => unknown

add prefix routes

put: (
path: string,
hand: (req: Req, res: Res) => void,
hook?: ((req: Req, res: Res) => void)[],
) => unknown

for only PUT method

routes: Routes[]
use: (hand: (req: Req, res: Res) => void) => unknown

add hook