cacti icon indicating copy to clipboard operation
cacti copied to clipboard

refactor(core,core-api): use fastify, drop express

Open petermetz opened this issue 1 year ago • 6 comments

Description

Express v5 just came out: https://expressjs.com/2024/10/15/v5-release.html but it still doesn't support HTTP 2 so I'd say it's best for us to jump over to the Fastify bandwagon because it has proven itself already (we are already using it in the API server to serve ConnectRPC HTTP 2 traffic)

So this task is about taking it all the way and using Fastify for everything. This involves modifying the core-api/core utility methods/types that are currently dependent on express types. This will be a massive breaking change so we need to schedule this for 3.0.0 instead of a minor or patch release of 2.x.

In the meantime what we can still (probably) do is identify a subset of the places in the code that can be refactored without breaking changes to not use the Express type signatures. (We can create our own type signatures with precision so that they only include a copy of the relevant parts of the Express types/method signatures).

Acceptance Criteria

  1. All tests are still passing.
  2. express and @types/express are completely eliminated from the codebase

petermetz avatar Oct 18 '24 20:10 petermetz

Hello @jagpreetsinghsasan I would like to work on this one, Thanks

aldousalvarez avatar Oct 23 '24 10:10 aldousalvarez

As the refactoring is huge, splitting this task into 2 smaller tasks

TheJagpreet avatar Feb 19 '25 03:02 TheJagpreet

The other task (for cmd-api-server) is located here: #3778

TheJagpreet avatar Feb 19 '25 03:02 TheJagpreet

Hello, @petermetz I have a question about which Fastify version to use. The docs state that Fastify v5.x supports Node 20 and 22, while our current Node version (18.19.0) only supports Fastify v4.x, 3.x, and 2.x. Should we use Fastify v4.x for now and upgrade later, or upgrade Node and use the latest Fastify version?

aldousalvarez avatar Feb 25 '25 13:02 aldousalvarez

@aldousalvarez Very sorry about the slow response. We should use the latest version of Fastify (v5) because Node 18 is no longer maintained as of this month (April 2024) so now we can safely drop support for it. CC: @outSH

petermetz avatar Apr 04 '25 22:04 petermetz

This issue will be considered if the depending package remains, as part of the cleanup initiative: https://github.com/hyperledger-cacti/cacti/issues/4037

This is an important issue, due to Node18 support. A big upgrade is very overdue. Let us sync on existing options @LordKubaya @outSH @AndreAugusto11

RafaelAPB avatar Oct 18 '25 17:10 RafaelAPB