Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

fastro

ci

Fastro is web framework for developers who are obsessed with simplicity & performance. It is inspired by Express & Fastify.

Check these benchmarks to compare its speed with others.

After refactoring, these features will be released in the next version:

  • Dependency injection
  • Command line interface (CLI)
  • Cloud function

Table of contents

Benchmarks

Go to this folder to check detailed methods & results.

Framework Version Requests/s Percentage Router?
Deno http 1.1.3 15522.4 100.0% βœ—
Node http 14.3.0 15218.6 98.0% βœ—
Fastro 0.13.0 14356.8 92.5% βœ“
Fastify 2.15.1 12346.7 79.5% βœ“
Oak 5.2.0 10504.6 67.7% βœ“
Abc 1.0.0 10137.5 65.3% βœ“
Express 4.17.1 6852.1 44.1% βœ“
PHP 7.3.11 5979.4 38.5% βœ—
Python Flask 1.1.2 544.2 3.5% βœ“

How to use

This module uses the git release. If you do not use the version, simply change v0.13.0 to master branch. Breaking changes may be made without warning.

import { Fastro } from "https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/mod.ts";
const server = new Fastro();
server.get("/", (req) => req.send("root"));
await server.listen();

Run this command to try directly:

deno run --allow-net https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/hello.ts

Server Options

Server options are used to enable the use of payload, logger, and static files.

Static Files

You can enable the use of static files by defining the server option to {static: true}.

const server = new Fastro({ static: true });
server.static("/", "public")

Payload

You can enable the use of payload by defining the server option to {payload: true}.

const server = new Fastro({ payload: true });
server.post("/hello", (req) => {
  const payload = req.payload;
  req.send(payload);
});

Logger

You can enable the use of logger by defining the server option to {logger: true}.

const server = new Fastro({ logger: true });

You can also enable all server options at once:

const server = new Fastro({ payload: true, static: true, logger: true });

Middleware

You can add new properties or functions for specific URL to the default request. This is similar to the express middleware.

const middleware = (req: Request, done: Function) => {
  req.root = () => req.send("root");
  done();
};

server
  .use(middleware)
  .get("/", (req) => req.root());

Plugin

You can add new properties or functions to the fastro instance. You can also use all default instance functions, create routes & middleware. This is similar to the fastify plugin.

const routes = function (fastro: Fastro, done: Function) {
  fastro
    .get("/", (req) => req.send("root"))
    .post("/", (req) => req.send("post"))
    .put("/", (req) => req.send("put"))
    .delete("/", (req) => req.send("delete"));
  done();
};

server.register(routes);

Examples

Run this command to try directly.

deno run -A https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/hello.ts

You can replace above url with these raw urls.

Title Raw URL
Create hello world app https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/hello.ts
Use the basics https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/basic.ts
Get url parameter https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/basic.ts
Get a payload https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/basic.ts
Send results as a file https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/basic.ts
Serve static files https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/static.ts
Create a middleware https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/middleware.ts
Create a plugin https://raw.githubusercontent.com/fastrodev/fastro/v0.13.0/examples/plugin.ts