Repository
Current version released
4 years ago
Dependencies
deno.land/x
Versions
Usage example
import { Application } from "https://deno.land/x/oak@v9.0.1/mod.ts";
import { StaticRouter } from "./mod.ts";
const app = new Application();
const router = new StaticRouter();
await router.statics({
absolute: "./path/to/views",
relative: "/",
});
await router.statics({
absolute: "./path/to/styles",
relative: "css",
});
await router.statics({
absolute: "./path/to/scripts",
relative: "js",
});
app.use(await router.routes);
await app.listen({ port: 8080 });The class StaticRouter receives a list of paths and provides a number of methods:
staticsAllows to declare a static route and receives an argument of type path.
routesit is an asynchronous getter that returns the routes already configured.
The Path type contains information about the paths to use:
absolutedefines the absolute path of the file or folder
relativedefines the relative path within the router