Skip to main content
The Deno 2 Release Candidate is here
Learn more

Sequoia 🦕

A library for handling HTTP requests by using middlewares. Inspired by Oak. Written in TypeScript, works with Deno runtime

Why Sequoia?

If you ever had some experience with web frameworks, you’ve probably wrote something like this:

app.get('/', (req, res) => {
    const body = { ok: true, user: { id: 1, name: 'John Doe' } }
    res.status(201).json(body).cookie('access_token', 'Bearer a62bc1')
})

A chain of methods like this res.status(201).json(body).cookie('access_token', 'Bearer a62bc1') is not a great example of Developer Experience

Sequoia on the other hand provides you a better way to do this:

app.GET('/', (ctx) => {
    const body = { ok: true, user: { id: 1, name: 'John Doe' } }
    ctx.cookies.set('access_token', 'Bearer a62bc1')

    return new HTTPResponse({
        status: HTTPStatus.CREATED,
        type: 'application/json',
        body
    })
})

In Sequoia there is an HTTPResponse class which stands in-between the developer and the actual Response object that is being sent to the user. While using this class you are getting the great intellisense in your IDE and creating APIs become a much more pleasant experience

image

Usage

Prerequisites

To use this library you obviously need Deno (v1.30.3 or later) to be install on your machine. Check out the installation guide

Getting started

Using Sequoia might seem familiar to those who had some experience with Oak, Koa, Express or any other middleware library.

Warning: The project is still in Beta stage. So the API and the provided functionality might change after achieving v1.0.0

To get started you can use this example:

// example.ts
import { Application, Router, HTTPStatus, HTTPResponse } from 'https://deno.land/x/sequoia/mod.ts'

const app = new Application({ logging: true })
const router = new Router({ type: 'application/json' })

router.GET('/', (ctx) => {
    const agent = ctx.request.headers.get('User-Agent')
    ctx.response.headers.set('X-Powered-By', 'Sequoia')
    ctx.cookies.set('WebServer', 'Sequoia')

    return new HTTPResponse({
        status: HTTPStatus.SUCCESS,
        body: { ok: true, agent }
    })
})

app.useRouter(router)

const APP_IP = Deno.env.get('APP_IP') ?? '127.0.0.1'
const APP_PORT = Number(Deno.env.get('APP_PORT') ?? 8000)

app.listen(
    { hostname: APP_IP, port: APP_PORT },
    () => console.log('The sequoia server is up!')
)

To run this example just use:

deno run --allow-net --allow-env example.ts

After running this command the server is running, so you can go to http://localhost:8000 in your browser and there you can see the response which might look like this: { 'ok': true, 'agent': 'curl/7.85.0' }

To see more examples visit: examples

Roadmap

Right now Sequoia is only maintained by its original creator (@len0xx), though anyone on the internet is welcome to contribute. So new features of a library depend directly on the free time of its maintainer. Do not expect releases too often.

The features that are expected in the upcoming releases:

  • Allow serving static files via CLI
  • Examples folder
  • Support for TLS
  • Unit tests and CI/CD through GitHub Actions
  • Support for WebSockets
  • Better compatibility with svelte-adapter-deno
  • Support for compression and other HTTP headers