A middleware framework for Deno's http serve

A middleware framework for Deno's http serve

A middleware framework for Deno's http serve. Transplanted from Koa.

A middleware framework for Deno's http serve. Transplanted from Koa.

Quick start

A basic usage, responding to every request with Hello World;

import { App } from "https://deno.land/x/doa/mod.ts";

const app = new App();

app.use(async ctx => {
  ctx.status = 200;
  ctx.body = "Hello World";
});

app.listen({ port: 8000 });

Adding middlewares through app.use(middleware), will cause all of the middlewares to be executed upon each request in the specified order. When you call the middleware, it passed the context and next method in the stack.

A more complex example with responseTime middleware, which will add x-response-time in the response header:

import { App } from "https://deno.land/x/doa/mod.ts";
import { responseTime } from "https://deno.land/x/response-time/mod.ts";

const app = new App();

app.use(responseTime());

app.use(async ctx => {
  ctx.status = 200;
  ctx.body = "Hello World";
});

app.listen({ port: 8000 });

docs

For more information see https://koajs.com/.

Running tests

More than 190 test cases( over 90% ) to ensure code quality.

$ deno test --allow-read --allow-write --allow-net --allow-hrtime  

# test result: ok. 191 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out 

Running benchmarks

Use wrk to benchmark doa.

$  make -C benchmarks 

Trouble Shooting

Make sure you are using deno version 1.1.3 and std 0.59.0. Doa will continue to update deno to the latest version later.

Download Details:

Author: JohannLai

GitHub: https://github.com/JohannLai/doa

deno javascript nodejs node

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Javascript module for easily generating mazes,compatible with both Deno and Node

A work-in-progress Javascript maze generator module, compatible with both Deno and Node.

What is Deno? The Node.JS Killer? The Deno-minator to Node?

What is Deno? The Node.JS Killer? The Deno-minator to Node? Deno is the new hype and will it be better than node.js? Deno is a secure runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language that addresses Node’s shortcomings

What is Deno and is Node.js Dying? | Deno vs Node

What is Deno? Deno vs Node. Is Node.js going to die? Deno is a runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language. It was created by Ryan Dahl, original creator of Node.js, and is focused on productivity. It was announced by Dahl in 2018 during his talk "10 Things I Regret About Node.js"

Deno - How to Compile & Run Javascript Code in Deno Runtime

Learn How to Compile & Run Javascript Code in Deno Runtime.

Deno vs. Node: A Good Crisp Difference Between Node and Deno

Deno vs. Node: A Good Crisp Difference Between Node and Deno - Here is a basic tutorial on a crisp difference between Nodejs and Deno. Before starting with Deno it good to understand what problem deno solves.