Fastro
Fast, simple, minimalist web framework for deno.
import { Fastro } from "https://deno.land/x/fastro/mod.ts";
const server = new Fastro();
server.get("/", (req) => req.send("root"));
await server.listen({ port: 8000 });
How to use
These modules are tagged in accordance with Fastro releases. So, for example, the v0.1.0 tag is guaranteed to work with fastro v0.1.0. You can link to v0.1.0 using the URL https://deno.land/x/fastro@v0.1.0/mod.ts. Not specifying a tag will link to the master branch.
Available route shorthand declaration
server.get(url, handler)
server.post(url, handler)
server.put(url, handler)
server.head(url, handler)
server.delete(url, handler)
server.options(url, handler)
server.patch(url, handler)
Create a plugin
For example you want to get a payload of all post method or want to get the url parameters of all get method or want to get headers of all types of requests -- instead of defining it in each handler, you can make a plugin.
function plugin(req: FastroRequest) {
console.log(req.parameter);
}
server.use(plugin)
Benchmarks
If performance is important to you, here are the benchmark results:
Framework | Version | Router? | Avg Req |
---|---|---|---|
Abc | 1.0.0-rc6 | ✓ | 1002.5 |
Deno-http | 0.52.0 | ✗ | 2479 |
Express | 4.17.1 | ✓ | 519.3 |
Fastify | 2.14.1 | ✓ | 1607.2 |
Fastro | 0.2.13 | ✓ | 1676.3 |
Node-http | 14.3.0 | ✗ | 2140.4 |
Oak | 4.0.0 | ✗ | 1086.2 |
Check this to see the detail method & results: benckmarks
Examples
You can see above basic example code here: hello.ts
Check the following codes to find out how to:
- send simple text & json data
- handle url parameters
- set custom http headers & status
- handle http posts & get the payload
- add server listen optional callback
- plugin: compare parameter with local variable
- plugin: add new request function & property
- plugin: get client headers & custom send method
- plugin: create simple jwt auth