Coder Social home page Coder Social logo

mvemcjsunpe / tinyhttp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tinyhttp/tinyhttp

0.0 0.0 0.0 8.26 MB

⚡ 0-legacy, tiny & fast web framework as a replacement of Express

Home Page: https://tinyhttp.v1rtl.site

License: MIT License

TypeScript 85.70% JavaScript 2.35% HTML 5.11% CSS 6.56% Shell 0.25% Pug 0.03%

tinyhttp's Introduction

tinyhttp

⚡ Tiny web framework as a replacement of Express

npm GitHub Workflow Status Codecov Vulnerabilities Codacy grade Last commit NPM

tinyhttp is a modern Express-like web framework written in TypeScript and compiled to native ESM, that uses a bare minimum amount of dependencies trying to avoid legacy hell.

Here is a short list of most important features that tinyhttp has:

  • 2.3x faster than Express
  • ⚙ Full Express middleware support
  • ↪ Async middleware support
  • ☑ Native ESM and CommonJS support
  • 🚀 No legacy dependencies, just the JavaScript itself
  • 🔨 Types out of the box
  • 🔥 Prebuilt middleware for modern Node.js

To get started, visit tinyhttp website.

Install

tinyhttp requires Node.js 12.4.0 or newer. It is recommended to use pnpm, although it isn't required.

# npm
npm i @tinyhttp/app
# pnpm
pnpm i @tinyhttp/app
# yarn
yarn add @tinyhttp/app

Docs

You can see the documentation here.

Get Started

tinyhttp is compiled to ESM (and legacy CommonJS) so you can use import / export syntax in Node.js with it.

To setup a Node ESM package, put "type": "module" in the package.json file, like this:

{
  "type": "module"
}

Another option would be using an .mjs extension, then you don't need to put that "type" field in package.json.

For more info, check out the ECMAScript Modules Node.js documentation.

From now on you can use named imports for ESM modules and default imports for CommonJS modules in your project.

The app structure is quite similar to Express, except that you need to import App from @tinyhttp/app instead of default import from express.

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)

For more examples, check examples folder.

Middlewares

tinyhttp offers a list of premade middleware for common tasks, such as session, logger and jwt.

Search and explore the full list at middleware search page.

Comparison

To compare tinyhttp with Express and Polka (another Express-like framework), see COMPARISON.md

Benchmarks

To see benchmark comparison between tinyhttp, polka, express and koa, check benchmark folder.

Contributing

See CONTRIBUTING.md.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


v 1 r t l

💡 🔌 📆 🚧 💻

Matt

🔌 ⚠️

Nasmevka

📖

elianiva

💡 🚧 💻 ⚠️

Katja Lutz

💡

Arnovsky

🔌 💻

Rocktim Saikia

🚇 💻 💡

Ahmad Reza

💻

Ionel lupu

💡

Tomi Kalmi

📖

Luiginator

💡 💻

Aneesh Relan

💡 ⚠️

Roberto Ortega

💡

Barciet Maëlann

💡

shzmr

💻 ⚠️ 💡

Egor Avakumov

💡

Rashmi K A

💻

Shubhi Agarwal

⚠️

Maurizio

⚠️ 💻

jkreller

💡

Alan Carpilovsky

⚠️

KoljaTM

⚠️

ike

📖 💡

Fabian Morón Zirfas

🐛

Vitaly Baev

⚠️ 🐛

omrilotan

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Supporters 💰

These amazing people supported tinyhttp financially:


molefrog

License

MIT © v1rtl

tinyhttp's People

Contributors

ahmad-reza619 avatar alcar avatar allcontributors[bot] avatar arnovsky avatar bertoort avatar betelgeuse1 avatar bra1l0r avatar elianiva avatar iketiunn avatar ionellupu avatar katywings avatar koljatm-edeka avatar luiginator avatar mauriziopz avatar omrilotan avatar rashmi-k-a avatar rocktimsaikia avatar setheal avatar shzmr avatar tkalmi avatar vitalybaev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.