Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fsrouter/mod.ts

A file system based router for Deno.
Go to Latest
import * as fsrouter from "https://deno.land/x/fsrouter@2.11.1/mod.ts";

Functions

fsRouter creates a standard library Handler which handles requests according to the shape of the filesystem at the given rootDir. Each file within rootDir must provide a FsHandler as its default export, which will be used to execute requests if the requested route matches the file's position in the filesystem. See docs on FsHandler.

Interfaces

A collection of options to be passed in on initialization.

Type Aliases

Every file to which routes are being served must export a function of type FsHandler as its default export. FsHandler is very similar to the standard library Handler type -- the first argument is a Request object, the second argument is a Query type, and the third argument is the standard library ConnInfo type. The Query argument is placed as the second argument instead of the third for better ergonomics. See example below for more details.

Query is an object of text matched from route wildcards. See FsHandler example for more details.