ios-dev/comments/Home/node_modules/@tinyhttp/app
Ernest Litvinenko 0066e66a47 Initial 2024-03-11 14:47:28 +03:00
..
dist Initial 2024-03-11 14:47:28 +03:00
LICENSE Initial 2024-03-11 14:47:28 +03:00
README.md Initial 2024-03-11 14:47:28 +03:00
package.json Initial 2024-03-11 14:47:28 +03:00

README.md

@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)