Last month, the creator of the Feathers web-framework, David Luecke announced the release of Feathers 4. This release brings built-in TypeScript definitions, a framework-independent authentication mechanism, improved documentation, security updates in database adapters, and more.
Read also: Getting started with React Hooks by building a counter with useState and useEffect
It basically serves as an API layer between any backend and frontend:
Unlike traditional MVC and low-level HTTP frameworks that rely on routes, controllers, or HTTP requests and response handlers, Feathers uses services and hooks. This makes the application easier to understand and test and lets developers focus on their application logic regardless of how it is being accessed. This also enables developers to add new communication protocols without the need for updating their application code.
Key updates in Feathers 4
Built-in TypeScript definitions
The core libraries and database adapters in Feathers 4 now have built-in TypeScript definitions. With this update, you will be able to create a TypeScript Feathers application with the command-line interface (CLI).
Read also: TypeScript 3.6 releases with stricter generators, new functions in TypeScript playground, better Unicode support for identifiers, and more
A new framework-independent authentication mechanism
Feathers 4 comes with a new framework-independent authentication mechanism that is both flexible and easier to use. It provides a collection of tools for managing username/password, JSON web tokens (JWT) and OAuth authentication, and custom authentication mechanisms.
The authentication mechanism includes the following core modules:
- A Feathers service named ‘AuthenticationService’ to register authentication mechanisms and create authentication tokens.
- The ‘JWTStrategy’ authentication strategy for authenticating JSON web token service methods calls and HTTP requests.
- The ‘authenticate’ hook to limit service calls to an authentication strategy.
Security updates in database adapters
The database adapters in Feathers 4 are updated to include crucial security and usability features, some of which are:
- Querying by id: The database adapters now support additional query parameters for ‘get’, ‘remove’, ‘update’, and ‘patch’. In this release, a ‘NotFound’ error will be thrown if the record does not match the query, even if the id is valid.
- Hook-less service methods: Starting from this release, you can call a service method by simply adding ‘a _’ in front instead of using a hook. This will be useful in the cases when you need the raw data from the service without triggering any of its hooks.
- Multi updates: Mulitple update means you can create, update, or remove multiple records at once. Though it is convenient, it can also open your application to queries that you never intended for. This is why, in Feathers 4, the team has made multiple updates opt-in by disabling it by default. You can enable it by explicitly setting the ‘multi’ option.
Along with these updates, the team has also worked on the website and documentation. “The Feathers guide is more concise while still teaching all the important things about Feathers. You get to create your first REST API and real-time web-application in less than 15 minutes and a complete chat application with a REST and websocket API, a web frontend, unit tests, user registration and GitHub login in under two hours,” Luecke writes.
Read Luecke’s official announcement to know what else has landed in Feathers 4.
Other news in web
5 pitfalls of React Hooks you should avoid – Kent C. Dodds
Firefox 69 allows default blocking of third-party tracking cookies and cryptomining for all users