Node.JS – Foal framework – Version 2.2 release notes

Version 2.2 of Foal has been released! Here are the improvements that it brings. New … Read more Node.JS – Foal framework – Version 2.2 release notes

Banner

Version 2.2 of Foal has been released! Here are the improvements that it brings.

New Look of the createapp Command#[1]

The output of the createapp command has been prettified to be more “welcoming”.

New createapp look

Authentication Improvement for Single-Page Applications (SPA)#[2]

When building a SPA with cookie-based authentication, it can sometimes be difficult to know if the user is logged in or to obtain certain information about the user (isAdmin, etc).

Since the authentication token is stored in a cookie with the httpOnly directive set to true (to mitigate XSS attacks), the front-end application has no way of knowing if a user is logged in, except by making an additional request to the server.

To solve this problem, version 2.2 adds a new option called userCookie that allows you to set an additional cookie that the frontend can read with the content you choose. This cookie is synchronized with the session and is refreshed at each request and destroyed when the session expires or when the user logs out.

In the following example, the user cookie is empty if no user is logged in or contains certain information about him/her otherwise. This is particularly useful if you need to display UI elements based on user characteristics.

Server-side code

Cookies

User cookie

Client-side code

Support of Nested Routes in foal generate|g rest-api <name>#[3]

Like the command g controller, g rest-api now supports nested routes.

Let’s say we have the following file structure:

Running these commands will add and register the following files:

References

  1. ^ Direct link to heading (foalts.org)
  2. ^ Direct link to heading (foalts.org)
  3. ^ Direct link to heading (foalts.org)


Source: Echo Js


Categories: Development, Software


Leave a Reply

Your email address will not be published. Required fields are marked *