Skip to main content
Module

x/fastro/examples/readme.md

Fast and simple web application framework for deno
Go to Latest
File

Examples

You can see above basic example code here: hello.ts

Check the following codes to find out how to:

Create a plugin

You can add new properties or functions to the default request. This feature is similar to the fastify decorator. For example, you want to add a new function that changes the default status and header:

const plugin = (req: FastroRequest) => {
  req.sendOk = (payload: string) => {
    const headers = new Headers();
    headers.set("X-token", "your_token");
    return req.send(payload, 200, headers);
  };
}

server
  .use(plugin)
  .get("/:hello", (req) => req.sendOk("hello"))

Check the following codes to find out how to: