Repository
Current version released
2 years ago
Dependencies
std
fsrouter
A file system based router for Deno.
Usage
Given a project with the following folder structure:
my-app/
ββ pages/
β ββ blog/
β β ββ post.ts
β β ββ index.ts
β ββ about.ts
β ββ index.ts
ββ mod.ts
And the following mod.ts
:
// my-app/mod.ts
import fsRouter from "https://deno.land/x/fsrouter@{VERSION}/mod.ts";
import { serve } from "https://deno.land/std@{VERSION}/http/server.ts";
// Use the file system router with base directory 'pages'
serve(await fsRouter("pages"));
Routes are then served as follows:
File | Route |
---|---|
pages/index.ts |
/ |
pages/about.ts |
/about |
pages/blog/index.ts |
/blog |
pages/blog/post.ts |
/blog/post |