Why Sequoia?
Sequoia
was developed to enhance the Developer Experience for those who create APIs with Node.js
/Deno
. Node.js
has a lot of disadvantages compared to Deno
. That's why Sequoia
was developed first for Deno
. Probably it will be adapted to work with Node.js
in the future. Read more about Deno
on the website
You may consider Sequoia
as an advanced and simplified version of Express
or Oak
. Because for now the libraries have a lot of similarities, but it's a subject to change in the future
Moving to the examples,if you've ever developed an API in Node.js
or Deno
, this code might look familiar to you:
// express.js
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:
// Sequoia
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
})
})
Read more about the better way of handling errors here