Releases: lukeed/polka
v1.0.0-next.25
NEW
- Add
@polka/compression
package! (#148): a2105e0, 7745eb4
A lightweightcompression
replacement, with opt-in Brotli support.
Thank you @developit! 🙌
Chores
- Add a licenses.dev badge to README files: 5ff616a
This service recursively analyzes entire dependency graphs to ensure that a package (or your project) is using permissive licenses. For example, here's a results table forpolka@next
and a largerastro
example.
Full Changelog: v1.0.0-next.24...v1.0.0-next.25
v1.0.0-next.24
Features
- Support TypeScript
node16
/nodenext
/bundler
module resolutions support (#192, #200):
Thank you @didinele and @benmccann~!
Patches
-
(
polka
) Upgrade totrouter@4.x
which improved optional wildcard pattern support: 862b08e
Seeregexparam@3.0.0
release notes for more information. -
(
@polka/send
) Apply custom response headers for piped stream (#198): 1568db3
Thank you @aral
Full Changelog: v1.0.0-next.22...v1.0.0-next.24
v1.0.0-next.22
v1.0.0-next.21
Breaking
- (
polka
) Removecode
property support fornext()
errors: f95a5b4
Previously any errors or custom error-objects could use thecode
property to set the response status code. However, this could pose a problem with nativeError
types that set an error code (eg,"ENOENT"
) which is an invalid status code.
Now you must use thestatus
property, which was always supported, but took a backseat tocode
's existence. Express also supports thestatus
property.next({ -- code: 422, ++ status: 422, message: 'Invalid content', });
Chores
- (
@polka/url
) Accomodate an updated error message in test expectant: d30d448
v1.0.0-next.20
v1.0.0-next.17
Patches
- (
@polka/url
): EnsuretoDecode
value is considered duringreq._parsedUrl
cache match: f64b4bb
For example, if youparse
a URL without decoding it, that previous result should not be reused if you callparse
again w/toDecode
set totrue
this time. Should be true for the reverse situation too.
v1.0.0-next.16
Breaking
-
No longer automatically decodes
req.url
andreq.path
values anymore (#172): 6ef32a6, 363e1f6
Previously, these properties had already passed throughdecodeURIComponent
, which could affect Polka's own routing (#142) or external middleware that always expectedreq.path
and/orreq.url
to remain percent-encoded.However, all
req.params
values are still decoded!This change aligns Polka with the default Express decoding behavior.
Chores
v0.5.0
Breaking
-
Remove Promise around
app.listen
(#19): dc56b9d, e34a2a4The previous
polka.listen
was a Promise & had structured input, both of which made it unique from existing frameworks. However, it was also a gotcha for projects migrating from existing frameworks.Instead,
polka.listen
now passes all arguments directly to the underlingserver.listen
, which is arguably more "in tune" with the rest of Polka's ideology around nativehttp
integration.The new method will now rerun the current
Polka
instance directly, allowing you to continue chaining from it, or allowing you to grab theserver
orhandler
values immediately. Previously,.listen()
always had to be last in your chain & resolved to nothing.// Could not do this before 0.5.0 const { server, handler } = polka().listen(); // Or this! const app = polka().listen(PORT, onAppStart); app.use('users', require('./users')) .get('/', (req, res) => { res.end('Pretty cool!'); });
-
Removed built-in
.METHOD()
prototype methods for all 34http.METHODS
: 6d5d094The large majority of these are never used; eg:
ACL
,MKCOL
,MKCALENDAR
, etc.These HTTP/1.1 verbs are supported / available to your Polka applications:
- GET ->
.get()
- POST ->
.post()
- OPTIONS ->
.options()
- DELETE ->
.delete()
- PATCH ->
.patch()
- PUT ->
.put()
- HEAD ->
.head()
- CONNECT ->
.connect()
- TRACE ->
.trace()
- GET ->
Features
-
Polka now supports multiple route-specific handlers! (#18): 42574ac, aac1859, a82f571
This was the most anticipated & most request feature for Polka 🎉
Put simply, variadic route handlers allows you to chain middleware for specific paths. This was only feasible before through
req.path
filters on sub-application or global middleware. Routes can now be modular, allowing you to compose/reuse your server route-by-route instead of group-by-group.Supporting this dramatically improves compatibility between Express and Polka applications. Most importantly, though, this did not come at the expense of performance~!
Here's a very basic example using
passport
, which was often a driver for this feature request:const app = polka(); app.post('/login', // This "guards" this route, executing first passport.authenticate('local', { failureRedirect: '/login' }), // This is the "main" function of this route function (req, res) { res.redirect('/'); });
-
NEW
@polka/url
package: 44a5757, da00320, 87bac82, 17c54a7
Super lightweight URL parser built specifically for Node.js servers.
Patches
Examples
- Added
examples/with-apollo
(#48): a7a38c4 - Added
examples/with-nextjs
(#48): a7a38c4
Thanks @jerolan! - Update
examples/with-socketio
: a9f0f58
Chores
- Fix README:
req.path
instead ofreq.pathname
(#62): a4d96b9
Thanks @antoineneff! - Add Middleware Sequence documentation: d6296ed
- Update Express comparisons: d6296ed, 99f4fe9
- Misc README changes: 734ee31, 35fb3d8, e43bf6f
v0.4.0
Minor Changes
-
Add new
opts.server
option: 276056c, e93ae66, d2f5f96
This allows Polka to attach to predefined, existing servers. It's an alternative approach to booting Polka and wrapping it with another parent server. -
Initialize
server
only when needed: 276056c
Without this, all sub-applications were preemptively booting uphttp
servers. This meant that all servers were just utilizing memory & never served a purpose, since only the main application'sserver
mattered.This change means that the following code sample no longer works:
let { server } = polka(); //=> before: "server" was http.Server //=> current: "server" is undefined
-
Rename
req.pathname
toreq.path
(#29): 7d467f3
This is for Express compatibility. A lot of popular apps/middlewares rely onreq.path
(likewebpack-dev-server
) & it doesn't make to maintainreq.pathname
andreq.path
values.
Patches
- Push root-based middleware group into global middleware: 46285f9
This is mostly a Express-compatibility thing; funky but a needed workaround for some.
Chores
- Fix readme docs: 37fe875, 46086ae
- Rewrite tests with
async
for convenience / sanity: c17440f - Fix tests after
trouter@1.1.0
update: 8af07b5