flowrix 1.0.1-beta.10 → 1.0.1-beta.101

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 (239) hide show
  1. package/dist/module.d.mts +1 -6
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +104 -29
  4. package/dist/runtime/composables/Blog/useBlogIndex.d.ts +2 -5
  5. package/dist/runtime/composables/Brand/brand.js +2 -0
  6. package/dist/runtime/composables/Cart/useCart.d.ts +40 -0
  7. package/dist/runtime/composables/Cart/useCart.js +10 -0
  8. package/dist/runtime/composables/Cart/useCartDetail.d.ts +15 -5
  9. package/dist/runtime/composables/Cart/useCartDetail.js +3 -0
  10. package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.d.ts +40 -1
  11. package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.js +2 -2
  12. package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.d.ts +40 -1
  13. package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.js +2 -2
  14. package/dist/runtime/composables/Checkout/PaymentMethods/usePaymentMethods.js +3 -14
  15. package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.d.ts +2 -2
  16. package/dist/runtime/composables/Checkout/useCheckout.d.ts +84 -73
  17. package/dist/runtime/composables/Checkout/useCheckout.js +81 -34
  18. package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.d.ts +43 -0
  19. package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.js +84 -0
  20. package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.d.ts +55 -0
  21. package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.js +196 -0
  22. package/dist/runtime/composables/Checkout/useCreateAccount.d.ts +7 -7
  23. package/dist/runtime/composables/Checkout/useCreateAccount.js +3 -1
  24. package/dist/runtime/composables/Checkout/useDeliveryMethod.d.ts +2 -2
  25. package/dist/runtime/composables/Checkout/useDeliveryMethod.js +14 -7
  26. package/dist/runtime/composables/Customer/useBillingAddress.d.ts +112 -0
  27. package/dist/runtime/composables/Customer/useBillingAddress.js +93 -0
  28. package/dist/runtime/composables/Customer/useLogin.d.ts +9 -0
  29. package/dist/runtime/composables/Customer/useLogin.js +34 -0
  30. package/dist/runtime/composables/Customer/useOrders.d.ts +29 -0
  31. package/dist/runtime/composables/Customer/useOrders.js +56 -0
  32. package/dist/runtime/composables/Customer/usePasswordReset.d.ts +26 -0
  33. package/dist/runtime/composables/Customer/usePasswordReset.js +258 -0
  34. package/dist/runtime/composables/Customer/useProfile.d.ts +75 -0
  35. package/dist/runtime/composables/Customer/useProfile.js +106 -0
  36. package/dist/runtime/composables/Customer/useQuotations.d.ts +32 -0
  37. package/dist/runtime/composables/Customer/useQuotations.js +40 -0
  38. package/dist/runtime/composables/Customer/useRegister.d.ts +120 -11
  39. package/dist/runtime/composables/Customer/useRegister.js +311 -34
  40. package/dist/runtime/composables/Customer/useShippingAddress.d.ts +121 -0
  41. package/dist/runtime/composables/Customer/useShippingAddress.js +145 -0
  42. package/dist/runtime/composables/Customer/useUpdatePassword.d.ts +21 -0
  43. package/dist/runtime/composables/Customer/useUpdatePassword.js +94 -0
  44. package/dist/runtime/composables/Customer/useUserCards.d.ts +22 -0
  45. package/dist/runtime/composables/Customer/useUserCards.js +65 -0
  46. package/dist/runtime/composables/{useWishlists.d.ts → Customer/useWishlists.d.ts} +6 -19
  47. package/dist/runtime/composables/{useWishlists.js → Customer/useWishlists.js} +21 -29
  48. package/dist/runtime/composables/Extras/useCountry.d.ts +11 -6
  49. package/dist/runtime/composables/Extras/useCountry.js +5 -4
  50. package/dist/runtime/composables/Header/useHeader.d.ts +6 -20
  51. package/dist/runtime/composables/Header/useHeader.js +3 -2
  52. package/dist/runtime/composables/Product/CustomProduct/useCustomeScript.js +4 -5
  53. package/dist/runtime/composables/Product/CustomProduct/useSteps.d.ts +1 -1
  54. package/dist/runtime/composables/Product/useProductComponent.js +2 -0
  55. package/dist/runtime/composables/Product/useProductSlug.d.ts +8 -1
  56. package/dist/runtime/composables/Product/useQuickView.d.ts +8 -0
  57. package/dist/runtime/composables/Product/useQuickView.js +27 -0
  58. package/dist/runtime/composables/Product/useService.d.ts +1 -1
  59. package/dist/runtime/composables/Product/useService.js +0 -3
  60. package/dist/runtime/composables/SideBar/Filters/useFilters.d.ts +2 -2
  61. package/dist/runtime/composables/SideBar/Filters/useSorting.d.ts +2 -2
  62. package/dist/runtime/composables/index.d.ts +17 -12
  63. package/dist/runtime/composables/index.js +17 -12
  64. package/dist/runtime/composables/useAddresses.js +6 -6
  65. package/dist/runtime/composables/useApp.d.ts +1 -0
  66. package/dist/runtime/composables/useApp.js +24 -0
  67. package/dist/runtime/composables/useCards.js +2 -2
  68. package/dist/runtime/composables/useDataLayer.js +2 -1
  69. package/dist/runtime/composables/useDotDigital.d.ts +3 -0
  70. package/dist/runtime/composables/useDotDigital.js +122 -0
  71. package/dist/runtime/composables/useLocation.d.ts +2 -12
  72. package/dist/runtime/composables/useQuotationCheckout.d.ts +78 -0
  73. package/dist/runtime/composables/useQuotationCheckout.js +138 -0
  74. package/dist/runtime/middleware/flowrix.d.ts +5 -4
  75. package/dist/runtime/middleware/flowrix.js +40 -21
  76. package/dist/runtime/pages/flowrix-default.d.vue.ts +3 -0
  77. package/dist/runtime/pages/flowrix-default.vue +34 -0
  78. package/dist/runtime/pages/flowrix-default.vue.d.ts +3 -0
  79. package/dist/runtime/plugin.d.ts +1 -1
  80. package/dist/runtime/server/api/albums.d.ts +1 -0
  81. package/dist/runtime/server/api/albums.js +32 -9
  82. package/dist/runtime/server/api/auth/forgot.js +1 -2
  83. package/dist/runtime/server/api/auth/login.d.ts +7 -0
  84. package/dist/runtime/server/api/auth/login.js +4 -16
  85. package/dist/runtime/server/api/auth/logout.js +1 -2
  86. package/dist/runtime/server/api/auth/register.js +1 -2
  87. package/dist/runtime/server/api/auth/session.get.js +1 -3
  88. package/dist/runtime/server/api/auth/user/reset-password.js +1 -2
  89. package/dist/runtime/server/api/auth/user/session.js +1 -2
  90. package/dist/runtime/server/api/auth/user/verify-token.js +1 -2
  91. package/dist/runtime/server/api/banners.js +17 -17
  92. package/dist/runtime/server/api/brand/[...slug].js +52 -0
  93. package/dist/runtime/server/api/brand/index.d.ts +3 -0
  94. package/dist/runtime/server/api/brand/index.js +46 -0
  95. package/dist/runtime/server/api/cache/[...slug].delete.d.ts +5 -0
  96. package/dist/runtime/server/api/cache/[...slug].delete.js +37 -0
  97. package/dist/runtime/server/api/cache/clean.get.d.ts +10 -0
  98. package/dist/runtime/server/api/cache/clean.get.js +13 -0
  99. package/dist/runtime/server/api/cart/[slug]/add.d.ts +1 -1
  100. package/dist/runtime/server/api/cart/[slug]/add.js +11 -11
  101. package/dist/runtime/server/api/cart/[slug]/update.d.ts +1 -1
  102. package/dist/runtime/server/api/cart/[slug]/update.js +11 -11
  103. package/dist/runtime/server/api/{blog/blog.d.ts → cart/related.d.ts} +0 -1
  104. package/dist/runtime/server/api/cart/related.js +20 -0
  105. package/dist/runtime/server/api/cart/remove.js +1 -2
  106. package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +1 -1
  107. package/dist/runtime/server/api/cart/service/[slug]/add.js +12 -12
  108. package/dist/runtime/server/api/catalog/brands.d.ts +3 -0
  109. package/dist/runtime/server/api/catalog/brands.js +46 -0
  110. package/dist/runtime/server/api/catalog/categories.js +23 -20
  111. package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
  112. package/dist/runtime/server/api/catalog/categoriesall.js +46 -0
  113. package/dist/runtime/server/api/catalog/featured.js +23 -18
  114. package/dist/runtime/server/api/catalog/posts.d.ts +3 -0
  115. package/dist/runtime/server/api/catalog/posts.js +46 -0
  116. package/dist/runtime/server/api/catalog/samples.js +23 -20
  117. package/dist/runtime/server/api/catalog/search.js +23 -20
  118. package/dist/runtime/server/api/category/[...slug].js +24 -21
  119. package/dist/runtime/server/api/checkout/applyCoupon.d.ts +1 -1
  120. package/dist/runtime/server/api/checkout/applyCoupon.js +13 -13
  121. package/dist/runtime/server/api/checkout/configs.d.ts +1 -1
  122. package/dist/runtime/server/api/checkout/configs.js +11 -11
  123. package/dist/runtime/server/api/checkout/countries.d.ts +1 -1
  124. package/dist/runtime/server/api/checkout/countries.js +5 -9
  125. package/dist/runtime/server/api/checkout/paymentmethod.d.ts +1 -1
  126. package/dist/runtime/server/api/checkout/paymentmethod.js +16 -11
  127. package/dist/runtime/server/api/checkout/quotation/[slug].d.ts +2 -0
  128. package/dist/runtime/server/api/checkout/quotation/[slug].js +20 -0
  129. package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +2 -0
  130. package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +35 -0
  131. package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +2 -0
  132. package/dist/runtime/server/api/checkout/quotation/guest/customer.js +20 -0
  133. package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +2 -0
  134. package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +22 -0
  135. package/dist/runtime/server/api/checkvariables.d.ts +3 -0
  136. package/dist/runtime/server/api/checkvariables.js +35 -0
  137. package/dist/runtime/server/api/cmspost/[...slug].js +49 -0
  138. package/dist/runtime/server/api/cmspost/all.d.ts +3 -0
  139. package/dist/runtime/server/api/cmspost/all.js +46 -0
  140. package/dist/runtime/server/api/company/profile.d.ts +1 -1
  141. package/dist/runtime/server/api/company/profile.js +9 -9
  142. package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +1 -1
  143. package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +45 -15
  144. package/dist/runtime/server/api/contact-center/webforms/create.d.ts +1 -1
  145. package/dist/runtime/server/api/contact-center/webforms/create.js +10 -10
  146. package/dist/runtime/server/api/countries.d.ts +2 -0
  147. package/dist/runtime/server/api/countries.js +39 -0
  148. package/dist/runtime/server/api/customer/address/add.js +1 -2
  149. package/dist/runtime/server/api/customer/address/delete.js +2 -3
  150. package/dist/runtime/server/api/customer/address/setshipping.js +1 -2
  151. package/dist/runtime/server/api/customer/address/update.js +1 -2
  152. package/dist/runtime/server/api/customer/cards/delete.js +2 -3
  153. package/dist/runtime/server/api/customer/cards/get.js +2 -3
  154. package/dist/runtime/server/api/customer/change-password.js +2 -3
  155. package/dist/runtime/server/api/customer/checkout.js +1 -2
  156. package/dist/runtime/server/api/customer/orders.js +2 -3
  157. package/dist/runtime/server/api/customer/profile/update.js +1 -2
  158. package/dist/runtime/server/api/customer/quotations.js +2 -3
  159. package/dist/runtime/server/api/customer/search.js +1 -2
  160. package/dist/runtime/server/api/customer/tax-invoice.js +1 -2
  161. package/dist/runtime/server/api/customer/wishlist/add.js +1 -2
  162. package/dist/runtime/server/api/customer/wishlist/createWishList.js +1 -2
  163. package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +1 -2
  164. package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +1 -2
  165. package/dist/runtime/server/api/customer/wishlist/get.js +2 -3
  166. package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +1 -2
  167. package/dist/runtime/server/api/customer/wishlist/updateWishList.js +2 -3
  168. package/dist/runtime/server/api/featured.d.ts +3 -0
  169. package/dist/runtime/server/api/featured.js +46 -0
  170. package/dist/runtime/server/api/generate/robots.get.d.ts +2 -0
  171. package/dist/runtime/server/api/generate/robots.get.js +20 -0
  172. package/dist/runtime/server/api/generate/sitemap.get.d.ts +2 -0
  173. package/dist/runtime/server/api/generate/sitemap.get.js +32 -0
  174. package/dist/runtime/server/api/location.d.ts +1 -1
  175. package/dist/runtime/server/api/location.js +20 -12
  176. package/dist/runtime/server/api/nav/[id]/links.d.ts +1 -0
  177. package/dist/runtime/server/api/nav/[id]/links.js +43 -12
  178. package/dist/runtime/server/api/page/[...slug].js +49 -0
  179. package/dist/runtime/server/api/product/[...slug].js +25 -14
  180. package/dist/runtime/server/api/{v2/[...slug].d.ts → quickview/[slug].d.ts} +0 -1
  181. package/dist/runtime/server/api/quickview/[slug].js +17 -0
  182. package/dist/runtime/server/api/reviews.d.ts +2 -0
  183. package/dist/runtime/server/api/reviews.js +18 -0
  184. package/dist/runtime/server/api/samples.d.ts +3 -0
  185. package/dist/runtime/server/api/samples.js +47 -0
  186. package/dist/runtime/server/api/search.d.ts +3 -0
  187. package/dist/runtime/server/api/search.js +47 -0
  188. package/dist/runtime/server/api/service/[slug].js +19 -18
  189. package/dist/runtime/server/api/service/availability.d.ts +1 -1
  190. package/dist/runtime/server/api/service/availability.js +11 -13
  191. package/dist/runtime/server/api/service/getall.d.ts +3 -0
  192. package/dist/runtime/server/api/service/getall.js +52 -0
  193. package/dist/runtime/server/api/shop.d.ts +3 -0
  194. package/dist/runtime/server/api/shop.js +47 -0
  195. package/dist/runtime/server/api/subscribe.d.ts +1 -1
  196. package/dist/runtime/server/api/subscribe.js +19 -14
  197. package/dist/runtime/server/api/v2/[...slug].get.d.ts +2 -0
  198. package/dist/runtime/server/api/v2/[...slug].get.js +31 -0
  199. package/dist/runtime/server/api/webform.d.ts +3 -0
  200. package/dist/runtime/server/api/webform.js +49 -0
  201. package/dist/runtime/server/tsconfig.json +3 -3
  202. package/dist/runtime/stores/Cart.d.ts +12 -0
  203. package/dist/runtime/stores/Cart.js +56 -19
  204. package/dist/runtime/stores/Checkout.d.ts +9 -15
  205. package/dist/runtime/stores/Checkout.js +22 -40
  206. package/dist/runtime/stores/Search.d.ts +1 -1
  207. package/dist/runtime/stores/Services.js +2 -2
  208. package/dist/runtime/stores/auth.d.ts +8 -11
  209. package/dist/runtime/stores/auth.js +390 -8
  210. package/dist/runtime/stores/countries.d.ts +1 -3
  211. package/dist/runtime/stores/countries.js +4 -8
  212. package/dist/runtime/stores/product/slug.d.ts +1 -17
  213. package/dist/runtime/stores/wishlists.d.ts +114 -7
  214. package/dist/runtime/stores/wishlists.js +209 -15
  215. package/dist/runtime/utils/api.js +7 -13
  216. package/dist/runtime/utils/htmlCache.d.ts +2 -2
  217. package/dist/runtime/utils/htmlCache.js +23 -13
  218. package/dist/types.d.mts +6 -2
  219. package/package.json +30 -20
  220. package/dist/runtime/composables/Checkout/useBillingAddress.d.ts +0 -19
  221. package/dist/runtime/composables/Checkout/useBillingAddress.js +0 -82
  222. package/dist/runtime/composables/Checkout/useShippingAddress.d.ts +0 -9
  223. package/dist/runtime/composables/Checkout/useShippingAddress.js +0 -121
  224. package/dist/runtime/composables/useAuth.d.ts +0 -45
  225. package/dist/runtime/composables/useAuth.js +0 -180
  226. package/dist/runtime/composables/useCountries.d.ts +0 -12
  227. package/dist/runtime/composables/useCountries.js +0 -50
  228. package/dist/runtime/composables/useOrders.d.ts +0 -21
  229. package/dist/runtime/composables/useOrders.js +0 -82
  230. package/dist/runtime/composables/useQuotations.d.ts +0 -14
  231. package/dist/runtime/composables/useQuotations.js +0 -50
  232. package/dist/runtime/server/api/blog/[slug].js +0 -51
  233. package/dist/runtime/server/api/blog/blog.js +0 -17
  234. package/dist/runtime/server/api/brand/[slug].js +0 -58
  235. package/dist/runtime/server/api/page/[slug].js +0 -51
  236. package/dist/runtime/server/api/v2/[...slug].js +0 -9
  237. /package/dist/runtime/server/api/brand/{[slug].d.ts → [...slug].d.ts} +0 -0
  238. /package/dist/runtime/server/api/{blog/[slug].d.ts → cmspost/[...slug].d.ts} +0 -0
  239. /package/dist/runtime/server/api/page/{[slug].d.ts → [...slug].d.ts} +0 -0
@@ -0,0 +1,34 @@
1
+ <script setup>
2
+ const route = useRoute();
3
+ const { data, error } = await useAsyncData(
4
+ "flowrix-page",
5
+ () => $fetch(`/api/v2${route.fullPath}`, {
6
+ method: "GET"
7
+ })
8
+ );
9
+ if (error.value) {
10
+ throw createError({
11
+ statusCode: 404,
12
+ statusMessage: "Page Not Found"
13
+ });
14
+ }
15
+ const rediectpage = (async (data2) => {
16
+ return navigateTo(data2.target, { redirectCode: 302 });
17
+ });
18
+ if (data.value?.data?.type === "Redirect") {
19
+ }
20
+ const html = data.value?.data?.html || null;
21
+ </script>
22
+
23
+ <template>
24
+ {{ data }}
25
+ <div>
26
+ <!-- Render HTML page from API -->
27
+ <div v-if="html" v-html="html"></div>
28
+
29
+ <!-- Fallback for debugging -->
30
+ <div v-else>
31
+ <pre>{{ data }}</pre>
32
+ </div>
33
+ </div>
34
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
1
+ declare const _default: any;
2
2
  export default _default;
@@ -1,2 +1,3 @@
1
+ export declare const catelogCache: Map<any, any>;
1
2
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
2
3
  export default _default;
@@ -1,15 +1,38 @@
1
1
  import { defineEventHandler, setResponseStatus } from "h3";
2
- import { $fetch } from "ofetch";
2
+ import { writeFile, mkdir, readFile } from "fs/promises";
3
+ import { join } from "path";
4
+ import { useRuntimeConfig } from "#imports";
5
+ import { flowrixApi } from "../../middleware/flowrix.js";
6
+ const CACHE_DIR = join("/tmp", ".cache", "nitro", "extra");
7
+ export const catelogCache = /* @__PURE__ */ new Map();
8
+ async function ensureCacheDir() {
9
+ try {
10
+ await mkdir(CACHE_DIR, { recursive: true });
11
+ } catch (error) {
12
+ console.error("Error creating cache directory:", error);
13
+ }
14
+ }
3
15
  export default defineEventHandler(async (event) => {
16
+ const fileName = "albums";
17
+ const filePath = join(CACHE_DIR, `${fileName}.json`);
18
+ try {
19
+ const fileContent = await readFile(filePath, "utf-8");
20
+ const catelog = JSON.parse(fileContent);
21
+ return catelog;
22
+ } catch (error) {
23
+ }
4
24
  try {
5
- const albums = await $fetch(`${process.env.FLOWRIX_API_BASE}albums`, {
6
- method: "GET",
7
- headers: {
8
- "x-api-key": process.env.FLOWRIX_API_KEY,
9
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
10
- "Origin": process.env.FLOWRIX_API_ORIGIN
11
- }
12
- });
25
+ const config = useRuntimeConfig();
26
+ const rawCookies = event.req.headers.cookie || "";
27
+ const apiConfig = {
28
+ ...config,
29
+ cookies: rawCookies
30
+ };
31
+ const albums = await flowrixApi.get(`albums`, apiConfig);
32
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
33
+ await ensureCacheDir();
34
+ await writeFile(filePath, JSON.stringify(albums, null, 2), "utf-8");
35
+ }
13
36
  return albums;
14
37
  } catch (error) {
15
38
  setResponseStatus(event, 500);
@@ -6,8 +6,7 @@ export default defineEventHandler(async (event) => {
6
6
  const response = await fetch(`${process.env.FLOWRIX_API_BASE}verify-email/`, {
7
7
  method: "POST",
8
8
  headers: {
9
- "x-api-key": process.env.FLOWRIX_API_KEY,
10
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
9
+ "x-public-key": process.env.FLOWRIX_API_KEY,
11
10
  "Origin": process.env.FLOWRIX_API_ORIGIN,
12
11
  "Content-Type": "application/json"
13
12
  },
@@ -7,5 +7,12 @@ interface AuthUser {
7
7
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
8
8
  user: AuthUser;
9
9
  token: string;
10
+ success?: undefined;
11
+ error?: undefined;
12
+ } | {
13
+ success: boolean;
14
+ error: string;
15
+ user?: undefined;
16
+ token?: undefined;
10
17
  }>>;
11
18
  export default _default;
@@ -1,4 +1,4 @@
1
- import { defineEventHandler, readBody, createError } from "h3";
1
+ import { defineEventHandler, readBody, createError, setResponseStatus } from "h3";
2
2
  export default defineEventHandler(async (event) => {
3
3
  try {
4
4
  const body = await readBody(event);
@@ -9,16 +9,10 @@ export default defineEventHandler(async (event) => {
9
9
  statusMessage: "Email and password are required"
10
10
  });
11
11
  }
12
- const config = useRuntimeConfig();
13
- const apiBase = config.apiBase;
14
- const apiKey = config.apiKey;
15
- const apiSecret = config.apiSecret;
16
- const apiOrigin = config.apiOrigin;
17
12
  const response = await fetch(`${process.env.FLOWRIX_API_BASE}login/`, {
18
13
  method: "POST",
19
14
  headers: {
20
- "x-api-key": process.env.FLOWRIX_API_KEY,
21
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
15
+ "x-public-key": process.env.FLOWRIX_API_KEY,
22
16
  "Origin": process.env.FLOWRIX_API_ORIGIN,
23
17
  "Content-Type": "application/json"
24
18
  },
@@ -57,13 +51,7 @@ export default defineEventHandler(async (event) => {
57
51
  token
58
52
  };
59
53
  } catch (error) {
60
- console.error("Login error:", error);
61
- if (error.statusCode || error.status) {
62
- throw error;
63
- }
64
- throw createError({
65
- statusCode: 500,
66
- statusMessage: error.message || "Internal server error"
67
- });
54
+ setResponseStatus(event, 500);
55
+ return { success: false, error: error.message };
68
56
  }
69
57
  });
@@ -5,8 +5,7 @@ export default defineEventHandler(async (event) => {
5
5
  await $fetch(`${process.env.FLOWRIX_API_BASE}customer/logout`, {
6
6
  method: "POST",
7
7
  headers: {
8
- "x-api-key": process.env.FLOWRIX_API_KEY,
9
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
8
+ "x-public-key": process.env.FLOWRIX_API_KEY,
10
9
  "Origin": process.env.FLOWRIX_API_ORIGIN,
11
10
  "Authorization": `Bearer ${accessTok || ""}`
12
11
  }
@@ -6,8 +6,7 @@ export default defineEventHandler(async (event) => {
6
6
  const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/create`, {
7
7
  method: "POST",
8
8
  headers: {
9
- "x-api-key": process.env.FLOWRIX_API_KEY,
10
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
9
+ "x-public-key": process.env.FLOWRIX_API_KEY,
11
10
  "Origin": process.env.FLOWRIX_API_ORIGIN,
12
11
  "Content-Type": "application/json"
13
12
  },
@@ -12,13 +12,11 @@ export default defineEventHandler(async (event) => {
12
12
  const config = useRuntimeConfig();
13
13
  const apiBase = config.apiBase;
14
14
  const apiKey = config.apiKey;
15
- const apiSecret = config.apiSecret;
16
15
  const apiOrigin = config.apiOrigin;
17
16
  const response = await fetch(`${apiBase}user/session`, {
18
17
  method: "GET",
19
18
  headers: {
20
- "x-api-key": apiKey,
21
- "x-api-secret": apiSecret,
19
+ "x-public-key": apiKey,
22
20
  "Origin": apiOrigin || "",
23
21
  "Authorization": `Bearer ${token}`,
24
22
  "Content-Type": "application/json",
@@ -7,8 +7,7 @@ export default defineEventHandler(async (event) => {
7
7
  const response = await fetch(`${process.env.FLOWRIX_API_BASE}reset-password/`, {
8
8
  method: "POST",
9
9
  headers: {
10
- "x-api-key": process.env.FLOWRIX_API_KEY,
11
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
10
+ "x-public-key": process.env.FLOWRIX_API_KEY,
12
11
  "Origin": process.env.FLOWRIX_API_ORIGIN,
13
12
  "Content-Type": "application/json",
14
13
  // <--- CHANGE THIS
@@ -5,8 +5,7 @@ export default defineEventHandler(async (event) => {
5
5
  const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/profile`, {
6
6
  method: "GET",
7
7
  headers: {
8
- "x-api-key": process.env.FLOWRIX_API_KEY,
9
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
8
+ "x-public-key": process.env.FLOWRIX_API_KEY,
10
9
  "Origin": process.env.FLOWRIX_API_ORIGIN,
11
10
  Authorization: authHeader
12
11
  // Use the authorization header if available
@@ -6,8 +6,7 @@ export default defineEventHandler(async (event) => {
6
6
  const response = await fetch(`${process.env.FLOWRIX_API_BASE}verify-token/`, {
7
7
  method: "POST",
8
8
  headers: {
9
- "x-api-key": process.env.FLOWRIX_API_KEY,
10
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
9
+ "x-public-key": process.env.FLOWRIX_API_KEY,
11
10
  "Origin": process.env.FLOWRIX_API_ORIGIN,
12
11
  "Content-Type": "application/json"
13
12
  },
@@ -1,8 +1,9 @@
1
- import { defineEventHandler, createError } from "h3";
2
- import { $fetch } from "ofetch";
1
+ import { defineEventHandler, setResponseStatus } from "h3";
3
2
  import { writeFile, mkdir, readFile } from "fs/promises";
4
3
  import { join } from "path";
5
- const CACHE_DIR = join(process.cwd(), ".nuxt", "cache", "nitro", "extra");
4
+ import { useRuntimeConfig } from "#imports";
5
+ import { flowrixApi } from "../../middleware/flowrix.js";
6
+ const CACHE_DIR = join("/tmp", ".cache", "nitro", "extra");
6
7
  export const catelogCache = /* @__PURE__ */ new Map();
7
8
  async function ensureCacheDir() {
8
9
  try {
@@ -21,21 +22,20 @@ export default defineEventHandler(async (event) => {
21
22
  } catch (error) {
22
23
  }
23
24
  try {
24
- const banners = await $fetch(`${process.env.FLOWRIX_API_BASE}banners`, {
25
- headers: {
26
- "x-api-key": process.env.FLOWRIX_API_KEY,
27
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
28
- "Origin": process.env.FLOWRIX_API_ORIGIN
29
- }
30
- });
31
- await ensureCacheDir();
32
- await writeFile(filePath, JSON.stringify(banners, null, 2), "utf-8");
25
+ const config = useRuntimeConfig();
26
+ const rawCookies = event.req.headers.cookie || "";
27
+ const apiConfig = {
28
+ ...config,
29
+ cookies: rawCookies
30
+ };
31
+ const banners = await flowrixApi.get(`banners`, apiConfig);
32
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
33
+ await ensureCacheDir();
34
+ await writeFile(filePath, JSON.stringify(banners, null, 2), "utf-8");
35
+ }
33
36
  return banners;
34
37
  } catch (error) {
35
- throw createError({
36
- statusCode: 500,
37
- statusMessage: `Failed to fetch catelog for slug: ${slug}`,
38
- data: error.message
39
- });
38
+ setResponseStatus(event, 500);
39
+ return { success: false, error: error.message };
40
40
  }
41
41
  });
@@ -0,0 +1,52 @@
1
+ import { defineEventHandler, getQuery, createError, setResponseStatus } from "h3";
2
+ import { writeFile, mkdir, readFile } from "fs/promises";
3
+ import { join } from "path";
4
+ import { flowrixApi } from "../../../middleware/flowrix.js";
5
+ import { useRuntimeConfig } from "#imports";
6
+ const CACHE_DIR = join("/tmp", ".cache", "nitro", "brands");
7
+ export const brandCache = /* @__PURE__ */ new Map();
8
+ async function ensureCacheDir() {
9
+ try {
10
+ await mkdir(CACHE_DIR, { recursive: true });
11
+ } catch (error) {
12
+ console.error("Error creating cache directory:", error);
13
+ }
14
+ }
15
+ export default defineEventHandler(async (event) => {
16
+ const slug = event.context.params._;
17
+ let query = getQuery(event);
18
+ if (!slug) {
19
+ throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
20
+ }
21
+ if (!/^[a-zA-Z0-9-_]+$/.test(slug)) {
22
+ }
23
+ const cacheKey = `${slug}-${JSON.stringify(query)}`;
24
+ const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
25
+ const filePath = join(CACHE_DIR, `${fileName}.json`);
26
+ try {
27
+ const fileContent = await readFile(filePath, "utf-8");
28
+ const brand = JSON.parse(fileContent);
29
+ return brand;
30
+ } catch (error) {
31
+ }
32
+ try {
33
+ const config = useRuntimeConfig();
34
+ const rawCookies = event.req.headers.cookie || "";
35
+ const apiConfig = {
36
+ ...config,
37
+ cookies: rawCookies
38
+ };
39
+ query = {
40
+ ...query
41
+ };
42
+ const brand = await flowrixApi.get(`brands/${slug}`, apiConfig, { query });
43
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
44
+ await ensureCacheDir();
45
+ await writeFile(filePath, JSON.stringify(brand, null, 2), "utf-8");
46
+ }
47
+ return brand;
48
+ } catch (error) {
49
+ setResponseStatus(event, 500);
50
+ return { success: false, error: error.message };
51
+ }
52
+ });
@@ -0,0 +1,3 @@
1
+ export declare const catelogCache: Map<any, any>;
2
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
+ export default _default;
@@ -0,0 +1,46 @@
1
+ import { defineEventHandler, getQuery, getCookie, setResponseStatus } from "h3";
2
+ import { writeFile, mkdir, readFile } from "fs/promises";
3
+ import { join } from "path";
4
+ import { useRuntimeConfig } from "#imports";
5
+ import { flowrixApi } from "../../../middleware/flowrix.js";
6
+ const CACHE_DIR = join("/tmp", ".cache", "nitro", "catalog");
7
+ export const catelogCache = /* @__PURE__ */ new Map();
8
+ async function ensureCacheDir() {
9
+ try {
10
+ await mkdir(CACHE_DIR, { recursive: true });
11
+ } catch (error) {
12
+ console.error("Error creating cache directory:", error);
13
+ }
14
+ }
15
+ export default defineEventHandler(async (event) => {
16
+ let query = getQuery(event);
17
+ const customerType = getCookie(event, "customertype") || "";
18
+ const fileName = "brands";
19
+ const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
20
+ try {
21
+ const fileContent = await readFile(filePath, "utf-8");
22
+ const catelog = JSON.parse(fileContent);
23
+ return catelog;
24
+ } catch (error) {
25
+ }
26
+ try {
27
+ const config = useRuntimeConfig();
28
+ const rawCookies = event.req.headers.cookie || "";
29
+ const apiConfig = {
30
+ ...config,
31
+ cookies: rawCookies
32
+ };
33
+ query = {
34
+ ...query
35
+ };
36
+ const brands = await flowrixApi.get(`brands`, apiConfig, { query });
37
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
+ await ensureCacheDir();
39
+ await writeFile(filePath, JSON.stringify(brands, null, 2), "utf-8");
40
+ }
41
+ return brands;
42
+ } catch (error) {
43
+ setResponseStatus(event, 500);
44
+ return { success: false, error: error.message };
45
+ }
46
+ });
@@ -0,0 +1,5 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string[] | {
2
+ success: boolean;
3
+ error: string;
4
+ }>>;
5
+ export default _default;
@@ -0,0 +1,37 @@
1
+ import { defineEventHandler, getQuery, setResponseStatus } from "h3";
2
+ import { join } from "path";
3
+ import fs from "fs";
4
+ import path from "path";
5
+ const CACHE_DIR = join("/tmp", ".cache");
6
+ export default defineEventHandler(async (event) => {
7
+ const slug = event.context.params._;
8
+ try {
9
+ let deleteMatchingFiles = function(dir) {
10
+ const files = fs.readdirSync(dir);
11
+ for (const file of files) {
12
+ const filePath = path.join(dir, file);
13
+ const stat = fs.statSync(filePath);
14
+ if (stat.isDirectory()) {
15
+ deleteMatchingFiles(filePath);
16
+ } else if (file.startsWith(prefix)) {
17
+ fs.unlinkSync(filePath);
18
+ deletedFiles.push(filePath);
19
+ } else if (file.startsWith(`_${prefix}`)) {
20
+ fs.unlinkSync(filePath);
21
+ deletedFiles.push(filePath);
22
+ }
23
+ }
24
+ };
25
+ const query = getQuery(event);
26
+ const cacheKey = `${slug}-${JSON.stringify(query)}`;
27
+ const prefix = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
28
+ const deletedFiles = [];
29
+ if (fs.existsSync(CACHE_DIR)) {
30
+ deleteMatchingFiles(CACHE_DIR);
31
+ }
32
+ return deletedFiles;
33
+ } catch (error) {
34
+ setResponseStatus(event, 500);
35
+ return { success: false, error: error.message };
36
+ }
37
+ });
@@ -0,0 +1,10 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
2
+ success: boolean;
3
+ message: string;
4
+ error?: undefined;
5
+ } | {
6
+ success: boolean;
7
+ error: string;
8
+ message?: undefined;
9
+ }>>;
10
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { defineEventHandler, setResponseStatus } from "h3";
2
+ import { join } from "path";
3
+ import { rm } from "fs/promises";
4
+ const CACHE_DIR = join("/tmp", ".cache");
5
+ export default defineEventHandler(async (event) => {
6
+ try {
7
+ await rm(CACHE_DIR, { recursive: true, force: true });
8
+ return { success: true, message: "Cache deleted successfully" };
9
+ } catch (error) {
10
+ setResponseStatus(event, 500);
11
+ return { success: false, error: error.message };
12
+ }
13
+ });
@@ -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,19 +1,19 @@
1
+ import { useRuntimeConfig } from "#imports";
1
2
  import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
2
- import { $fetch } from "ofetch";
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);
6
7
  try {
7
- const productResponse = await $fetch(`${process.env.FLOWRIX_API_BASE}cart/${slug}/add`, {
8
- method: "POST",
9
- headers: {
10
- "x-api-key": process.env.FLOWRIX_API_KEY,
11
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
12
- "Origin": process.env.FLOWRIX_API_ORIGIN
13
- },
14
- body
15
- });
16
- return productResponse;
8
+ const config = useRuntimeConfig();
9
+ const response = await flowrixApi.post(
10
+ `cart/${slug}/add`,
11
+ config,
12
+ {
13
+ body
14
+ }
15
+ );
16
+ return response;
17
17
  } catch (error) {
18
18
  setResponseStatus(event, 500);
19
19
  return { success: false, error: error.message };
@@ -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,19 +1,19 @@
1
1
  import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
2
- import { $fetch } from "ofetch";
2
+ import { flowrixApi } from "../../../../middleware/flowrix.js";
3
+ import { useRuntimeConfig } from "#imports";
3
4
  export default defineEventHandler(async (event) => {
4
5
  const slug = getRouterParam(event, "slug");
5
6
  const body = await readBody(event);
6
7
  try {
7
- const productResponse = await $fetch(`${process.env.FLOWRIX_API_BASE}cart/${slug}/update`, {
8
- method: "POST",
9
- headers: {
10
- "x-api-key": process.env.FLOWRIX_API_KEY,
11
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
12
- "Origin": process.env.FLOWRIX_API_ORIGIN
13
- },
14
- body
15
- });
16
- return productResponse;
8
+ const config = useRuntimeConfig();
9
+ const response = await flowrixApi.post(
10
+ `cart/${slug}/update`,
11
+ config,
12
+ {
13
+ body
14
+ }
15
+ );
16
+ return response;
17
17
  } catch (error) {
18
18
  setResponseStatus(event, 500);
19
19
  return { success: false, error: error.message };
@@ -1,3 +1,2 @@
1
- export declare const Page: Map<any, any>;
2
1
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
2
  export default _default;
@@ -0,0 +1,20 @@
1
+ import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
2
+ import { $fetch } from "ofetch";
3
+ export default defineEventHandler(async (event) => {
4
+ const slug = getRouterParam(event, "slug");
5
+ const body = await readBody(event);
6
+ try {
7
+ const productResponse = await $fetch(`${process.env.FLOWRIX_API_BASE}cart/relatedproducts`, {
8
+ method: "POST",
9
+ headers: {
10
+ "x-public-key": process.env.FLOWRIX_API_KEY,
11
+ "Origin": process.env.FLOWRIX_API_ORIGIN
12
+ },
13
+ body
14
+ });
15
+ return productResponse;
16
+ } catch (error) {
17
+ setResponseStatus(event, 500);
18
+ return { success: false, error: error.message };
19
+ }
20
+ });
@@ -7,8 +7,7 @@ export default defineEventHandler(async (event) => {
7
7
  const productResponse = await $fetch(`${process.env.FLOWRIX_API_BASE}cart/remove`, {
8
8
  method: "POST",
9
9
  headers: {
10
- "x-api-key": process.env.FLOWRIX_API_KEY,
11
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
10
+ "x-public-key": process.env.FLOWRIX_API_KEY,
12
11
  "Origin": process.env.FLOWRIX_API_ORIGIN
13
12
  },
14
13
  body
@@ -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,16 +1,16 @@
1
- import { defineEventHandler } from "h3";
2
- import { $fetch } from "ofetch";
1
+ import { defineEventHandler, getRouterParam, readBody } from "h3";
2
+ import { flowrixApi } from "../../../../../middleware/flowrix.js";
3
+ import { useRuntimeConfig } from "#imports";
3
4
  export default defineEventHandler(async (event) => {
4
5
  const slug = getRouterParam(event, "slug");
5
6
  const body = await readBody(event);
6
- const services = await $fetch(`${process.env.FLOWRIX_API_BASE}cart/service/${slug}/add`, {
7
- method: "POST",
8
- headers: {
9
- "x-api-key": process.env.FLOWRIX_API_KEY,
10
- "x-api-secret": process.env.FLOWRIX_API_SECRET,
11
- "Origin": process.env.FLOWRIX_API_ORIGIN
12
- },
13
- body
14
- });
15
- return services;
7
+ const config = useRuntimeConfig();
8
+ const response = await flowrixApi.post(
9
+ `cart/service/${slug}/add`,
10
+ config,
11
+ {
12
+ body
13
+ }
14
+ );
15
+ return response;
16
16
  });
@@ -0,0 +1,3 @@
1
+ export declare const catelogCache: Map<any, any>;
2
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
+ export default _default;