Development tinyhttp — tiny Expess-like web framework

v1rtl

teen webdev
Local time
07:15
Joined
Oct 10, 2019
Messages
25
Pronouns
bruh
Project URL
https://tinyhttp.v1rtl.site
Elevator Pitch
Fast, tiny and modular Express-like web framework

Hi y'all, 2-3 months ago I started working on tinyhttp, a tiny, fast and modern web framework that takes concepts from Express.

project link -> https://tinyhttp.v1rtl.site
github repo -> https://github.com/talentlessguy/tinyhttp

Unlike Express, tinyhttp:

  • Is written in TypeScript (=types out of the box)
  • Provides Node ESM support
  • Isn't bloated with useless Node 0.10.X polyfills and targets Node 12 LTS instead, resulting in smaller dependency size and better perf
  • 2.5-3x faster than Express

tinyhttp uses the same pattern for defining routes and middlewares, has the majority of Express req / res extensions and subapp support. So tinyhttp can be used to replace Express in existing apps with minimal struggle.

Example:

Code:
import { App } from '@tinyhttp/app'
import { logger } from '@tinyhttp/logger'

const app = new App()

app
  .use(logger())
  .use(function someMiddleware(req, res, next) {
    console.log('Did a request')
    next()
  })
  .get('/', (_, res) => {
    res.send('<h1>Hello World</h1>')
  })
  .get('/page/:page/', (req, res) => {
    res.status(200).send(`You just opened ${req.params.page}`)
  })
  .listen(3000)

Because the most of popular Express middleware also uses outdated modules, tinyhttp provides a set of its rewrites / remakes of popular wares, such as logger, session and so on. The full list can be viewed here: https://tinyhttp.v1rtl.site/mw

All of the framework is documented with descriptions and example usages. The docs is here: https://tinyhttp.v1rtl.site/docs

tinyhttp also has a learning guide, it's quite rough atm but worth reading to cover main differences with Express and learn some tricks. Also will be a good starting point for those who never used Express. You can check it out here: https://tinyhttp.v1rtl.site/learn

At the moment of making this post, tinyhttp already has more than 15 examples with various cases, from GraphQL to database integration.

tinyhttp has 270+ stars on github and 8K+ downloads at the moment.

Would like to hear your thoughts, and if you liked the project, don't forget to star it!

 
Upvote 2

Gummibeer

Astroneer
Moderator
Local time
05:15
Joined
Oct 5, 2019
Messages
1,162
Pronouns
he/him

Sounds good! 🚀
I have really no project with a JS backend, so I can't switch something to it or use it. But I like types and performance! 😉

 
Top