Skip to main content
Module

x/fastro/examples/plugin.ts

Fast and simple web application framework for deno
Go to Latest
File
import { Fastro } from "../mod.ts";const server = new Fastro();
const routes = function (server: Fastro, done: Function) { server.use((req) => { req.root = "root"; });
server .get("/", (req) => { req.send(req.root); }) .post("/", (req) => req.send("post")) .put("/", (req) => req.send("put")) .delete("/", (req) => req.send("delete")); done();};
const plugin = function (server: Fastro, done: Function) { server.use((req) => { req.plugin = "plugin"; }); done();};
server .register(plugin) .register(routes) .register("v1", routes) .register("v2", routes);
server.get("/plugin", (req) => { req.send(`${req.plugin} & ${req.root}`);});
await server.listen();