@unchainedshop/cockpit-api 1.0.29 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +1 -1
- package/package.json +1 -1
- package/src/api.ts +3 -3
package/dist/api.js
CHANGED
|
@@ -113,7 +113,7 @@ const handleErrorAndLog = (e) => {
|
|
|
113
113
|
return null;
|
|
114
114
|
};
|
|
115
115
|
export const CockpitAPI = async (tenant, cockpitOptions) => {
|
|
116
|
-
if (!process.env.COCKPIT_GRAPHQL_ENDPOINT
|
|
116
|
+
if (!process.env.COCKPIT_GRAPHQL_ENDPOINT && !cockpitOptions?.endpoint)
|
|
117
117
|
throw Error("COCKPIT_GRAPHQL_ENDPOINT is not set");
|
|
118
118
|
const cockpitEndPOint = cockpitOptions.endpoint || process.env.COCKPIT_GRAPHQL_ENDPOINT;
|
|
119
119
|
const buildUrl = (path, { locale = "de", queryParams = {} } = {}) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/cockpit-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "A package to interact with the Cockpit CMS API, including functionalities to handle GraphQL requests and various CMS content manipulations.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"homepage": "https://unchained.shop",
|
package/src/api.ts
CHANGED
|
@@ -135,8 +135,8 @@ const handleErrorAndLog = (e: Error) => {
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
export const CockpitAPI = async (tenant?: string, cockpitOptions?: CockpitAPIOptions) => {
|
|
138
|
-
if (!process.env.COCKPIT_GRAPHQL_ENDPOINT
|
|
139
|
-
const
|
|
138
|
+
if (!process.env.COCKPIT_GRAPHQL_ENDPOINT && !cockpitOptions?.endpoint) throw Error("COCKPIT_GRAPHQL_ENDPOINT is not set")
|
|
139
|
+
const cockpitEndpoint = cockpitOptions?.endpoint || process.env.COCKPIT_GRAPHQL_ENDPOINT;
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
const buildUrl = (path: string, { locale = "de", queryParams = {} } = {}) => {
|
|
@@ -191,7 +191,7 @@ export const CockpitAPI = async (tenant?: string, cockpitOptions?: CockpitAPIOpt
|
|
|
191
191
|
return {
|
|
192
192
|
async graphQL(document: any, variables: any) {
|
|
193
193
|
const query = print(document);
|
|
194
|
-
const cockpitEndpointUrl = new URL(
|
|
194
|
+
const cockpitEndpointUrl = new URL(cockpitEndpoint);
|
|
195
195
|
if (tenant) {
|
|
196
196
|
cockpitEndpointUrl.pathname = `/:${tenant}${cockpitEndpointUrl.pathname}`;
|
|
197
197
|
}
|