Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Middleware web-framework for creating fast and easy-to-use servers
Sequoia
A library for creating clean and minimalistic HTTP servers. It is inspired by Oak and it is mostly compatible with it.
Getting started
To get started you can create your own server using this snippet:
// server.ts import { Application, Router, HTTPStatus, HTTPResponse, ContentType } from 'jsr:@sequoia/sequoia' const app = new Application() const router = new Router() router.GET('/', (_ctx) => { return new HTTPResponse({ status: HTTPStatus.SUCCESS, type: ContentType.JSON, body: { ok: true, healthcheck: 'success' } }) }) app.useRouter(router) app.listen({ port: 8000 })
Then you can run the created server by running: deno run --allow-net server.ts
It will spin up a server at http://localhost:8000
. This server will respond with a JSON { ok: true, healthcheck: 'success' }
What's the difference from Oak?
The main difference that Sequoia has over Oak is the simplified approach to sending responses:
// oak.ts (ctx) => { ctx.response.status = 200 ctx.response.headers.set('Content-Type', 'application/json') ctx.response.body = JSON.stringify({ ok: true, healthcheck: 'success' }) } // sequoia.ts (_ctx) => { return new HTTPResponse({ status: HTTPStatus.SUCCESS, type: ContentType.JSON, body: { ok: true, healthcheck: 'success' } }) }
The examples above create 2 identical Response
objects, but in Sequoia
we aim to give the best developer expirience possible. So instead of setting each property of response individually you can just return the HTTPResponse
object from middleware. In addition to that there is an enum HTTPStatus
which you can use to easily set the status code of response.
Add Package
deno add jsr:@sequoia/sequoia
Import symbol
import * as sequoia from "@sequoia/sequoia";
Import directly with a jsr specifier
import * as sequoia from "jsr:@sequoia/sequoia";
Add Package
bunx jsr add @sequoia/sequoia
Import symbol
import * as sequoia from "@sequoia/sequoia";