flowrix 1.0.1-beta.155 → 1.0.1-beta.157

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 (226) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +23 -192
  3. package/dist/runtime/components/Types/page/index.d.vue.ts +5 -4
  4. package/dist/runtime/components/Types/page/index.vue +7 -11
  5. package/dist/runtime/components/Types/page/index.vue.d.ts +5 -4
  6. package/dist/runtime/composables/Blog/useBlogSingle.js +4 -5
  7. package/dist/runtime/composables/Category/useCategoryIndex.js +5 -5
  8. package/dist/runtime/composables/Checkout/useCheckout.d.ts +4 -0
  9. package/dist/runtime/composables/Checkout/useCheckout.js +15 -3
  10. package/dist/runtime/composables/Customer/useBillingAddress.d.ts +3 -0
  11. package/dist/runtime/composables/Customer/useBillingAddress.js +2 -0
  12. package/dist/runtime/composables/Customer/useShippingAddress.d.ts +3 -0
  13. package/dist/runtime/composables/Customer/useShippingAddress.js +2 -1
  14. package/dist/runtime/composables/Customer/useWishlists.d.ts +1 -1
  15. package/dist/runtime/composables/Product/CustomProduct/useCustomeScript.d.ts +4 -0
  16. package/dist/runtime/composables/Product/CustomProduct/useCustomeScript.js +5 -11
  17. package/dist/runtime/composables/Product/useProductCard.d.ts +90 -9
  18. package/dist/runtime/composables/Product/useProductCard.js +257 -55
  19. package/dist/runtime/composables/Product/useProductComponent.js +3 -10
  20. package/dist/runtime/composables/Product/useQuickView.d.ts +1 -1
  21. package/dist/runtime/composables/Product/useService.d.ts +1 -12
  22. package/dist/runtime/composables/Product/useService.js +2 -2
  23. package/dist/runtime/composables/index.d.ts +1 -1
  24. package/dist/runtime/composables/index.js +1 -1
  25. package/dist/runtime/composables/useAddresses.js +27 -6
  26. package/dist/runtime/composables/useApp.js +3 -4
  27. package/dist/runtime/composables/useCards.js +0 -1
  28. package/dist/runtime/composables/useClientApi.d.ts +8 -8
  29. package/dist/runtime/composables/useClientApi.js +74 -30
  30. package/dist/runtime/composables/useLocation.d.ts +3 -15
  31. package/dist/runtime/composables/useLocation.js +6 -27
  32. package/dist/runtime/composables/usePriceCalculation.d.ts +33 -0
  33. package/dist/runtime/composables/usePriceCalculation.js +107 -0
  34. package/dist/runtime/composables/useQuotationCheckout.d.ts +1 -1
  35. package/dist/runtime/middleware/flowrix.d.ts +5 -5
  36. package/dist/runtime/middleware/flowrix.js +2 -2
  37. package/dist/runtime/middleware/flowrixs3.d.ts +3 -0
  38. package/dist/runtime/middleware/flowrixs3.js +65 -0
  39. package/dist/runtime/pages/flowrix-default.vue +62 -15
  40. package/dist/runtime/plugins/full-reload.client.d.ts +2 -0
  41. package/dist/runtime/plugins/full-reload.client.js +28 -0
  42. package/dist/runtime/server/api/albums.d.ts +0 -1
  43. package/dist/runtime/server/api/albums.js +13 -40
  44. package/dist/runtime/server/api/auth/login.d.ts +0 -18
  45. package/dist/runtime/server/api/auth/login.js +0 -57
  46. package/dist/runtime/server/api/banners.d.ts +0 -1
  47. package/dist/runtime/server/api/banners.js +13 -40
  48. package/dist/runtime/server/api/brand/[...slug].d.ts +0 -1
  49. package/dist/runtime/server/api/brand/[...slug].js +14 -43
  50. package/dist/runtime/server/api/brand/index.d.ts +0 -1
  51. package/dist/runtime/server/api/brand/index.js +13 -39
  52. package/dist/runtime/server/api/cache/[...slug].delete.js +1 -2
  53. package/dist/runtime/server/api/cache/clean.get.js +1 -2
  54. package/dist/runtime/server/api/cart/[slug]/add.d.ts +0 -2
  55. package/dist/runtime/server/api/cart/[slug]/add.js +0 -21
  56. package/dist/runtime/server/api/cart/[slug]/update.d.ts +0 -2
  57. package/dist/runtime/server/api/cart/[slug]/update.js +0 -21
  58. package/dist/runtime/server/api/cart/related.d.ts +0 -2
  59. package/dist/runtime/server/api/cart/related.js +0 -34
  60. package/dist/runtime/server/api/cart/remove.d.ts +0 -2
  61. package/dist/runtime/server/api/cart/remove.js +0 -21
  62. package/dist/runtime/server/api/catalog/brands.d.ts +0 -1
  63. package/dist/runtime/server/api/catalog/brands.js +13 -45
  64. package/dist/runtime/server/api/catalog/categories.d.ts +0 -1
  65. package/dist/runtime/server/api/catalog/categories.js +13 -45
  66. package/dist/runtime/server/api/catalog/categoriesall.d.ts +0 -1
  67. package/dist/runtime/server/api/catalog/categoriesall.js +13 -45
  68. package/dist/runtime/server/api/catalog/featured.d.ts +0 -1
  69. package/dist/runtime/server/api/catalog/featured.js +13 -45
  70. package/dist/runtime/server/api/catalog/posts.d.ts +0 -1
  71. package/dist/runtime/server/api/catalog/posts.js +13 -45
  72. package/dist/runtime/server/api/catalog/samples.d.ts +0 -1
  73. package/dist/runtime/server/api/catalog/samples.js +13 -46
  74. package/dist/runtime/server/api/catalog/search.d.ts +0 -1
  75. package/dist/runtime/server/api/catalog/search.js +13 -46
  76. package/dist/runtime/server/api/category/[...slug].d.ts +1 -2
  77. package/dist/runtime/server/api/category/[...slug].js +34 -49
  78. package/dist/runtime/server/api/checkout/applyCoupon.d.ts +0 -2
  79. package/dist/runtime/server/api/checkout/applyCoupon.js +0 -20
  80. package/dist/runtime/server/api/checkout/configs.d.ts +0 -2
  81. package/dist/runtime/server/api/checkout/configs.js +0 -20
  82. package/dist/runtime/server/api/checkout/countries.d.ts +0 -2
  83. package/dist/runtime/server/api/checkout/countries.js +0 -13
  84. package/dist/runtime/server/api/checkout/paymentmethod.d.ts +0 -2
  85. package/dist/runtime/server/api/checkout/paymentmethod.js +0 -25
  86. package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +0 -2
  87. package/dist/runtime/server/api/checkout/quotation/guest/customer.js +0 -20
  88. package/dist/runtime/server/api/checkvariables.js +1 -2
  89. package/dist/runtime/server/api/cmspost/[...slug].d.ts +0 -1
  90. package/dist/runtime/server/api/cmspost/[...slug].js +14 -44
  91. package/dist/runtime/server/api/cmspost/all.js +1 -2
  92. package/dist/runtime/server/api/company/profile.d.ts +1 -1
  93. package/dist/runtime/server/api/company/profile.js +13 -17
  94. package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +0 -3
  95. package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +0 -54
  96. package/dist/runtime/server/api/countries.js +13 -38
  97. package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.d.ts +0 -2
  98. package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +0 -45
  99. package/dist/runtime/server/api/featured.d.ts +0 -3
  100. package/dist/runtime/server/api/featured.js +0 -52
  101. package/dist/runtime/server/api/generate/robots.get.js +0 -2
  102. package/dist/runtime/server/api/generate/sitemap.get.d.ts +1 -1
  103. package/dist/runtime/server/api/generate/sitemap.get.js +8 -12
  104. package/dist/runtime/server/api/global/[...slug].js +20 -0
  105. package/dist/runtime/server/api/location.d.ts +0 -2
  106. package/dist/runtime/server/api/location.js +0 -25
  107. package/dist/runtime/server/api/nav/[id]/links.d.ts +0 -1
  108. package/dist/runtime/server/api/nav/[id]/links.js +13 -43
  109. package/dist/runtime/server/api/page/[...slug].d.ts +0 -1
  110. package/dist/runtime/server/api/page/[...slug].js +14 -44
  111. package/dist/runtime/server/api/permalink/[...slug].get.js +31 -0
  112. package/dist/runtime/server/api/product/[...slug].d.ts +0 -1
  113. package/dist/runtime/server/api/product/[...slug].js +14 -49
  114. package/dist/runtime/server/api/quickview/[slug].d.ts +1 -1
  115. package/dist/runtime/server/api/quickview/[slug].js +15 -16
  116. package/dist/runtime/server/api/reviews.d.ts +1 -1
  117. package/dist/runtime/server/api/reviews.js +1 -2
  118. package/dist/runtime/server/api/reviews3.js +19 -0
  119. package/dist/runtime/server/api/samples.d.ts +0 -1
  120. package/dist/runtime/server/api/samples.js +13 -46
  121. package/dist/runtime/server/api/search.d.ts +0 -1
  122. package/dist/runtime/server/api/search.js +13 -46
  123. package/dist/runtime/server/api/service/[slug].d.ts +0 -1
  124. package/dist/runtime/server/api/service/[slug].js +13 -44
  125. package/dist/runtime/server/api/service/availability.d.ts +1 -1
  126. package/dist/runtime/server/api/service/getall.d.ts +0 -1
  127. package/dist/runtime/server/api/service/getall.js +13 -51
  128. package/dist/runtime/server/api/shop.d.ts +0 -1
  129. package/dist/runtime/server/api/shop.js +13 -46
  130. package/dist/runtime/server/api/subscribe.d.ts +0 -2
  131. package/dist/runtime/server/api/subscribe.js +0 -25
  132. package/dist/runtime/server/api/webform.d.ts +0 -3
  133. package/dist/runtime/server/api/webform.js +0 -54
  134. package/dist/runtime/server/middleware/powertools.d.ts +9 -0
  135. package/dist/runtime/server/middleware/powertools.js +30 -0
  136. package/dist/runtime/stores/Booking.js +23 -7
  137. package/dist/runtime/stores/Cart.js +18 -3
  138. package/dist/runtime/stores/Checkout.js +14 -3
  139. package/dist/runtime/stores/NavMenu.js +2 -4
  140. package/dist/runtime/stores/Search.js +9 -3
  141. package/dist/runtime/stores/auth.d.ts +28 -1
  142. package/dist/runtime/stores/auth.js +0 -5
  143. package/dist/runtime/stores/countries.js +1 -1
  144. package/dist/runtime/stores/index.d.ts +0 -1
  145. package/dist/runtime/stores/index.js +0 -1
  146. package/dist/runtime/stores/locations.d.ts +1 -5
  147. package/dist/runtime/stores/locations.js +8 -5
  148. package/dist/runtime/stores/product.js +9 -3
  149. package/dist/runtime/stores/promotions.d.ts +51 -0
  150. package/dist/runtime/stores/promotions.js +65 -0
  151. package/dist/runtime/stores/useCompanyProfile.js +5 -2
  152. package/dist/runtime/stores/wishlists.d.ts +1 -1
  153. package/dist/runtime/stores/wishlists.js +1 -1
  154. package/package.json +11 -3
  155. package/dist/runtime/composables/useLocations.d.ts +0 -12
  156. package/dist/runtime/composables/useLocations.js +0 -53
  157. package/dist/runtime/server/api/auth/forgot.d.ts +0 -5
  158. package/dist/runtime/server/api/auth/forgot.js +0 -43
  159. package/dist/runtime/server/api/auth/logout.d.ts +0 -5
  160. package/dist/runtime/server/api/auth/logout.js +0 -22
  161. package/dist/runtime/server/api/auth/register.js +0 -50
  162. package/dist/runtime/server/api/auth/session.get.js +0 -44
  163. package/dist/runtime/server/api/auth/user/reset-password.d.ts +0 -5
  164. package/dist/runtime/server/api/auth/user/reset-password.js +0 -39
  165. package/dist/runtime/server/api/auth/user/session.js +0 -42
  166. package/dist/runtime/server/api/auth/user/verify-token.d.ts +0 -6
  167. package/dist/runtime/server/api/auth/user/verify-token.js +0 -49
  168. package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +0 -2
  169. package/dist/runtime/server/api/cart/service/[slug]/add.js +0 -16
  170. package/dist/runtime/server/api/check-404.d.ts +0 -4
  171. package/dist/runtime/server/api/check-404.js +0 -8
  172. package/dist/runtime/server/api/checkout/quotation/[slug].d.ts +0 -2
  173. package/dist/runtime/server/api/checkout/quotation/[slug].js +0 -20
  174. package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +0 -2
  175. package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +0 -35
  176. package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +0 -2
  177. package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +0 -22
  178. package/dist/runtime/server/api/contact-center/webforms/create.d.ts +0 -2
  179. package/dist/runtime/server/api/contact-center/webforms/create.js +0 -20
  180. package/dist/runtime/server/api/customer/address/add.d.ts +0 -14
  181. package/dist/runtime/server/api/customer/address/add.js +0 -32
  182. package/dist/runtime/server/api/customer/address/delete.d.ts +0 -20
  183. package/dist/runtime/server/api/customer/address/delete.js +0 -36
  184. package/dist/runtime/server/api/customer/address/setshipping.d.ts +0 -20
  185. package/dist/runtime/server/api/customer/address/setshipping.js +0 -40
  186. package/dist/runtime/server/api/customer/address/update.d.ts +0 -20
  187. package/dist/runtime/server/api/customer/address/update.js +0 -41
  188. package/dist/runtime/server/api/customer/cards/delete.d.ts +0 -2
  189. package/dist/runtime/server/api/customer/cards/delete.js +0 -22
  190. package/dist/runtime/server/api/customer/cards/get.d.ts +0 -2
  191. package/dist/runtime/server/api/customer/cards/get.js +0 -16
  192. package/dist/runtime/server/api/customer/change-password.d.ts +0 -14
  193. package/dist/runtime/server/api/customer/change-password.js +0 -33
  194. package/dist/runtime/server/api/customer/checkout.d.ts +0 -2
  195. package/dist/runtime/server/api/customer/checkout.js +0 -19
  196. package/dist/runtime/server/api/customer/orders.d.ts +0 -2
  197. package/dist/runtime/server/api/customer/orders.js +0 -16
  198. package/dist/runtime/server/api/customer/profile/update.d.ts +0 -14
  199. package/dist/runtime/server/api/customer/profile/update.js +0 -33
  200. package/dist/runtime/server/api/customer/quotations.d.ts +0 -2
  201. package/dist/runtime/server/api/customer/quotations.js +0 -16
  202. package/dist/runtime/server/api/customer/search.d.ts +0 -2
  203. package/dist/runtime/server/api/customer/search.js +0 -14
  204. package/dist/runtime/server/api/customer/tax-invoice.d.ts +0 -8
  205. package/dist/runtime/server/api/customer/tax-invoice.js +0 -35
  206. package/dist/runtime/server/api/customer/wishlist/add.d.ts +0 -2
  207. package/dist/runtime/server/api/customer/wishlist/add.js +0 -29
  208. package/dist/runtime/server/api/customer/wishlist/createWishList.d.ts +0 -2
  209. package/dist/runtime/server/api/customer/wishlist/createWishList.js +0 -28
  210. package/dist/runtime/server/api/customer/wishlist/deleteWishList.d.ts +0 -2
  211. package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +0 -29
  212. package/dist/runtime/server/api/customer/wishlist/get.d.ts +0 -2
  213. package/dist/runtime/server/api/customer/wishlist/get.js +0 -16
  214. package/dist/runtime/server/api/customer/wishlist/getWishListItems.d.ts +0 -2
  215. package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +0 -20
  216. package/dist/runtime/server/api/customer/wishlist/updateWishList.d.ts +0 -2
  217. package/dist/runtime/server/api/customer/wishlist/updateWishList.js +0 -29
  218. package/dist/runtime/server/api/v2/[...slug].get.d.ts +0 -2
  219. package/dist/runtime/server/api/v2/[...slug].get.js +0 -34
  220. package/dist/runtime/stores/IpLocation.d.ts +0 -109
  221. package/dist/runtime/stores/IpLocation.js +0 -107
  222. package/dist/runtime/utils/api.d.ts +0 -13
  223. package/dist/runtime/utils/api.js +0 -96
  224. /package/dist/runtime/server/api/{auth/register.d.ts → global/[...slug].d.ts} +0 -0
  225. /package/dist/runtime/server/api/{auth/session.get.d.ts → permalink/[...slug].get.d.ts} +0 -0
  226. /package/dist/runtime/server/api/{auth/user/session.d.ts → reviews3.d.ts} +0 -0
@@ -0,0 +1,28 @@
1
+ export default defineNuxtPlugin((nuxtApp) => {
2
+ const router = useRouter();
3
+ let isFirstLoad = true;
4
+ router.beforeEach((to, from) => {
5
+ if (to.path == from.path) {
6
+ isFirstLoad = false;
7
+ } else {
8
+ if (isFirstLoad) {
9
+ isFirstLoad = false;
10
+ return;
11
+ }
12
+ console.log(isFirstLoad);
13
+ if (to.query.customize) {
14
+ return;
15
+ }
16
+ const url = new URL(to.fullPath, window.location.origin);
17
+ const authToken = useCookie("authToken").value;
18
+ const customerType = useCookie("customertype").value;
19
+ console.log(url.href, window.location.origin + "/");
20
+ console.log(authToken && customerType && Number(customerType) > 1 && url.href !== window.location.origin + "/");
21
+ if (authToken && customerType && Number(customerType) > 1 && url.href !== window.location.origin + "/") {
22
+ url.searchParams.set("type", customerType);
23
+ }
24
+ window.location.href = url.pathname + url.search;
25
+ return false;
26
+ }
27
+ });
28
+ });
@@ -1,3 +1,2 @@
1
- export declare const catelogCache: Map<any, any>;
2
1
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
2
  export default _default;
@@ -1,46 +1,19 @@
1
- import { defineEventHandler, setResponseStatus } from "h3";
2
- import { writeFile, mkdir, readFile } from "fs/promises";
3
- import { join } from "path";
1
+ import { defineEventHandler } from "h3";
4
2
  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
+ import { flowrixS3 } from "../../middleware/flowrixs3.js";
15
4
  export default defineEventHandler(async (event) => {
16
- const fileName = "albums";
17
- const filePath = join(CACHE_DIR, `${fileName}.json`);
5
+ const config = useRuntimeConfig();
6
+ const endpoint = "albums";
18
7
  try {
19
- const fileContent = await readFile(filePath, "utf-8");
20
- const catelog = JSON.parse(fileContent);
21
- return catelog;
22
- } catch (error) {
23
- }
24
- try {
25
- const config = useRuntimeConfig();
26
- const rawCookies = event.req.headers.cookie || "";
27
- const apiConfig = {
28
- ...config,
29
- cookies: rawCookies
30
- };
31
- const options = {
32
- headers: {
33
- "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
34
- }
8
+ const s3Data = await flowrixS3.get(endpoint, config);
9
+ console.log("Loaded from S3:", endpoint);
10
+ return s3Data;
11
+ } catch (s3Error) {
12
+ console.log("S3 fetch failed:", s3Error.message);
13
+ return {
14
+ status: "Error",
15
+ message: "File not found",
16
+ error: s3Error.message
35
17
  };
36
- const albums = await flowrixApi.get(`albums`, apiConfig, options);
37
- if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
- await ensureCacheDir();
39
- await writeFile(filePath, JSON.stringify(albums, null, 2), "utf-8");
40
- }
41
- return albums;
42
- } catch (error) {
43
- setResponseStatus(event, 500);
44
- return { success: false, error: error.message };
45
18
  }
46
19
  });
@@ -1,18 +0,0 @@
1
- interface AuthUser {
2
- id: string | number;
3
- email: string;
4
- firstName?: string;
5
- lastName?: string;
6
- }
7
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
8
- user: AuthUser;
9
- token: string;
10
- success?: undefined;
11
- error?: undefined;
12
- } | {
13
- success: boolean;
14
- error: string;
15
- user?: undefined;
16
- token?: undefined;
17
- }>>;
18
- export default _default;
@@ -1,57 +0,0 @@
1
- import { defineEventHandler, readBody, createError, setResponseStatus } from "h3";
2
- export default defineEventHandler(async (event) => {
3
- try {
4
- const body = await readBody(event);
5
- const { email, password } = body;
6
- if (!email || !password) {
7
- throw createError({
8
- statusCode: 400,
9
- statusMessage: "Email and password are required"
10
- });
11
- }
12
- const response = await fetch(`${process.env.FLOWRIX_API_BASE}login/`, {
13
- method: "POST",
14
- headers: {
15
- "x-public-key": process.env.FLOWRIX_API_KEY,
16
- "Origin": process.env.FLOWRIX_API_ORIGIN,
17
- "Content-Type": "application/json"
18
- },
19
- body: JSON.stringify({ email, password })
20
- });
21
- if (!response.ok) {
22
- let errorMessage = "Login failed";
23
- try {
24
- const errorData = await response.json();
25
- console.error("Error response data:", errorData);
26
- if (errorData.message) {
27
- if (Array.isArray(errorData.message)) {
28
- errorMessage = errorData.message.join(", ");
29
- } else if (typeof errorData.message === "object") {
30
- errorMessage = errorData.message.email || Object.values(errorData.message)[0] || errorMessage;
31
- } else {
32
- errorMessage = errorData.message;
33
- }
34
- }
35
- } catch (parseError) {
36
- console.error("Failed to parse error response:", parseError);
37
- errorMessage = `HTTP ${response.status}: ${response.statusText}`;
38
- }
39
- throw createError({
40
- statusCode: response.status,
41
- statusMessage: errorMessage
42
- });
43
- }
44
- const data = await response.json();
45
- let user;
46
- let token;
47
- user = data.data.user;
48
- token = data.data.access_token;
49
- return {
50
- user,
51
- token
52
- };
53
- } catch (error) {
54
- setResponseStatus(event, 500);
55
- return { success: false, error: error.message };
56
- }
57
- });
@@ -1,3 +1,2 @@
1
- export declare const catelogCache: Map<any, any>;
2
1
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
2
  export default _default;
@@ -1,46 +1,19 @@
1
- import { defineEventHandler, setResponseStatus } from "h3";
2
- import { writeFile, mkdir, readFile } from "fs/promises";
3
- import { join } from "path";
1
+ import { defineEventHandler } from "h3";
4
2
  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
+ import { flowrixS3 } from "../../middleware/flowrixs3.js";
15
4
  export default defineEventHandler(async (event) => {
16
- const fileName = "banners";
17
- const filePath = join(CACHE_DIR, `${fileName}.json`);
5
+ const config = useRuntimeConfig();
6
+ const endpoint = "banners/index";
18
7
  try {
19
- const fileContent = await readFile(filePath, "utf-8");
20
- const catelog = JSON.parse(fileContent);
21
- return catelog;
22
- } catch (error) {
23
- }
24
- try {
25
- const config = useRuntimeConfig();
26
- const rawCookies = event.req.headers.cookie || "";
27
- const apiConfig = {
28
- ...config,
29
- cookies: rawCookies
30
- };
31
- const options = {
32
- headers: {
33
- "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
34
- }
8
+ const s3Data = await flowrixS3.get(endpoint, config);
9
+ console.log("Loaded from S3:", endpoint);
10
+ return s3Data;
11
+ } catch (s3Error) {
12
+ console.log("S3 fetch failed:", s3Error.message);
13
+ return {
14
+ status: "Error",
15
+ message: "File not found",
16
+ error: s3Error.message
35
17
  };
36
- const banners = await flowrixApi.get(`banners`, apiConfig, options);
37
- if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
- await ensureCacheDir();
39
- await writeFile(filePath, JSON.stringify(banners, null, 2), "utf-8");
40
- }
41
- return banners;
42
- } catch (error) {
43
- setResponseStatus(event, 500);
44
- return { success: false, error: error.message };
45
18
  }
46
19
  });
@@ -1,3 +1,2 @@
1
- export declare const brandCache: Map<any, any>;
2
1
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
2
  export default _default;
@@ -1,55 +1,26 @@
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";
1
+ import { defineEventHandler, getQuery, createError } from "h3";
2
+ import { flowrixS3 } from "../../../middleware/flowrixs3.js";
5
3
  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
4
  export default defineEventHandler(async (event) => {
16
- const slug = event.context.params._;
5
+ const slug = event.context.params?._;
6
+ const config = useRuntimeConfig();
17
7
  let query = getQuery(event);
18
8
  if (!slug) {
19
9
  throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
20
10
  }
21
11
  if (!/^[a-zA-Z0-9-_]+$/.test(slug)) {
22
12
  }
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
- }
13
+ const endpoint = `brands/${slug}`;
32
14
  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 headers = {
43
- "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
15
+ const s3Data = await flowrixS3.get(endpoint, config);
16
+ console.log("Loaded from S3:", endpoint);
17
+ return s3Data;
18
+ } catch (s3Error) {
19
+ console.log("S3 fetch failed:", s3Error.message);
20
+ return {
21
+ status: "Error",
22
+ message: "File not found",
23
+ error: s3Error.message
44
24
  };
45
- const brand = await flowrixApi.get(`brands/${slug}`, apiConfig, { query, headers });
46
- if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
47
- await ensureCacheDir();
48
- await writeFile(filePath, JSON.stringify(brand, null, 2), "utf-8");
49
- }
50
- return brand;
51
- } catch (error) {
52
- setResponseStatus(event, 500);
53
- return { success: false, error: error.message };
54
25
  }
55
26
  });
@@ -1,3 +1,2 @@
1
- export declare const catelogCache: Map<any, any>;
2
1
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
2
  export default _default;
@@ -1,46 +1,20 @@
1
- import { defineEventHandler, getQuery, getCookie, setResponseStatus } from "h3";
2
- import { writeFile, mkdir, readFile } from "fs/promises";
3
- import { join } from "path";
1
+ import { defineEventHandler, getQuery } from "h3";
4
2
  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
- }
3
+ import { flowrixS3 } from "../../../middleware/flowrixs3.js";
15
4
  export default defineEventHandler(async (event) => {
5
+ const config = useRuntimeConfig();
16
6
  let query = getQuery(event);
17
- const customerType = getCookie(event, "customertype") || "";
18
- const fileName = "brands";
19
- const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
7
+ const endpoint = "brands";
20
8
  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
9
+ const s3Data = await flowrixS3.get(endpoint, config);
10
+ console.log("Loaded from S3:", endpoint);
11
+ return s3Data;
12
+ } catch (s3Error) {
13
+ console.log("S3 fetch failed:", s3Error.message);
14
+ return {
15
+ status: "Error",
16
+ message: "File not found",
17
+ error: s3Error.message
35
18
  };
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
19
  }
46
20
  });
@@ -1,4 +1,4 @@
1
- import { defineEventHandler, getQuery, setResponseStatus } from "h3";
1
+ import { defineEventHandler, getQuery } from "h3";
2
2
  import { join } from "path";
3
3
  import fs from "fs";
4
4
  import path from "path";
@@ -31,7 +31,6 @@ export default defineEventHandler(async (event) => {
31
31
  }
32
32
  return deletedFiles;
33
33
  } catch (error) {
34
- setResponseStatus(event, 500);
35
34
  return { success: false, error: error.message };
36
35
  }
37
36
  });
@@ -1,4 +1,4 @@
1
- import { defineEventHandler, setResponseStatus } from "h3";
1
+ import { defineEventHandler } from "h3";
2
2
  import { join } from "path";
3
3
  import { rm } from "fs/promises";
4
4
  const CACHE_DIR = join("/tmp", ".cache");
@@ -7,7 +7,6 @@ export default defineEventHandler(async (event) => {
7
7
  await rm(CACHE_DIR, { recursive: true, force: true });
8
8
  return { success: true, message: "Cache deleted successfully" };
9
9
  } catch (error) {
10
- setResponseStatus(event, 500);
11
10
  return { success: false, error: error.message };
12
11
  }
13
12
  });
@@ -1,2 +0,0 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
2
- export default _default;
@@ -1,21 +0,0 @@
1
- import { useRuntimeConfig } from "#imports";
2
- import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
3
- import { flowrixApi } from "../../../../middleware/flowrix.js";
4
- export default defineEventHandler(async (event) => {
5
- const slug = getRouterParam(event, "slug");
6
- const body = await readBody(event);
7
- try {
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
- } catch (error) {
18
- setResponseStatus(event, 500);
19
- return { success: false, error: error.message };
20
- }
21
- });
@@ -1,2 +0,0 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
2
- export default _default;
@@ -1,21 +0,0 @@
1
- import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
2
- import { flowrixApi } from "../../../../middleware/flowrix.js";
3
- import { useRuntimeConfig } from "#imports";
4
- export default defineEventHandler(async (event) => {
5
- const slug = getRouterParam(event, "slug");
6
- const body = await readBody(event);
7
- try {
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
- } catch (error) {
18
- setResponseStatus(event, 500);
19
- return { success: false, error: error.message };
20
- }
21
- });
@@ -1,2 +0,0 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
2
- export default _default;
@@ -1,34 +0,0 @@
1
- import { useRuntimeConfig } from "#imports";
2
- import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
3
- import { flowrixApi } from "../../../middleware/flowrix.js";
4
- export default defineEventHandler(async (event) => {
5
- const slug = getRouterParam(event, "slug");
6
- const body = await readBody(event);
7
- try {
8
- const config = useRuntimeConfig();
9
- const rawCookies = event.req.headers.cookie || "";
10
- const apiConfig = {
11
- ...config,
12
- cookies: rawCookies
13
- };
14
- const options = {
15
- headers: {
16
- "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
17
- }
18
- };
19
- const productResponse = await flowrixApi.post(
20
- `cart/relatedproducts`,
21
- apiConfig,
22
- {
23
- body,
24
- headers: {
25
- "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
26
- }
27
- }
28
- );
29
- return productResponse;
30
- } catch (error) {
31
- setResponseStatus(event, 500);
32
- return { success: false, error: error.message };
33
- }
34
- });
@@ -1,2 +0,0 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
2
- export default _default;
@@ -1,21 +0,0 @@
1
- import { useRuntimeConfig } from "#imports";
2
- import { defineEventHandler, getRouterParam, setResponseStatus, readBody } from "h3";
3
- import { flowrixApi } from "../../../middleware/flowrix.js";
4
- export default defineEventHandler(async (event) => {
5
- const slug = getRouterParam(event, "slug");
6
- const body = await readBody(event);
7
- try {
8
- const config = useRuntimeConfig();
9
- const productResponse = await flowrixApi.post(
10
- `cart/remove`,
11
- config,
12
- {
13
- body
14
- }
15
- );
16
- return productResponse;
17
- } catch (error) {
18
- setResponseStatus(event, 500);
19
- return { success: false, error: error.message };
20
- }
21
- });
@@ -1,3 +1,2 @@
1
- export declare const catelogCache: Map<any, any>;
2
1
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
2
  export default _default;
@@ -1,52 +1,20 @@
1
- import { defineEventHandler, getQuery, getCookie, setResponseStatus } from "h3";
2
- import { writeFile, mkdir, readFile } from "fs/promises";
3
- import { join } from "path";
1
+ import { defineEventHandler, getQuery } from "h3";
4
2
  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
- }
3
+ import { flowrixS3 } from "../../../middleware/flowrixs3.js";
15
4
  export default defineEventHandler(async (event) => {
5
+ const config = useRuntimeConfig();
16
6
  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
- }
7
+ const endpoint = "_global_configurations/brands";
26
8
  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 options = {
37
- headers: {
38
- "x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
39
- },
40
- query
9
+ const s3Data = await flowrixS3.get(endpoint, config);
10
+ console.log("Loaded from S3:", endpoint);
11
+ return s3Data;
12
+ } catch (s3Error) {
13
+ console.log("S3 fetch failed:", s3Error.message);
14
+ return {
15
+ status: "Error",
16
+ message: "File not found",
17
+ error: s3Error.message
41
18
  };
42
- const brands = await flowrixApi.get(`brands`, apiConfig, options);
43
- if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
44
- await ensureCacheDir();
45
- await writeFile(filePath, JSON.stringify(brands, null, 2), "utf-8");
46
- }
47
- return brands;
48
- } catch (error) {
49
- setResponseStatus(event, 500);
50
- return { success: false, error: error.message };
51
19
  }
52
20
  });
@@ -1,3 +1,2 @@
1
- export declare const catelogCache: Map<any, any>;
2
1
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
3
2
  export default _default;