Vue Storefront is now Alokai! Learn More
Middleware Extension

Middleware Extension

Coveo integration requires a middleware extension to be added to the middleware configuration.

Install the integration package

If you did not install the module using the Storefront CLI, you need to install the @vsf-enterprise/coveo-api package. Please, check the Installation section.

Create configuration file

Create storefront-middleware/integrations/coveo directory and a file with configuration related to Coveo inside, let's say it's index.ts.

// storefront-middleware/integrations/coveo/index.ts
import type { IntegrationConfig } from "@vsf-enterprise/coveo-api";
import type { ApiClientExtension, Integration } from "@vue-storefront/middleware";
import { coveoExtensionFactory } from "@sf-modules-middleware/coveo";

export const config = {
  location: "@vsf-enterprise/coveo-api/server",
  configuration: {},
  extensions: (extensions: ApiClientExtension[]) => [
      defaultCurrency: 'USD', // Default currency used as a fallback if it's absent in the payload
      commerce: 'commerce' // Name of the key under which the eCommerce integration is registered inside config.integrations object
} satisfies Integration<IntegrationConfig>;

Configure the middleware

Add the coveo configuration to the storefront-middleware/middleware.config.js file. It will enable the middleware to use the Coveo integration and expose required API methods.

import { config as coveoConfig } from "./integrations/coveo";
// ...

const config = {
  integrations: {
    coveo: coveoConfig,