You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is a common task to add support for a custom (non-standard) SAP OCC API endpoint not covered by the Alokai intergration.
4
-
This guide will show you how can do it using Alokai.
4
+
There are two ways how you can do it:
5
5
6
-
## Prerequisites
6
+
1. Generate new API client based on OpenAPI (swagger) specification.
7
+
2. Add support for a custom endpoint manually.
7
8
8
-
Before we start make sure that you are familiar with [Adding New API Methods](https://docs.alokai.com/storefront/integration-and-setup/storefront-extension#adding-new-api-methods) guide. With that guide, you would be able to
9
+
## Generating new API client
10
+
11
+
Generation of new API client allows you to add support for all custom endpoints at once. You just run a script and all the endpoints will be added to the integration.
12
+
13
+
How to do this is described in the [Generated API guide](/integrations/sapcc/features/generated-api).
14
+
15
+
This should be your default approach, because it is the most scalable and maintainable way.
16
+
17
+
## Adding support for a custom endpoint manually
18
+
19
+
If you don't want or cannot generate a new API client, you can add support for a custom endpoint manually.
20
+
It boils down to adding a new API method to the middleware that calls the custom endpoint. This guide shows how to do it efficiently.
21
+
22
+
When to use this approach?
23
+
24
+
- When for some reason you cannot generate a new API client, e.g. OpenAPI specification is not available.
25
+
- When you are iterating fast both on the API and the front-end and you don't want to regenerate the API client for each change.
26
+
27
+
### Prerequisites
28
+
29
+
Before we start make sure that you are familiar with [Adding New API Methods](/unified-data-layer/integration-and-setup/creating-new-api-methods) guide. With that guide, you would be able to
9
30
communicate with OCC API but it would require manual retrieval of context parameters (baseSiteId, userId, language,
10
31
and currency) and preparation of authorization headers. Read on to see how to streamline that process.
11
32
12
-
## Communicating with OCC API effectively
33
+
###Communicating with OCC API effectively
13
34
14
35
OCC endpoints have a given structure
15
36
@@ -35,74 +56,69 @@ Here's where to find the parameters:
35
56
36
57
-`baseUrl` - is configured in .env file as `SAPCC_API_URI`. The api client already knows it and prepends each URL with it.
37
58
-`baseSiteId` - is defined in the middleware configuration. That configuration is exposed to api method via context.
38
-
-`userId` - can be found in the request cookies under [`AUTH_USER_COOKIE_NAME`](https://docs.alokai.com/integrations/sapcc/api/sapcc-api/AUTH_USER_COOKIE_NAME).
39
-
-`language` - can be found in the request cookies under [`VSF_LOCALE_COOKIE`](https://docs.alokai.com/storefront/features/internationalization/internatialization-support).
40
-
-`currency` - can be found in the request cookies under [`VSF_CURRENCY_COOKIE`](https://docs.alokai.com/storefront/features/internationalization/currency-switching).
41
-
- authorization token - can be found in the request cookies under [`AUTH_USER_TOKEN_COOKIE_NAME`](https://docs.alokai.com/integrations/sapcc/api/sapcc-api/AUTH_USER_TOKEN_COOKIE_NAME)
59
+
-`userId` - can be found in the request cookies under [`AUTH_USER_COOKIE_NAME`](/integrations/sapcc/api/sapcc-api/AUTH_USER_COOKIE_NAME).
60
+
-`language` - can be found in the request cookies under [`VSF_LOCALE_COOKIE`](/storefront/features/internationalization/internatialization-support).
61
+
-`currency` - can be found in the request cookies under [`VSF_CURRENCY_COOKIE`](/storefront/features/internationalization/currency-switching).
62
+
- authorization token - can be found in the request cookies under [`AUTH_USER_TOKEN_COOKIE_NAME`](/integrations/sapcc/api/sapcc-api/AUTH_USER_TOKEN_COOKIE_NAME)
42
63
43
64
You don't have to parse the cookies yourself. Alokai provides helper methods for that. Here’s a code example of how to do it:
Here's an example implementation of the product interest feature. This feature is available in OCC API, but not in the middleware and SDK integration.
113
+
Here's an example implementation of the product interest feature.
92
114
Let's add support for it.
93
115
94
-
First, you need to add a new API method in the middleware. (For simplicity, this guide shows how to do it in one file, but we recommend splitting it into multiple files to maintain cleaner code.)
116
+
First, you need to add a new API method in the middleware.
Copy file name to clipboardExpand all lines: docs/content/guides/1.index.md
+15-5Lines changed: 15 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -34,15 +34,26 @@ Alokai is not a cookie-cutter solution, it is meant to be able to handle even th
34
34
Learn how to create efficient and unified multigeo/multibrand/multivendor setups with Alokai.
35
35
::
36
36
37
-
#section-4
38
-
:card{to="/guides/kubernetes-probe"title="Kubernetes Probes"description="Alokai Cloud customers' middleware and frontend apps are deployed in Kubernetes. Check how Kubernetes mechanisms are used by Alokai Cloud"icon="tabler:heart-rate-monitor"}
37
+
::
38
+
39
+
## Advanced
39
40
40
-
#section-5
41
-
:card{to="/guides/best-practices"title="Best Practices"description="Check what to follow to keep your storefront in the best possible shape"icon="tabler:rosette-discount-check"}
Learn how to implement health check endpoints for your Alokai Cloud applications running on Kubernetes. This guide covers liveness and readiness probes implementation to ensure proper application monitoring and reliability.
Every 100ms added to loading time costed Amazon 1% less sales. Don't let the poor performance to ruin your sales. Learn how to optimize your store for speed.
In this guide, we have compiled a collection of best practices to help you optimize your development workflow, improve code quality, and ensure maintainability.
Every 100ms added to loading time costed Amazon 1% less sales. Don't let the poor performance to ruin your sales. Learn how to optimize your store for speed.
Copy file name to clipboardExpand all lines: docs/content/guides/6.best-practices/2.data-fetching.md
+8-3Lines changed: 8 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,8 @@ The rule of thumb is: _always use server-side fetching except for_:
42
42
43
43
Alokai architecture introduces the Middleware in between the front-end application and the APIs. This adds two additional possible routes to our diagram, but most of the traffic should go through the middleware, because:
44
44
45
-
- it is cached on the CDN
45
+
<!-- Uncomment below when CDN caching is availavble -->
46
+
<!-- - it is cached on the CDN -->
46
47
- it keeps your architecture simple
47
48
- you can easily monitor middleware traffic in the console
@@ -58,13 +59,17 @@ Fortunately, we can reject the route between the server and the API, because:
58
59
The direct route between the browser and API should be avoided, because it:
59
60
60
61
- tightly couples storefront with the API,
61
-
- reduces performance by bypasses CDN cache.
62
+
<!-- Uncomment below when CDN caching is availavble -->
63
+
<!-- - reduces performance by bypassing CDN cache. -->
62
64
63
65
Use direct direct browser to API calls only when communicating via middleware is not possible or requires unnecessary effort. Sample scenarios when it might be valid to communicate directly between client and API:
64
66
65
67
- the communication requires extremely low latency - e.g. voice or video stream
66
68
- communication with API is done via some SDK that requires direct client (browser) interaction - e.g. analytics or authentication services
67
69
70
+
71
+
<!-- Uncomment below when CDN caching is availavble -->
72
+
<!-- ## CDN Caching
68
73
## CDN Caching
69
74
70
75
To further improve your application performance we encourage you to enable the CDN. The CDN is capable of caching responses from the server and the middleware to the browser.
@@ -73,7 +78,7 @@ To further improve your application performance we encourage you to enable the C
73
78
74
79
::info
75
80
[Read more about caching here.](/storefront/features/cdn/making-ssr-cacheable)
On this page you'll find a set of guides that will help you to understand the fundamentals of Alokai and how different parts of our stack will help you to build your Alokai application.
9
+
10
+
Below you will find a list of guides to help you get started with Alokai.
0 commit comments