Tinyhttp Versions Save

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

@tinyhttp/[email protected]

6 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/tinyhttp/tinyhttp/compare/@tinyhttp/[email protected]...@tinyhttp/[email protected]

@tinyhttp/[email protected]

7 months ago

v.2.2

Features

new View engine

by @talentlessguy in https://github.com/tinyhttp/tinyhttp/pull/401

View engine was ported from express for cases like multiple view engines and custom View processing. See docs for more info.

App doesn't require a first argument as engine options in a generic anymore. Instead pass engine options to app.engine and res.render.

Example:

import { App } from '@tinyhttp/app'
import { renderFile, type EtaConfig } from 'eta'
import type { PartialConfig } from 'eta/dist/types/config'

const app = new App()

app.engine('eta', eta.renderFile)

app.use((_, res) => void res.render<PartialConfig>('index.eta', { name: 'Eta' }))

app.listen(3000, () => console.log(`Listening on http://localhost:3000`))

new type: AppConstructor

A constructor type for @tinyhttp/app has been moved into a type for more convenience:

import type { AppConstructor } from '@tinyhttp/app'

new App method: app.disabled

Returns if a setting is disabled:

app.disabled('networkExtensions') // true

Bug Fixes

Improvements

  • Cut down total deps of @tinyhttp/app from 25 to 23.
  • Install size of @tinyhttp/app decreased from 692KB to 540KB (22% smaller) by switching from es-mime-types to mime@beta
  • app.set, app.enable and app.disable now have stricter types
  • app.engine supports extensions with and without a dot
  • app.render, res.render and app.engine support passing template engine options as a generic
  • a few es- modules owned by @talentlessguy are moved to the tinyhttp organization to avoid lock-in and make it easier to maintain

New examples

Full Changelog: https://github.com/tinyhttp/tinyhttp/compare/@tinyhttp/[email protected]...@tinyhttp/[email protected]

@tinyhttp/[email protected]

11 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/tinyhttp/tinyhttp/compare/@tinyhttp/[email protected]...@tinyhttp/[email protected]

@tinyhttp/[email protected]

2 years ago

Slide 16_9 - 18

tinyhttp v2 - Hello ESM, goodbye CJS

tinyhttp finally drops all CommonJS outputs and becomes pure ESM. Node.js 10 became EOL so this means all LTS versions starting v12 support the framework. All of the middlewares are also pure ESM now.

Core

  • BREAKING: move to pure ESM
  • fix: Unable to set url prefix for the application (#249)
  • remove freshnessTesting property because it makes no sense
  • router: align RegexParams types to regexpram
  • fix: console.error triggering in tests
  • don't report error if it is not an Error class instance
  • set proper headers for HEAD requests
  • fix: ETag caching not working (#272)
  • send: set 304 status on fresh request
  • fix: req.path computed improperly (#290)
  • fix: router mount order (#292)
  • fix(send): res.sendFile method forcibly overwrites the HTTP status code with 200

Wares

  • cors: set default allowed headers to content-type (#257)
  • fix(logger): statusEmoji import in logger (#271)
  • deprecate @tinyhttp/session, @tinyhttp/pug
  • move bot-detector, cookie-parser, jwt, logger, favicon, markdown to separate repos
  • ip-filter, rate-limit: remove type dependency on tinyhttp in wares

Other

  • cli: add project name as package.json name (#264)

Docs

  • fix typo in couchdb/README.md (#251)
  • fix broken benchmarks link (#300)
  • rate-limit: Correct status code typo (#303)
  • move website to a separate repo

Examples

  • add turbo-http, neo4j (#269), malibu (#281), swagger (#283) examples
  • use ts-node/esm loader for ts example
  • remove aws, babel, next-custom-server, dev-server examples bc of incompatibility with ESM
  • examples cleanup & deps bump

thanks to @wasd845, @tbhmens, @fabiospampinato, @sbencoding, @e965, @n1ru4l, @paolotiu, @eltociear, @sonnyp, @aral, @wakeupmh, @aldy505, @massivefermion for helping with the project! ❤️❤️❤️

v1.3.0

3 years ago

Core

  • added missing acceptsLanguages method in Request interface

Wares

  • @tinyhttp/favicon - Convert to sync for better compat

Docs

  • typo fixes
  • added section about transpilation to older Node.js versions
  • added Deta to ways of deploying a tinyhttp app

Examples

  • added Deta example

Other

v1.2.0

3 years ago

v1.2 CLI and initial Deno support

Core

  • Add custom xPoweredBy setting (3ff78610646ab3c58451f900ea0bf6a3c54acfc0)
  • Fix 404 with query parameters (80dd71c5d1986b0d78b5fba517587ba214a9212c)
  • Align types to be identical to Express (fdc47dbbc127b75945b54c1af6f8df37e7b4e9fe)
  • Get rid of deprecated url.parse in favor of a custom func (9a5573fb7fd724d52217745c839d81bacb3f90f9)
  • Get rid of mutate function in app.handle (d533d2cbac50d93e6f88b0cc738e90fe1fbb2125)

New packages

  • the tinyhttp CLI has been created which allows you to easily quick start projects using the repository examples.

For example:

tinyhttp new prisma-graphql my-new-project --prettier --eslint
  • work on Deno port of tinyhttp has started. It's currently very basic and the more stable version of it is going to be in v2

Example from README:

import { App } from 'https://deno.land/x/[email protected]/app.ts'

const app = new App()

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

  next()
})

app.get('/:name/', (req) => {
  req.respond({ body: `Hello ${req.params.name}!` })
})

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

Wares

  • @tinyhttp/logger: no longer depend on core (01265c002d18a06e210f45bf5cb3a82f4e86d51a)
  • @tinyhttp/cors: support a range of origins and regex (6502fcc56b05d6112c615f2af514dab0aa3ec248)
  • @tinyhttp/cors: preflightContinue setting (c1cd15a21964c021e831d95eb936c7ced224fba8)
  • @tinyhttp/cors: Fix 404 on OPTIONS in (263dd95215136f0717d9016bdf371f7747afb7a3)

Docs

  • Added a mention of req.range (de0ea5503c7b50907d99598b831bed5d69e6f31e)
  • Show quick start in "Learn" page with the new tinyhttp CLI (0c788d646ff187598f7c4bd5222f1b1b3289400c)
  • Add "Donate" secion in readme (7e81e5ee1de2cc3d8c416995119fa7445c1205dc)

Examples

  • Rewrite validator example (a83d59926f07d8e90273d0791da47fcb4fdc8915)
  • Update AWS example (8468755650d156a5689a9174ab8113dc808a38be)

Other

  • Add missing headers for res.sendFile (de0ea5503c7b50907d99598b831bed5d69e6f31e)
  • Fix res.cookie not appending headers (bd5ca65c94c4a3a47ab8d36f58070148425aaf81)
  • Make value argument optional for res.set and res.header (b06d8d5da933b86fd64e4b7afdca5f24cb02f1cb)

v1.1.0

3 years ago

Core

  • Fixes bugs with req.url, req.path and req.originaUrl (#203)
  • Fixes res.redirect incorrect URI encoding (#205)
  • Fixes res.set (and extensions using it) not adding charset
  • Fixes res.render not inheriting template engine settings

Middleware

  • @tinyhttp/markdown now sends a stream instead of plain text using streamdown
  • @tinyhttp/markdown doesn't have recursive option anymore. Instead of file listing, the current directory is switched in case the path contains a directory. Therefore, the ware no longer depends on readdirp
  • @tinyhttp/markdown now has a caching setting to configure Cache-Control header
  • @tinyhttp/session now uses express-session as direct dependency instead of dev (#201)

Docs

  • Fix typo with router methods in the docs (#204)

v1.0.0

3 years ago

Finally, after months of hard work, different implementation decisions, collaborations with contributors I'm thrilled to announce the first stable release of tinyhttp!

Express API implementation

100% ready. The only method that isn't implemented is app.param, which was deprecated in Express 4.11.

Core

Catching errors in async handlers

errors thrown in async handlers are now catched and passed to next, e.g. if an error is throwed in a handler it won't crash and will keep working.

Example:

import { App } from '@tinyhttp/app'

const app = new App()

app.use(async (_req, _res) => {
  throw `error`
})

app.listen(3000)

The app will return the error and send 500 status:

$ curl localhost:3000
error

Custom middleware extensions

WIth the new applyExtensions parameter you can define your own req / res extensions, or disable all tinyhttp's extensions to achieve the best performance.

import { App } from '@tinyhttp/app'
import { send } from '@tinyhttp/send'

const app = new App({
  applyExtensions: (req, res, next) => {
    // now tinyhttp only has a `res.send` extension
    res.send = send(req, res)
  }
})

Other changes

  • Test coverage is increased to 92%
  • The majority of tinyhttp's modules have more flexible types now which don't require the full implementation of IncomingMessage and ServerResponse objects but only the properties which are used inside the module. This will let developers use these packages inside their own projects and not only in Node.js runtime.
  • Docs are updated with the current status of the project.