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.64k stars 2.08k forks source link

feat: add extended api to middleware context #7206

Closed lsliwaradioluz closed 4 months ago

lsliwaradioluz commented 4 months ago

πŸ”— Linked issue

Quick feature

❓ Type of change

πŸ“š Description

Provided easy access to methods added by middleware extensions via the context.extendedApi property.

const extensionA = {
  name: 'extensionA',
  extendApiMethods: {
    methodA: async () => { ... }
  }
}

const extensionB = {
  name: 'extensionB',
  extendApiMethods: {
    methodB: async () => { ... }
  }
}

const extensionC = {
  name: 'extensionC',
  extendApiMethods: {
    methodC: async (context) => {
      context.extendedApi.methodA();
      context.extendedApi.extensionB.methodB();
    }
  }
}

πŸ“ Checklist

changeset-bot[bot] commented 4 months ago

πŸ¦‹ Changeset detected

Latest commit: ec46f702af7747d04f8d9f0fefed918f5c6f4dd3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | -------------------------- | ----- | | @vue-storefront/middleware | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

lsliwaradioluz commented 4 months ago

I will wait with releasing it until we can update the middleware version in Storefront packages