Releases: tinyhttp/tinyhttp
@tinyhttp/app@2.2.1
What's Changed
- test: increased coverage for content-disposition, jsonp and type-is by @aarontravass in #411
- fix: subapps mount regardless if path has leading slash or not by @aarontravass in #419
- fix: correctly update req.url on routes and mws by @adhusson in #420
New Contributors
Full Changelog: https://github.com/tinyhttp/tinyhttp/compare/@tinyhttp/app@2.2.0...@tinyhttp/app@2.2.1
v2.2: New (old) view engine
v.2.2
Features
new View engine
by @talentlessguy in #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
- properly set
req.xhr
from a header by @aarontravass in #408 req.route
us assigned the correct middleware if multiple are present by @aarontravass in #409
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 fromes-mime-types
tomime@beta
app.set
,app.enable
andapp.disable
now have stricter typesapp.engine
supports extensions with and without a dotapp.render
,res.render
andapp.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/app@2.1.4...@tinyhttp/app@2.2.0
@tinyhttp/app@2.1.4
@tinyhttp/app@2.1.0
@tinyhttp/router@2.1.0
What's Changed
- Correct type declaration by @bullno1 in #378
- feat: Issue #377 added the ability to accept multiple paths by @aarontravass in #379
New Contributors
- @bullno1 made their first contribution in #378
- @aarontravass made their first contribution in #379
Full Changelog: https://github.com/tinyhttp/tinyhttp/compare/@tinyhttp/router@2.0.7...@tinyhttp/router@2.1.0
V2: Hello ESM, goodbye CJS
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! 鉂わ笍鉂わ笍鉂わ笍
1.3: Adjustments and fixes
Core
- added missing
acceptsLanguages
method inRequest
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
- send:
Range
header support forsendFile
- send: Set
Content-Encoding
andLast-Modified
headers forsendFile
- router: - Simplify router code by using a generic
.add(...)
method - router: Support arrays for route handlers (#65)
- send: added caching support to
sendFile
- cookie: default
req.signedCookies
to{}
- req: fix
req.fresh
not getting set - core: fix
HEAD
not being set implicitly (#243) - core/router: add params support for subapp mountpaths (#242)
v1.2: CLI and initial Deno support
v1.2 CLI and initial Deno support
Core
- Add custom
xPoweredBy
setting (3ff7861) - Fix 404 with query parameters (80dd71c)
- Align types to be identical to Express (fdc47db)
- Get rid of deprecated
url.parse
in favor of a custom func (9a5573f) - Get rid of
mutate
function inapp.handle
(d533d2c)
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/tinyhttp@v0.0.3/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 (01265c0)@tinyhttp/cors
: support a range of origins and regex (6502fcc)@tinyhttp/cors
:preflightContinue
setting (c1cd15a)@tinyhttp/cors
: Fix 404 on OPTIONS in (263dd95)
Docs
- Added a mention of
req.range
(de0ea55) - Show quick start in "Learn" page with the new tinyhttp CLI (0c788d6)
- Add "Donate" secion in readme (7e81e5e)
Examples
Other
v1.1.0. Markdown server upgrade & minor fixes
Core
- Fixes bugs with
req.url
,req.path
andreq.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 haverecursive
option anymore. Instead of file listing, the current directory is switched in case the path contains a directory. Therefore, the ware no longer depends onreaddirp
@tinyhttp/markdown
now has acaching
setting to configureCache-Control
header@tinyhttp/session
now usesexpress-session
as direct dependency instead of dev (#201)
Docs
- Fix typo with router methods in the docs (#204)
v1.0. The time has come.
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
andServerResponse
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.