Fast and simple web framework

Fast and simple web framework

High performance backend module. Built on top of Deno standard library. No external dependencies. Written in TypeScript.

Features

  • URL routing by file name
  • URL prefix
  • Dynamic URL parameters
  • Query Parameters
  • URL redirection
  • Supports cookie
  • Supports multipart/form-data
  • Supports application/json
  • Supports application/x-www-form-urlencoded
  • Command line interface

You can see the details in the examples.

Getting started

  • Create webapp folder

    mkdir webapp && cd webapp
    
    
  • Create main.ts

    import { Fastro } from "https://raw.githubusercontent.com/fastrodev/fastro/master/mod.ts";
    new Fastro().listen();
    
  • Run server

    deno run -A main.ts
    
    
  • Open url

    http://localhost:3000
    
    

How to add a handler

  • The structure will be like this:

    webapp
    ├── main.ts
    └── services
        └── hello.controller.ts
    
    

    File and folder description:

    • main.ts: Webapp entrypoint.
    • services: Default folder for all handler files. You can change it via ServerOptions.
    • services/hello.controller.ts: Endpoint handler. You can access it via URL: http://localhost:3000/hello.
  • Create entrypoint main.ts

    import { Fastro } from "https://raw.githubusercontent.com/fastrodev/fastro/master/mod.ts";
    const server = new Fastro();
    server.listen();
    
    • You can add ServerOptions on Fastro construtor to change default service folder, add url prefix, or enable cors.
    • You can pass ListenOptions on listen function to change default port and address.
  • Create handler hello.controller.ts

    import type { Request } from "https://raw.githubusercontent.com/fastrodev/fastro/master/mod.ts";
    
    export const handler = (request: Request) => {
      request.send("hello");
    };
    

    Please note that the handler file name will be used as URL endpoint:

    • hello . controller.ts
  • Run server

    deno run -A main.ts
    
    
  • Open url

    http://localhost:3000/hello
    
    

Command line interface

You can also run your project using fastro command line interface (fastro-cli).

With this, you don’t need an entrypoint file (main.ts) anymore.

  • Install fastro-cli

    deno install -A https://raw.githubusercontent.com/fastrodev/fastro/master/cli/fastro.ts
    
    
  • Run in development (HMR)

    Modules will be reloaded when changes are made.

    fastro serve
    
    
  • Run in production

    You can change the app port also.

    fastro serve --port 8080 --production
    
    

Perfomance

Performance test with hello world keep-alive connection.

Module Version Req/s Percentage
Deno 0.73.0 16384.0 100.00%
Fastro 0.30.5 15291.2 93.33%

You can see the details in the benchmarks.

Download Details:

Author: fastrodev

Demo: https://fastro.dev/fastro/

Source Code: https://github.com/fastrodev/fastro

#deno #node #nodejs #javascript

Fast and simple web framework
2.65 GEEK