SAP / spartacus

Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud that communicates exclusively through the Commerce REST API.
Apache License 2.0
744 stars 389 forks source link

Improve configuration structure for backends #1784

Closed tobi-or-not-tobi closed 5 years ago

tobi-or-not-tobi commented 5 years ago

On our path to make Spartacus more adaptable for other backends and third-party systems, we like to make our configuration more specific. We currently allow to configure the Commerce baseUrl and endpoint configuration in a structure that is not semantic enough to understand. Moreover, it is too generic and wil not scale.

Currently we have these items in the root of the config:

server: {
    baseUrl: environment.occBaseUrl,
    occPrefix: '',
}
endpoints: {
    product: '',
    productReviews: ''
}
site: {
    baseSite: ''
}

These are too generic, and would become unclear as soon as we start adding other backends (Service Factory, Yotpo, etc.). Therefor we like to use:

backend: {
    occ: {
        baseUrl: '',
        prefix: '',
        site: '',
        endpoints: {
            product: '',
            productReviews: ''
        }
    }
}
Platonn commented 5 years ago

We keep site where it is now. The rest of proposed config format is ok.

Platonn commented 5 years ago

QA steps:

  1. configure custom (fake) baseUrl, occ prefix and endpoints in backend.occ config property and verify that HTTP calls are made to custom url
  2. configure baseUrl in meta tag in index.html and verify that HTTP calls are made custom base url
  3. Configure valid baseUrl and travel quickly through whole application (because almost every feature makes calls to OCC) - manual smoke test.
KateChuen commented 5 years ago

backend: { occ: { baseUrl: 'https://hybris.com:9001', },

And confirmed that the calls were being made to the custom url.

occEndpoint

And confirmed that the calls were being made to the custom url.

metaIndex

Went quickly through the application. Was not able to perform a complete smoke test though, because the login screen is missing the login form on dev19 (was like this even before those changes. Gil was troubleshooting this issue but it hasn't been solved yet).

Did the last check on Dev17.

keustma commented 5 years ago

I just saw the Wiki page is not up-to-date with this change. I wanted to create a PR for this, but apparently that is not possible for the Wiki pages. Could you please update the Wiki page to reflect this config change ?

https://github.com/SAP/cloud-commerce-spartacus-storefront/wiki/Setup-and-Installation