vuestorefront / vue-storefront

Alokai is a Frontend as a Service solution that simplifies composable commerce. It connects all the technologies needed to build and deploy fast & scalable ecommerce frontends. It guides merchants to deliver exceptional customer experiences quickly and easily.
https://www.alokai.com
MIT License
10.59k stars 2.08k forks source link

feat(vsfp-61): init function in the middleware #6749

Closed bartoszherba closed 2 years ago

bartoszherba commented 2 years ago

Description

It solves ADR [#004] connection to API

The onCreate function should be called only once, when we start a middleware, then the app should use an instance of creating client for each incoming request - never create a new one. This is an experimental PR that confirms it: https://github.com/vuestorefront/commercetools/pull/190/files - please notice a change in index.server.ts- there is lifted up the state that holds the instance, only that change increases the capacity of our app rapidly.

Types of changes

Checklist:

Changelog

Tests

Code standards

Docs

Mateuszpietrusinski commented 2 years ago

Hey, we should provide documentation for that functionality.

lukasborawski commented 2 years ago

Yeah, @bartoszherba @filipsobol we're missing docs here.

bartoszherba commented 2 years ago

@filipsobol Could you please double-check the documentation update?

lukasborawski commented 2 years ago

Changelog note is missing as well.

filipsobol commented 2 years ago

❗ Making the createServer async (return a Promise) is a breaking change that should not be a patch, but a minor release. ❗

Please also update the code sample in this section to reflect that createServer is async, eg.:

(async () => {
  const app = await createServer({ integrations });

  app.listen(8181, () => {
    console.log('Middleware started');
  });
})();