Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@tinyhttp/app

tinyhttp374kMIT2.5.0TypeScript support: included

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

tinyhttp, router, backend, http, framework, api

readme

@tinyhttp/app

The core of tinyhttp. Contains the App, Request and Response. Additionally, it provides special tinyhttp-specific types.

Install

pnpm i @tinyhttp/app

Example

import { App } from '@tinyhttp/app'
import type { Request, Response, NextFunction } from '@tinyhttp/app'

new App()
  .use((req: Request, res: Response, next: NextFunction) => {
    console.log('Did a request')
    next()
  })
  .get('/', (_, res) => res.send('<h1>Hello World</h1>'))
  .get('/page/:page', (req, res) => res.send(`You opened ${req.params.page}`))
  .listen(3000)