Changelog History
Page 2
-
v3.2.1 Changes
August 17, 2020๐ฑ ๐ PR:
- โฌ๏ธ Bump autocannon from 5.1.0 to 6.0.0
- โก๏ธ update(package.json): add rafaelgss as member (#2464)
- We have a discord! (#2473)
- ๐ docs: what to do to became a collaborator (#2468)
- โฑ increase timeout (#2477)
- ๐ support unWritable props in the logger option (#2474)
- ๐ fix hasContentTypeParser to include native types (#2450)
- โก๏ธ Update Ecosystem.md (#2479)
- โก๏ธ Update Server.md (#2482)
- ๐ fix: test slowness on windows (#2481)
- ๐ fix: typings for hooks (#2485)
- feat: delete non existent files references (#2491)
- ci: avoid unnecessary runs (#2490)
- doc: add discord badge (#2489)
- โ Adds new section that better explains ESM context and TypeScript exports (#2484)
- โ Add type commonjs (#2493)
- โ Adds support for plugin dynamic imports in TS projects (#2494)
- โ add PROJECT_CHARTER (#2045)
- โ removed unused link (#2496)
-
v3.2.0 Changes
August 06, 2020Features:
- โ Added validationError property to request - #2422
- โ add: route-level custom Error Handlers - #2427
- โ add routePath in onRoute hook - #2451
- feat: add hook onTimeout - #2457
๐ Fixes:
- ๐ fix schema lock in #2463
๐ Documentation:
- โก๏ธ Update Routes.md - #2424
- ๐ Fix several broken links on website, clarify docs - #2434
- ๐ improve and expand docs around error handling - #2425
- ๐ docs: add logger option in async/await example - #2465
TypeScript:
- feat: make fastify() PromiseLike - #2428
- typings: add getSchema and getSchemas - #2441
- ๐ Improve server types - #2449
Internals:
-
v3.1.1 Changes
July 17, 2020 -
v3.1.0 Changes
July 17, 2020 -
v3.0.2 Changes
July 11, 2020๐ฑ ๐ PR:
- ๐ Fix a wrong TypeScript typing issue at register() function (#2401)
-
v3.0.1 Changes
July 11, 2020๐ฑ ๐ PR:
- โ add .dependabot to .npmignore
- โฌ๏ธ Bump tsd from 0.11.0 to 0.12.0 (#2360)
- feat(Serverless): Add netlify-lambda guide (#2359)
- โก๏ธ Update Errors.md (#2364)
- ๐ fix test per security release (#2365)
- โก๏ธ Update Hooks.md (#2363)
- ๐ docs(Serverless): add missing netlify-lambda link (#2362)
- โก๏ธ updated docs/ecosystem to remove old Google Datastore package that we abandoned, removed fastify-firestore in favor of our new fastify-firebase all in one plugin. fastify-firebase includes firebase-admin SDK including auth, firestore, storage, machineLearning, and more (#2366)
- โ add fastify-prettier to ecosystem (#2370)
- โฌ๏ธ Bump tsd from 0.12.1 to 0.13.1 (#2375)
- โก๏ธ Update Hooks.md (#2371)
- await app must resolve to the app (#2376)
- Reorder generic parameter of FastifyRequest for ease of use (#2373)
- โก๏ธ Updated benchmarks (#2380)
- ๐ Fix support for executing benchmark on Windows (#2322)
- โฌ๏ธ Bump fastify-plugin from 1.6.1 to 2.0.0 (#2384)
- โก๏ธ Updated LTS dates (#2383)
- ๐ fix(typo) Correct typo: Alternativies to Alternatives (#2387)
- ๐ Fix
res.raw.statusCode
typo (#2386) - ๐ docs: Created a gentler intro to the .inject method and running tests with tap (#2369)
- โ add Promise version overload for FastifyPlugin (#2350)
-
v3.0.0 Changes
July 08, 2020๐ฅ Breaking changes
โก๏ธ โ ๏ธ When updating your application to Fastify v3, update all the module at once. There might be incompatibilities by trying to do them "one at a time".
๐ Changed middleware support (#2014)
๐ From Fastify v3, middleware support does not come out-of-the-box with the framework itself.
๐ If you use Express middleware in your application, please install and register the
fastify-express
plugin ormiddie
plugin before doing so.v2:
// Using the Express `cors` middleware in Fastify v2.fastify.use(require('cors')());
v3:
// Using the Express `cors` middleware in Fastify v3.await fastify.register(require('fastify-express'));fastify.use(require('cors')());
๐ Changed logging serialization (#2017)
โก๏ธ The logging Serializers have been updated to Fastify
Request
andReply
objects instead of native ones.โก๏ธ Any custom serializers must be updated if they rely upon
request
orreply
properties that are present on the native objects but not the Fastify objects.v2:
const fastify = require('fastify')({logger: {serializers: {res(res) {return {statusCode: res.statusCode,customProp: res.customProp};}}}});
v3:
const fastify = require('fastify')({logger: {serializers: {res(reply) {return {statusCode: reply.statusCode, // No change requiredcustomProp: reply.raw.customProp // Log custom property from res object};}}}});
๐ Changed schema substitution (#2023)
๐ The non-standard
replace-way
shared schema support has been removed. This feature has been replaced with JSON Schema specification compliant$ref
based substitution. To better understand this change read Validation and Serialization in Fastify v3.v2:
const schema = {body: 'schemaId#'};fastify.route({ method, url, schema, handler });
v3:
const schema = {body: {$ref: 'schemaId#'}};fastify.route({ method, url, schema, handler });
๐ Changed schema validation options (#2023)
๐ The
setSchemaCompiler
andsetSchemaResolver
options have been replaced with thesetValidatorCompiler
to enable future tooling improvements. To better understand this change read Validation and Serialization in Fastify v3.v2:
const fastify = Fastify();const ajv = new AJV();ajv.addSchema(schemaA);ajv.addSchema(schemaB);fastify.setSchemaCompiler(schema =\> ajv.compile(schema));fastify.setSchemaResolver(ref =\> ajv.getSchema(ref).schema);
v3:
const fastify = Fastify();const ajv = new AJV();ajv.addSchema(schemaA);ajv.addSchema(schemaB);fastify.setValidatorCompiler(({ schema, method, url, httpPart }) =\>ajv.compile(schema));
๐ Changed preParsing hook behaviour (#2286)
๐ฐ From Fastify v3, the behavior of the
preParsing
hook will change slightly in order to support request payload manipulation.๐ฐ The hook now takes an additional argument,
payload
, and therefore the new hook signature isfn(request, reply, payload, done)
orasync fn(request, reply, payload)
.The hook can optionally return a new stream via
done(null, stream)
or returning the stream in case of async functions.If the hook returns a new stream, it will be used instead of the original one in following hooks. A sample use case for this is handling compressed requests.
โก๏ธ The new stream should add the
receivedEncodedLength
property to the stream that should reflect the actual data size received from the client. For instance, in a compressed request it should be the size of the compressed payload. This property can (and should) be dynamically updated duringdata
events.๐ The old syntax of Fastify v2 without payload is supported but it is deprecated.
๐ Changed hooks behaviour (#2004)
๐ From Fastify v3, the behavior of
onRoute
andonRegister
hooks will change slightly in order to support hook encapsulation.onRoute
- The hook will be called asynchronously. The hook is now inherited when registering a new plugin within the same encapsulation scope. Thus, this hook should be registered before registering any plugins.- ๐
onRegister
- Same as the onRoute hook. The only difference is that now the very first call will no longer be the framework itself, but the first registered plugin.
๐ Changed Content Type Parser syntax (#2286)
๐ In Fastify v3 the content type parsers now have a single signature for parsers.
๐ฐ The new signatures are
fn(request, payload, done)
orasync fn(request, payload)
. Note thatrequest
is now a fastify request, not anIncomingMessage
. The payload is by default a stream. If theparseAs
option is used in
๐ฐaddContentTypeParser
, thenpayload
reflects the option value (string or buffer).๐ The old signatures
fn(req, [done])
orfn(req, payload, [done])
(wherereq
isIncomingMessage
) are still supported but are deprecated.๐ Changed TypeScript support
0๏ธโฃ The type system was changed in Fastify version 3. The new type system introduces generic constraining and defaulting, plus a new way to define schema types such as a request body, querystring, and more!
v2:
interface PingQuerystring {foo?: number;}interface PingParams {bar?: string;}interface PingHeaders {a?: string;}interface PingBody {baz?: string;}server.get\<PingQuerystring, PingParams, PingHeaders, PingBody\>('/ping/:bar',opts,(request, reply) =\> {console.log(request.query); // This is of type `PingQuerystring`console.log(request.params); // This is of type `PingParams`console.log(request.headers); // This is of type `PingHeaders`console.log(request.body); // This is of type `PingBody`});
v3:
server.get\<{Querystring: PingQuerystring;Params: PingParams;Headers: PingHeaders;Body: PingBody;}\>('/ping/:bar', opts, async (request, reply) =\> {console.log(request.query); // This is of type `PingQuerystring`console.log(request.params); // This is of type `PingParams`console.log(request.headers); // This is of type `PingHeaders`console.log(request.body); // This is of type `PingBody`});
๐ป Manage uncaught exception (#2073)
๐ง In sync route handlers, if an error was thrown the server crashed by design without calling the configured
.setErrorHandler()
. This has changed and now all unexpected errors in sync and async routes are managed.v2:
fastify.setErrorHandler((error, request, reply) =\> {// this is NOT calledreply.send(error)})fastify.get('/', (request, reply) =\> {const maybeAnArray = request.body.something ? [] : 'I am a string'maybeAnArray.substr() // Thrown: [].substr is not a function and crash the server})
v3:
fastify.setErrorHandler((error, request, reply) =\> {// this IS calledreply.send(error)})fastify.get('/', (request, reply) =\> {const maybeAnArray = request.body.something ? [] : 'I am a string'maybeAnArray.substr() // Thrown: [].substr is not a function, but it is handled})
Further additions and improvements
- Hooks now have consistent context irregardless of how they are registered (#2005)
- ๐ Deprecated
request.req
andreply.res
forrequest.raw
andreply.raw
(#2008) - โ Removed
modifyCoreObjects
option (#2015) - โ Added
connectionTimeout
option (#2086) - โ Added
keepAliveTimeout
option (#2086) - โ Added async-await support for plugins (#2093)
- โ Added the feature to throw object as error (#2134)
-
v3.0.0-rc.5 Changes
June 29, 2020๐ฑ ๐ PR:
- 0๏ธโฃ Disable allErrors in default Ajv config
- โ Add fastify-peekaboo plugin (#2330)
- โก๏ธ Update Errors.md (#2332)
- feat: specify this context for setErrorHandler (#2338)
- ๐ fix: add code to FastifyError typing (#2337)
- ๐ fix ready order execution (#2333)
- ๐ Allow TS type augmentation for Fastify.prototype.use (#2335)
- List fastify-tokenize on the ecosystem doc page (#2340)
- โ add fastify-raw-body to Ecosystem (#2342)
- ๐ฆ Move createError utility to its own package (#2339)
- โ Add missing parameter
done
in example (#2353) - โ add test to verify ND-JSON content is not serialized as JSON (#2349)
- โก๏ธ updated Getting-Started.md - added more detail making the process easier to understand (#2352)
-
v2.15.3 Changes
August 06, 2020Fixes:
- inject function return normal value with non-ready app - #2417