flowrix 1.0.1-beta.103 → 1.0.1-beta.106

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.
Files changed (56) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +2 -1
  3. package/dist/runtime/composables/Cart/useCartComponent.js +5 -4
  4. package/dist/runtime/composables/Checkout/PaymentMethods/useDirectDeposit.js +8 -0
  5. package/dist/runtime/composables/Checkout/PaymentMethods/useEway.js +8 -0
  6. package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.js +8 -0
  7. package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.js +8 -0
  8. package/dist/runtime/composables/Checkout/PaymentMethods/usePaypal.js +8 -0
  9. package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.js +8 -0
  10. package/dist/runtime/composables/Checkout/PaymentMethods/useZippay.js +8 -0
  11. package/dist/runtime/composables/Customer/useRegister.d.ts +2 -3
  12. package/dist/runtime/composables/Customer/useRegister.js +23 -23
  13. package/dist/runtime/composables/Customer/useUpdatePassword.js +56 -20
  14. package/dist/runtime/composables/useWebforms.d.ts +38 -9
  15. package/dist/runtime/composables/useWebforms.js +93 -60
  16. package/dist/runtime/server/api/albums.js +6 -1
  17. package/dist/runtime/server/api/banners.js +6 -1
  18. package/dist/runtime/server/api/brand/[...slug].js +4 -1
  19. package/dist/runtime/server/api/cart/related.d.ts +1 -1
  20. package/dist/runtime/server/api/cart/related.js +1 -0
  21. package/dist/runtime/server/api/cart/remove.d.ts +1 -1
  22. package/dist/runtime/server/api/cart/remove.js +1 -0
  23. package/dist/runtime/server/api/catalog/brands.js +7 -1
  24. package/dist/runtime/server/api/catalog/categories.js +7 -1
  25. package/dist/runtime/server/api/catalog/categoriesall.js +7 -1
  26. package/dist/runtime/server/api/catalog/featured.js +7 -1
  27. package/dist/runtime/server/api/catalog/posts.js +7 -1
  28. package/dist/runtime/server/api/catalog/samples.js +7 -1
  29. package/dist/runtime/server/api/catalog/search.js +7 -1
  30. package/dist/runtime/server/api/category/[...slug].js +7 -1
  31. package/dist/runtime/server/api/cmspost/[...slug].js +6 -1
  32. package/dist/runtime/server/api/cmspost/all.js +7 -1
  33. package/dist/runtime/server/api/company/profile.js +6 -1
  34. package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +6 -1
  35. package/dist/runtime/server/api/contact-center/webforms/create.js +6 -2
  36. package/dist/runtime/server/api/countries.js +6 -1
  37. package/dist/runtime/server/api/featured.js +7 -1
  38. package/dist/runtime/server/api/location.js +6 -2
  39. package/dist/runtime/server/api/nav/[id]/links.js +6 -1
  40. package/dist/runtime/server/api/page/[...slug].js +6 -1
  41. package/dist/runtime/server/api/product/[...slug].js +8 -4
  42. package/dist/runtime/server/api/quickview/[slug].js +6 -2
  43. package/dist/runtime/server/api/reviews.js +6 -1
  44. package/dist/runtime/server/api/samples.js +7 -1
  45. package/dist/runtime/server/api/search.js +7 -1
  46. package/dist/runtime/server/api/service/[slug].js +6 -1
  47. package/dist/runtime/server/api/service/availability.js +6 -2
  48. package/dist/runtime/server/api/service/getall.js +6 -1
  49. package/dist/runtime/server/api/shop.js +7 -1
  50. package/dist/runtime/server/api/subscribe.js +6 -2
  51. package/dist/runtime/server/api/v2/[...slug].get.js +6 -1
  52. package/dist/runtime/server/api/webform.js +6 -1
  53. package/dist/runtime/stores/auth.js +16 -21
  54. package/dist/runtime/stores/webforms.d.ts +24 -9
  55. package/dist/runtime/stores/webforms.js +105 -5
  56. package/package.json +1 -1
@@ -1,75 +1,108 @@
1
- import { computed } from "vue";
1
+ import { ref, computed } from "vue";
2
2
  import { useWebformsStore } from "../stores/webforms.js";
3
- import { useApi } from "../utils/api.js";
4
- function formatErrorMessage(message) {
5
- if (!message) return "An error occurred";
6
- if (typeof message === "string") {
7
- return message;
8
- }
9
- const errorMessages = [];
10
- for (const [field, errors] of Object.entries(message)) {
11
- if (Array.isArray(errors)) {
12
- errorMessages.push(...errors);
13
- } else {
14
- errorMessages.push(String(errors));
15
- }
16
- }
17
- return errorMessages.join(", ");
18
- }
19
3
  export function useWebforms() {
20
- const store = useWebformsStore();
21
- const { get, post } = useApi();
22
- async function fetchWebform(id) {
23
- store.setLoading(true);
24
- store.setError(null);
4
+ const webformsStore = useWebformsStore();
5
+ const showSuccessModal = ref(false);
6
+ const currentFormData = ref(null);
7
+ const recaptchaToken = ref("");
8
+ const formLoading = ref(false);
9
+ const webform = computed(() => webformsStore.webform);
10
+ const webFormReturn = computed(() => webformsStore.webFormReturn);
11
+ const loading = computed(() => webformsStore.loading);
12
+ const error = computed(() => webformsStore.error);
13
+ const clearMessages = () => {
14
+ webformsStore.clearWebFormReturn();
15
+ webformsStore.clearError();
16
+ };
17
+ const fetchWebform = async (id) => {
18
+ clearMessages();
19
+ formLoading.value = true;
25
20
  try {
26
- const response = await get(`contact-center/webforms/${id}/details`);
27
- if (response.status === "Success" && response.data) {
28
- store.setWebform(response.data);
29
- return response;
30
- } else {
31
- const errorMessage = formatErrorMessage(response.message);
32
- store.setError(errorMessage);
33
- throw new Error(errorMessage);
34
- }
35
- } catch (error) {
36
- console.error("Fetch webform error:", error);
37
- const errorMessage = error.data ? formatErrorMessage(error.data.message) : error.message || "Failed to fetch webform";
38
- store.setError(errorMessage);
39
- throw new Error(errorMessage);
21
+ const result = await webformsStore.fetchWebform(id);
22
+ return result;
40
23
  } finally {
41
- store.setLoading(false);
24
+ formLoading.value = false;
42
25
  }
43
- }
44
- async function submitInquiry(formData, recaptchaToken = "") {
45
- store.setLoading(true);
46
- store.setError(null);
26
+ };
27
+ const initFormSubmission = (formData) => {
28
+ clearMessages();
29
+ currentFormData.value = formData;
30
+ showSuccessModal.value = false;
31
+ };
32
+ const submitInquiry = async (formData) => {
33
+ formLoading.value = true;
34
+ clearMessages();
47
35
  try {
48
- const data = { ...formData, recaptcha: recaptchaToken };
49
- const response = await post("/contact-center/webforms/create", data);
36
+ const submissionData = {
37
+ ...formData,
38
+ recaptcha: recaptchaToken.value || formData.recaptcha
39
+ };
40
+ const response = await webformsStore.submitInquiry(submissionData);
50
41
  if (response.status === "Success") {
51
- store.setWebFormReturn(response);
52
- return response;
53
- } else {
54
- const errorMessage = formatErrorMessage(response.message);
55
- store.setError(errorMessage);
56
- throw new Error(errorMessage);
42
+ showSuccessModal.value = true;
43
+ currentFormData.value = null;
44
+ recaptchaToken.value = "";
57
45
  }
58
- } catch (error) {
59
- console.error("Submit inquiry error:", error);
60
- const errorMessage = error.data ? formatErrorMessage(error.data.message) : error.message || "Failed to submit inquiry";
61
- store.setError(errorMessage);
62
- throw new Error(errorMessage);
46
+ return response;
47
+ } catch (error2) {
48
+ console.error("Submit inquiry error:", error2);
49
+ return {
50
+ status: "Error",
51
+ message: error2.message || "Submission failed",
52
+ data: null
53
+ };
63
54
  } finally {
64
- store.setLoading(false);
55
+ formLoading.value = false;
65
56
  }
66
- }
57
+ };
58
+ const setRecaptchaToken = (token) => {
59
+ recaptchaToken.value = token;
60
+ };
61
+ const closeSuccessModal = () => {
62
+ showSuccessModal.value = false;
63
+ clearMessages();
64
+ };
65
+ const resetForm = () => {
66
+ currentFormData.value = null;
67
+ recaptchaToken.value = "";
68
+ clearMessages();
69
+ showSuccessModal.value = false;
70
+ };
71
+ const autoClearMessages = () => {
72
+ if (webFormReturn.value?.status !== void 0 || error.value) {
73
+ setTimeout(() => {
74
+ clearMessages();
75
+ }, 5e3);
76
+ }
77
+ };
78
+ const isFormValid = (formData) => {
79
+ if (!webform.value) return false;
80
+ const requiredFields = webform.value.fields.filter((field) => field.required);
81
+ return requiredFields.every((field) => {
82
+ const value = formData[field.name];
83
+ return value !== void 0 && value !== null && value !== "";
84
+ });
85
+ };
67
86
  return {
87
+ // State
88
+ showSuccessModal,
89
+ currentFormData,
90
+ recaptchaToken,
91
+ formLoading,
92
+ // Computed
93
+ webform,
94
+ webFormReturn,
95
+ loading,
96
+ error,
97
+ // Methods
98
+ clearMessages,
68
99
  fetchWebform,
100
+ initFormSubmission,
69
101
  submitInquiry,
70
- webform: computed(() => store.webform),
71
- webFormReturn: computed(() => store.webFormReturn),
72
- loading: computed(() => store.loading),
73
- error: computed(() => store.error)
102
+ setRecaptchaToken,
103
+ closeSuccessModal,
104
+ resetForm,
105
+ autoClearMessages,
106
+ isFormValid
74
107
  };
75
108
  }
@@ -28,7 +28,12 @@ export default defineEventHandler(async (event) => {
28
28
  ...config,
29
29
  cookies: rawCookies
30
30
  };
31
- const albums = await flowrixApi.get(`albums`, apiConfig);
31
+ const options = {
32
+ headers: {
33
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
34
+ }
35
+ };
36
+ const albums = await flowrixApi.get(`albums`, apiConfig, options);
32
37
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
33
38
  await ensureCacheDir();
34
39
  await writeFile(filePath, JSON.stringify(albums, null, 2), "utf-8");
@@ -28,7 +28,12 @@ export default defineEventHandler(async (event) => {
28
28
  ...config,
29
29
  cookies: rawCookies
30
30
  };
31
- const banners = await flowrixApi.get(`banners`, apiConfig);
31
+ const options = {
32
+ headers: {
33
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
34
+ }
35
+ };
36
+ const banners = await flowrixApi.get(`banners`, apiConfig, options);
32
37
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
33
38
  await ensureCacheDir();
34
39
  await writeFile(filePath, JSON.stringify(banners, null, 2), "utf-8");
@@ -39,7 +39,10 @@ export default defineEventHandler(async (event) => {
39
39
  query = {
40
40
  ...query
41
41
  };
42
- const brand = await flowrixApi.get(`brands/${slug}`, apiConfig, { query });
42
+ const headers = {
43
+ "x-api-secret": apiConfig?.FLOWRIX_API_KEY || ""
44
+ };
45
+ const brand = await flowrixApi.get(`brands/${slug}`, apiConfig, { query, headers });
43
46
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
44
47
  await ensureCacheDir();
45
48
  await writeFile(filePath, JSON.stringify(brand, null, 2), "utf-8");
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
2
2
  export default _default;
@@ -1,5 +1,6 @@
1
1
  import { useRuntimeConfig } from "#imports";
2
2
  import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
3
+ import { flowrixApi } from "../../../middleware/flowrix.js";
3
4
  export default defineEventHandler(async (event) => {
4
5
  const slug = getRouterParam(event, "slug");
5
6
  const body = await readBody(event);
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
2
2
  export default _default;
@@ -1,5 +1,6 @@
1
1
  import { useRuntimeConfig } from "#imports";
2
2
  import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
3
+ import { flowrixApi } from "../../../middleware/flowrix.js";
3
4
  export default defineEventHandler(async (event) => {
4
5
  const slug = getRouterParam(event, "slug");
5
6
  const body = await readBody(event);
@@ -33,7 +33,13 @@ export default defineEventHandler(async (event) => {
33
33
  query = {
34
34
  ...query
35
35
  };
36
- const brands = await flowrixApi.get(`brands`, apiConfig, { query });
36
+ const options = {
37
+ headers: {
38
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
39
+ },
40
+ query
41
+ };
42
+ const brands = await flowrixApi.get(`brands`, apiConfig, options);
37
43
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
44
  await ensureCacheDir();
39
45
  await writeFile(filePath, JSON.stringify(brands, null, 2), "utf-8");
@@ -33,7 +33,13 @@ export default defineEventHandler(async (event) => {
33
33
  query = {
34
34
  ...query
35
35
  };
36
- const categories = await flowrixApi.get(`categories`, apiConfig, { query });
36
+ const options = {
37
+ headers: {
38
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
39
+ },
40
+ query
41
+ };
42
+ const categories = await flowrixApi.get(`categories`, apiConfig, options);
37
43
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
44
  await ensureCacheDir();
39
45
  await writeFile(filePath, JSON.stringify(categories, null, 2), "utf-8");
@@ -33,7 +33,13 @@ export default defineEventHandler(async (event) => {
33
33
  query = {
34
34
  ...query
35
35
  };
36
- const categories = await flowrixApi.get(`categories/all`, apiConfig, { query });
36
+ const options = {
37
+ headers: {
38
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
39
+ },
40
+ query
41
+ };
42
+ const categories = await flowrixApi.get(`categories/all`, apiConfig, options);
37
43
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
44
  await ensureCacheDir();
39
45
  await writeFile(filePath, JSON.stringify(categories, null, 2), "utf-8");
@@ -33,7 +33,13 @@ export default defineEventHandler(async (event) => {
33
33
  query = {
34
34
  ...query
35
35
  };
36
- const featured = await flowrixApi.get(`products/featured`, apiConfig, { query });
36
+ const options = {
37
+ headers: {
38
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
39
+ },
40
+ query
41
+ };
42
+ const featured = await flowrixApi.get(`products/featured`, apiConfig, options);
37
43
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
44
  await ensureCacheDir();
39
45
  await writeFile(filePath, JSON.stringify(featured, null, 2), "utf-8");
@@ -33,7 +33,13 @@ export default defineEventHandler(async (event) => {
33
33
  query = {
34
34
  ...query
35
35
  };
36
- const posts = await flowrixApi.post(`posts`, apiConfig, { query });
36
+ const options = {
37
+ headers: {
38
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
39
+ },
40
+ query
41
+ };
42
+ const posts = await flowrixApi.post(`posts`, apiConfig, options);
37
43
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
44
  await ensureCacheDir();
39
45
  await writeFile(filePath, JSON.stringify(posts, null, 2), "utf-8");
@@ -34,7 +34,13 @@ export default defineEventHandler(async (event) => {
34
34
  query = {
35
35
  ...query
36
36
  };
37
- const samples = await flowrixApi.get(`samples`, apiConfig, { query });
37
+ const options = {
38
+ headers: {
39
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
40
+ },
41
+ query
42
+ };
43
+ const samples = await flowrixApi.get(`samples`, apiConfig, options);
38
44
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
39
45
  await ensureCacheDir();
40
46
  await writeFile(filePath, JSON.stringify(samples, null, 2), "utf-8");
@@ -34,7 +34,13 @@ export default defineEventHandler(async (event) => {
34
34
  query = {
35
35
  ...query
36
36
  };
37
- const search = await flowrixApi.get(`search`, apiConfig, { query });
37
+ const options = {
38
+ headers: {
39
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
40
+ },
41
+ query
42
+ };
43
+ const search = await flowrixApi.get(`search`, apiConfig, options);
38
44
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
39
45
  await ensureCacheDir();
40
46
  await writeFile(filePath, JSON.stringify(search, null, 2), "utf-8");
@@ -41,7 +41,13 @@ export default defineEventHandler(async (event) => {
41
41
  ...query,
42
42
  "scope[withchildren]": "true"
43
43
  };
44
- const category = await flowrixApi.get(`categories/${slug}`, apiConfig, { query });
44
+ const options = {
45
+ headers: {
46
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
47
+ },
48
+ query
49
+ };
50
+ const category = await flowrixApi.get(`categories/${slug}`, apiConfig, options);
45
51
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
46
52
  await ensureCacheDir();
47
53
  await writeFile(filePath, JSON.stringify(category, null, 2), "utf-8");
@@ -36,7 +36,12 @@ export default defineEventHandler(async (event) => {
36
36
  ...config,
37
37
  cookies: rawCookies
38
38
  };
39
- const blog = await flowrixApi.get(`post/${slug}`, apiConfig, {});
39
+ const options = {
40
+ headers: {
41
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
42
+ }
43
+ };
44
+ const blog = await flowrixApi.get(`post/${slug}`, apiConfig, options);
40
45
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
41
46
  await ensureCacheDir();
42
47
  await writeFile(filePath, JSON.stringify(blog, null, 2), "utf-8");
@@ -33,7 +33,13 @@ export default defineEventHandler(async (event) => {
33
33
  query = {
34
34
  ...query
35
35
  };
36
- const posts = await flowrixApi.post(`posts`, apiConfig, { query });
36
+ const options = {
37
+ headers: {
38
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
39
+ },
40
+ query
41
+ };
42
+ const posts = await flowrixApi.post(`posts`, apiConfig, options);
37
43
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
44
  await ensureCacheDir();
39
45
  await writeFile(filePath, JSON.stringify(posts, null, 2), "utf-8");
@@ -9,7 +9,12 @@ export default defineEventHandler(async (event) => {
9
9
  ...config,
10
10
  cookies: rawCookies
11
11
  };
12
- const companyProfile = await flowrixApi.get(`company/profile`, apiConfig);
12
+ const options = {
13
+ headers: {
14
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
15
+ }
16
+ };
17
+ const companyProfile = await flowrixApi.get(`company/profile`, apiConfig, options);
13
18
  return companyProfile;
14
19
  } catch (error) {
15
20
  setResponseStatus(event, 500);
@@ -36,7 +36,12 @@ export default defineEventHandler(async (event) => {
36
36
  ...config,
37
37
  cookies: rawCookies
38
38
  };
39
- const webfrom = await flowrixApi.get(`contact-center/webforms/${slug}/details`, apiConfig, {});
39
+ const options = {
40
+ headers: {
41
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
42
+ }
43
+ };
44
+ const webfrom = await flowrixApi.get(`contact-center/webforms/${slug}/details`, apiConfig, options);
40
45
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
41
46
  await ensureCacheDir();
42
47
  await writeFile(filePath, JSON.stringify(webfrom, null, 2), "utf-8");
@@ -9,8 +9,12 @@ export default defineEventHandler(async (event) => {
9
9
  ...config,
10
10
  cookies: rawCookies
11
11
  };
12
- const webform = await flowrixApi.post(`posts`, apiConfig, {
12
+ const options = {
13
+ headers: {
14
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
15
+ },
13
16
  body
14
- });
17
+ };
18
+ const webform = await flowrixApi.post(`posts`, apiConfig, options);
15
19
  return webform;
16
20
  });
@@ -26,7 +26,12 @@ export default defineEventHandler(async (event) => {
26
26
  ...config,
27
27
  cookies: rawCookies
28
28
  };
29
- const countries = await flowrixApi.get(`countries`, apiConfig);
29
+ const options = {
30
+ headers: {
31
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
32
+ }
33
+ };
34
+ const countries = await flowrixApi.get(`countries`, apiConfig, options);
30
35
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
31
36
  await ensureCacheDir();
32
37
  await writeFile(filePath, JSON.stringify(countries, null, 2), "utf-8");
@@ -33,7 +33,13 @@ export default defineEventHandler(async (event) => {
33
33
  query = {
34
34
  ...query
35
35
  };
36
- const featured = await flowrixApi.get(`products/featured`, apiConfig, { query });
36
+ const options = {
37
+ headers: {
38
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
39
+ },
40
+ query
41
+ };
42
+ const featured = await flowrixApi.get(`products/featured`, apiConfig, options);
37
43
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
44
  await ensureCacheDir();
39
45
  await writeFile(filePath, JSON.stringify(featured, null, 2), "utf-8");
@@ -10,9 +10,13 @@ export default defineEventHandler(async (event) => {
10
10
  ...config,
11
11
  cookies: rawCookies
12
12
  };
13
- const location = await flowrixApi.post(`ip/location`, apiConfig, {
13
+ const options = {
14
+ headers: {
15
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
16
+ },
14
17
  body: JSON.stringify(body)
15
- });
18
+ };
19
+ const location = await flowrixApi.post(`ip/location`, apiConfig, options);
16
20
  return location;
17
21
  } catch (error) {
18
22
  setResponseStatus(event, 500);
@@ -37,7 +37,12 @@ export default defineEventHandler(async (event) => {
37
37
  ...config,
38
38
  cookies: rawCookies
39
39
  };
40
- const menu = await flowrixApi.get(`nav/${slug}/links`, apiConfig, {});
40
+ const options = {
41
+ headers: {
42
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
43
+ }
44
+ };
45
+ const menu = await flowrixApi.get(`nav/${slug}/links`, apiConfig, options);
41
46
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
42
47
  await ensureCacheDir();
43
48
  await writeFile(filePath, JSON.stringify(menu, null, 2), "utf-8");
@@ -36,7 +36,12 @@ export default defineEventHandler(async (event) => {
36
36
  ...config,
37
37
  cookies: rawCookies
38
38
  };
39
- const page = await flowrixApi.get(`page/${slug}`, apiConfig, {});
39
+ const options = {
40
+ headers: {
41
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
42
+ }
43
+ };
44
+ const page = await flowrixApi.get(`page/${slug}`, apiConfig, options);
40
45
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
41
46
  await ensureCacheDir();
42
47
  await writeFile(filePath, JSON.stringify(page, null, 2), "utf-8");
@@ -39,10 +39,14 @@ export default defineEventHandler(async (event) => {
39
39
  query = {
40
40
  ...query
41
41
  };
42
- const product = await flowrixApi.post(`product/${slug}`, apiConfig, {
43
- body: JSON.stringify(body),
44
- query
45
- });
42
+ const options = {
43
+ headers: {
44
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
45
+ },
46
+ query,
47
+ body: JSON.stringify(body)
48
+ };
49
+ const product = await flowrixApi.post(`product/${slug}`, apiConfig, options);
46
50
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
47
51
  await ensureCacheDir();
48
52
  await writeFile(filePath, JSON.stringify(product, null, 2), "utf-8");
@@ -10,8 +10,12 @@ export default defineEventHandler(async (event) => {
10
10
  ...config,
11
11
  cookies: rawCookies
12
12
  };
13
- const quickview = await flowrixApi.post(`quickview/${slug}`, apiConfig, {
13
+ const options = {
14
+ headers: {
15
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
16
+ },
14
17
  body: JSON.stringify(body)
15
- });
18
+ };
19
+ const quickview = await flowrixApi.post(`quickview/${slug}`, apiConfig, options);
16
20
  return quickview;
17
21
  });
@@ -9,7 +9,12 @@ export default defineEventHandler(async (event) => {
9
9
  ...config,
10
10
  cookies: rawCookies
11
11
  };
12
- const reviews = await flowrixApi.get(`reviews`, apiConfig, {});
12
+ const options = {
13
+ headers: {
14
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
15
+ }
16
+ };
17
+ const reviews = await flowrixApi.get(`reviews`, apiConfig, options);
13
18
  return reviews;
14
19
  } catch (error) {
15
20
  setResponseStatus(event, 500);
@@ -34,7 +34,13 @@ export default defineEventHandler(async (event) => {
34
34
  query = {
35
35
  ...query
36
36
  };
37
- const samples = await flowrixApi.get(`samples`, apiConfig, { query });
37
+ const options = {
38
+ headers: {
39
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
40
+ },
41
+ query
42
+ };
43
+ const samples = await flowrixApi.get(`samples`, apiConfig, options);
38
44
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
39
45
  await ensureCacheDir();
40
46
  await writeFile(filePath, JSON.stringify(samples, null, 2), "utf-8");
@@ -34,7 +34,13 @@ export default defineEventHandler(async (event) => {
34
34
  query = {
35
35
  ...query
36
36
  };
37
- const search = await flowrixApi.get(`search`, apiConfig, { query });
37
+ const options = {
38
+ headers: {
39
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
40
+ },
41
+ query
42
+ };
43
+ const search = await flowrixApi.get(`search`, apiConfig, options);
38
44
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
39
45
  await ensureCacheDir();
40
46
  await writeFile(filePath, JSON.stringify(search, null, 2), "utf-8");
@@ -39,7 +39,12 @@ export default defineEventHandler(async (event) => {
39
39
  ...config,
40
40
  cookies: rawCookies
41
41
  };
42
- const service = await flowrixApi.get(`services/${slug}`, apiConfig, {});
42
+ const options = {
43
+ headers: {
44
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
45
+ }
46
+ };
47
+ const service = await flowrixApi.get(`services/${slug}`, apiConfig, options);
43
48
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
44
49
  await ensureCacheDir();
45
50
  await writeFile(filePath, JSON.stringify(service, null, 2), "utf-8");
@@ -10,9 +10,13 @@ export default defineEventHandler(async (event) => {
10
10
  ...config,
11
11
  cookies: rawCookies
12
12
  };
13
- const response = await flowrixApi.post(`services/availability`, apiConfig, {
13
+ const options = {
14
+ headers: {
15
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
16
+ },
14
17
  body: JSON.stringify(body)
15
- });
18
+ };
19
+ const response = await flowrixApi.post(`services/availability`, apiConfig, options);
16
20
  return response;
17
21
  } catch (error) {
18
22
  return {
@@ -39,7 +39,12 @@ export default defineEventHandler(async (event) => {
39
39
  ...config,
40
40
  cookies: rawCookies
41
41
  };
42
- const service = await flowrixApi.get(`services`, apiConfig, {});
42
+ const options = {
43
+ headers: {
44
+ "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
45
+ }
46
+ };
47
+ const service = await flowrixApi.get(`services`, apiConfig, options);
43
48
  if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
44
49
  await ensureCacheDir();
45
50
  await writeFile(filePath, JSON.stringify(service, null, 2), "utf-8");