tinyhttp

nest badge GitHub release (latest by date)

This is a Deno port of tinyhttp, 0-legacy, tiny & fast web framework as a replacement of Express.

WARNING! This port is very unstable and is not tested yet. Wait for the v2 release of tinyhttp for a better version (see talentlessguy/tinyhttp#198)

Example

import { App } from 'https://deno.land/x/tinyhttp/app.ts'

const app = new App()

app.use('/', (req, res, next) => {
  console.log(`${req.method} ${req.url}`)

  res.set('Test-Header', 'Value')

  next()
})
app.get('/:name/', (req, res) => {
  res.send(`Hello on <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi>r</mi><mi>e</mi><mi>q</mi><mi mathvariant="normal">.</mi><mi>u</mi><mi>r</mi><mi>l</mi></mrow><mi>f</mi><mi>r</mi><mi>o</mi><mi>m</mi><mi>D</mi><mi>e</mi><mi>n</mi><mi>o</mi><mi>v</mi></mrow><annotation encoding="application/x-tex">{req.url} from Deno v</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">re</span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord">.</span><span class="mord mathnormal">u</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">ro</span><span class="mord mathnormal">m</span><span class="mord mathnormal">De</span><span class="mord mathnormal">n</span><span class="mord mathnormal">o</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span></span></span></span>{Deno.version.deno} and tinyhttp! 🦕`)
})

app.listen(3000, () => console.log(`Started on :3000`))