flowrix 1.0.1-beta.9 → 1.0.1-beta.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +1 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +103 -34
- package/dist/runtime/composables/Blog/useBlogIndex.d.ts +2 -5
- package/dist/runtime/composables/Brand/brand.js +2 -0
- package/dist/runtime/composables/Cart/useCart.d.ts +40 -0
- package/dist/runtime/composables/Cart/useCart.js +10 -0
- package/dist/runtime/composables/Cart/useCartDetail.d.ts +15 -5
- package/dist/runtime/composables/Cart/useCartDetail.js +3 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.d.ts +40 -1
- package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.js +2 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.d.ts +40 -1
- package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.js +2 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/usePaymentMethods.js +3 -14
- package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.d.ts +2 -2
- package/dist/runtime/composables/Checkout/useCheckout.d.ts +84 -73
- package/dist/runtime/composables/Checkout/useCheckout.js +81 -34
- package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.d.ts +43 -0
- package/dist/runtime/composables/Checkout/useCheckoutBillingAddress.js +84 -0
- package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.d.ts +55 -0
- package/dist/runtime/composables/Checkout/useCheckoutShippingAddress.js +196 -0
- package/dist/runtime/composables/Checkout/useCreateAccount.d.ts +7 -7
- package/dist/runtime/composables/Checkout/useCreateAccount.js +3 -1
- package/dist/runtime/composables/Checkout/useDeliveryMethod.d.ts +2 -2
- package/dist/runtime/composables/Checkout/useDeliveryMethod.js +8 -7
- package/dist/runtime/composables/Customer/useBillingAddress.d.ts +112 -0
- package/dist/runtime/composables/Customer/useBillingAddress.js +93 -0
- package/dist/runtime/composables/Customer/useLogin.d.ts +9 -0
- package/dist/runtime/composables/Customer/useLogin.js +34 -0
- package/dist/runtime/composables/Customer/useOrders.d.ts +29 -0
- package/dist/runtime/composables/Customer/useOrders.js +56 -0
- package/dist/runtime/composables/Customer/usePasswordReset.d.ts +26 -0
- package/dist/runtime/composables/Customer/usePasswordReset.js +258 -0
- package/dist/runtime/composables/Customer/useProfile.d.ts +75 -0
- package/dist/runtime/composables/Customer/useProfile.js +106 -0
- package/dist/runtime/composables/Customer/useQuotations.d.ts +32 -0
- package/dist/runtime/composables/Customer/useQuotations.js +40 -0
- package/dist/runtime/composables/Customer/useRegister.d.ts +120 -11
- package/dist/runtime/composables/Customer/useRegister.js +311 -34
- package/dist/runtime/composables/Customer/useShippingAddress.d.ts +121 -0
- package/dist/runtime/composables/Customer/useShippingAddress.js +145 -0
- package/dist/runtime/composables/Customer/useUpdatePassword.d.ts +21 -0
- package/dist/runtime/composables/Customer/useUpdatePassword.js +94 -0
- package/dist/runtime/composables/Customer/useUserCards.d.ts +22 -0
- package/dist/runtime/composables/Customer/useUserCards.js +65 -0
- package/dist/runtime/composables/{useWishlists.d.ts → Customer/useWishlists.d.ts} +6 -19
- package/dist/runtime/composables/{useWishlists.js → Customer/useWishlists.js} +21 -29
- package/dist/runtime/composables/Extras/useCountry.d.ts +11 -6
- package/dist/runtime/composables/Extras/useCountry.js +5 -4
- package/dist/runtime/composables/Header/useHeader.d.ts +6 -20
- package/dist/runtime/composables/Header/useHeader.js +3 -2
- package/dist/runtime/composables/Product/CustomProduct/useSteps.d.ts +1 -1
- package/dist/runtime/composables/Product/useProductComponent.js +2 -0
- package/dist/runtime/composables/Product/useProductSlug.d.ts +8 -1
- package/dist/runtime/composables/Product/useQuickView.d.ts +8 -0
- package/dist/runtime/composables/Product/useQuickView.js +27 -0
- package/dist/runtime/composables/Product/useService.d.ts +1 -1
- package/dist/runtime/composables/Product/useService.js +0 -3
- package/dist/runtime/composables/SideBar/Filters/useFilters.d.ts +2 -2
- package/dist/runtime/composables/SideBar/Filters/useSorting.d.ts +2 -2
- package/dist/runtime/composables/index.d.ts +16 -12
- package/dist/runtime/composables/index.js +16 -12
- package/dist/runtime/composables/useAddresses.js +6 -6
- package/dist/runtime/composables/useCards.js +2 -2
- package/dist/runtime/composables/useDataLayer.js +2 -1
- package/dist/runtime/composables/useLocation.d.ts +2 -12
- package/dist/runtime/composables/useQuotationCheckout.d.ts +78 -0
- package/dist/runtime/composables/useQuotationCheckout.js +138 -0
- package/dist/runtime/middleware/flowrix.d.ts +5 -4
- package/dist/runtime/middleware/flowrix.js +41 -21
- package/dist/runtime/pages/flowrix-default.d.vue.ts +3 -0
- package/dist/runtime/pages/flowrix-default.vue +34 -0
- package/dist/runtime/pages/flowrix-default.vue.d.ts +3 -0
- package/dist/runtime/plugin.d.ts +1 -1
- package/dist/runtime/server/api/albums.d.ts +1 -0
- package/dist/runtime/server/api/albums.js +38 -12
- package/dist/runtime/server/api/auth/forgot.js +1 -1
- package/dist/runtime/server/api/auth/login.js +5 -6
- package/dist/runtime/server/api/auth/logout.js +1 -1
- package/dist/runtime/server/api/auth/register.js +1 -1
- package/dist/runtime/server/api/auth/session.get.js +1 -1
- package/dist/runtime/server/api/auth/user/reset-password.js +1 -1
- package/dist/runtime/server/api/auth/user/session.js +1 -1
- package/dist/runtime/server/api/auth/user/verify-token.js +1 -1
- package/dist/runtime/server/api/banners.js +15 -12
- package/dist/runtime/server/api/brand/[...slug].js +55 -0
- package/dist/runtime/server/api/brand/index.d.ts +3 -0
- package/dist/runtime/server/api/brand/index.js +49 -0
- package/dist/runtime/server/api/cache/[...slug].delete.d.ts +2 -0
- package/dist/runtime/server/api/cache/[...slug].delete.js +40 -0
- package/dist/runtime/server/api/cache/clean.get.d.ts +5 -0
- package/dist/runtime/server/api/cache/clean.get.js +16 -0
- package/dist/runtime/server/api/cart/[slug]/add.d.ts +1 -1
- package/dist/runtime/server/api/cart/[slug]/add.js +11 -11
- package/dist/runtime/server/api/cart/[slug]/update.d.ts +1 -1
- package/dist/runtime/server/api/cart/[slug]/update.js +11 -11
- package/dist/runtime/server/api/{blog/blog.d.ts → cart/related.d.ts} +0 -1
- package/dist/runtime/server/api/cart/related.js +21 -0
- package/dist/runtime/server/api/cart/remove.js +1 -1
- package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +1 -1
- package/dist/runtime/server/api/cart/service/[slug]/add.js +12 -12
- package/dist/runtime/server/api/catalog/brands.d.ts +3 -0
- package/dist/runtime/server/api/catalog/brands.js +49 -0
- package/dist/runtime/server/api/catalog/categories.js +22 -16
- package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
- package/dist/runtime/server/api/catalog/categoriesall.js +49 -0
- package/dist/runtime/server/api/catalog/featured.js +22 -14
- package/dist/runtime/server/api/catalog/posts.d.ts +3 -0
- package/dist/runtime/server/api/catalog/posts.js +49 -0
- package/dist/runtime/server/api/catalog/samples.js +22 -16
- package/dist/runtime/server/api/catalog/search.js +21 -15
- package/dist/runtime/server/api/category/[...slug].js +22 -16
- package/dist/runtime/server/api/checkout/applyCoupon.d.ts +1 -1
- package/dist/runtime/server/api/checkout/applyCoupon.js +13 -13
- package/dist/runtime/server/api/checkout/configs.d.ts +1 -1
- package/dist/runtime/server/api/checkout/configs.js +11 -11
- package/dist/runtime/server/api/checkout/countries.d.ts +1 -1
- package/dist/runtime/server/api/checkout/countries.js +5 -9
- package/dist/runtime/server/api/checkout/paymentmethod.d.ts +1 -1
- package/dist/runtime/server/api/checkout/paymentmethod.js +16 -11
- package/dist/runtime/server/api/checkout/quotation/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/[slug].js +21 -0
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +37 -0
- package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/guest/customer.js +21 -0
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +23 -0
- package/dist/runtime/server/api/{blog/[slug].js → cmspost/[...slug].js} +19 -18
- package/dist/runtime/server/api/cmspost/all.d.ts +3 -0
- package/dist/runtime/server/api/cmspost/all.js +49 -0
- package/dist/runtime/server/api/company/profile.d.ts +1 -1
- package/dist/runtime/server/api/company/profile.js +9 -9
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +1 -1
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +48 -15
- package/dist/runtime/server/api/contact-center/webforms/create.d.ts +1 -1
- package/dist/runtime/server/api/contact-center/webforms/create.js +10 -10
- package/dist/runtime/server/api/countries.d.ts +2 -0
- package/dist/runtime/server/api/countries.js +42 -0
- package/dist/runtime/server/api/customer/address/add.js +1 -1
- package/dist/runtime/server/api/customer/address/delete.js +2 -2
- package/dist/runtime/server/api/customer/address/setshipping.js +1 -1
- package/dist/runtime/server/api/customer/address/update.js +1 -1
- package/dist/runtime/server/api/customer/cards/delete.js +2 -2
- package/dist/runtime/server/api/customer/cards/get.js +2 -2
- package/dist/runtime/server/api/customer/change-password.js +2 -2
- package/dist/runtime/server/api/customer/checkout.js +1 -1
- package/dist/runtime/server/api/customer/orders.js +2 -2
- package/dist/runtime/server/api/customer/profile/update.js +1 -1
- package/dist/runtime/server/api/customer/quotations.js +2 -2
- package/dist/runtime/server/api/customer/search.js +1 -1
- package/dist/runtime/server/api/customer/tax-invoice.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/add.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/createWishList.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/get.js +2 -2
- package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +1 -1
- package/dist/runtime/server/api/customer/wishlist/updateWishList.js +2 -2
- package/dist/runtime/server/api/featured.d.ts +3 -0
- package/dist/runtime/server/api/featured.js +49 -0
- package/dist/runtime/server/api/generate/robots.get.d.ts +2 -0
- package/dist/runtime/server/api/generate/robots.get.js +20 -0
- package/dist/runtime/server/api/generate/sitemap.get.d.ts +2 -0
- package/dist/runtime/server/api/generate/sitemap.get.js +32 -0
- package/dist/runtime/server/api/location.d.ts +1 -1
- package/dist/runtime/server/api/location.js +20 -12
- package/dist/runtime/server/api/nav/[id]/links.d.ts +1 -0
- package/dist/runtime/server/api/nav/[id]/links.js +48 -14
- package/dist/runtime/server/api/page/{[slug].js → [...slug].js} +18 -17
- package/dist/runtime/server/api/product/[...slug].js +23 -9
- package/dist/runtime/server/api/{v2/[...slug].d.ts → quickview/[slug].d.ts} +0 -1
- package/dist/runtime/server/api/quickview/[slug].js +17 -0
- package/dist/runtime/server/api/reviews.d.ts +2 -0
- package/dist/runtime/server/api/reviews.js +18 -0
- package/dist/runtime/server/api/samples.d.ts +3 -0
- package/dist/runtime/server/api/samples.js +50 -0
- package/dist/runtime/server/api/search.d.ts +3 -0
- package/dist/runtime/server/api/search.js +50 -0
- package/dist/runtime/server/api/service/[slug].js +17 -13
- package/dist/runtime/server/api/service/availability.d.ts +1 -1
- package/dist/runtime/server/api/service/availability.js +11 -13
- package/dist/runtime/server/api/service/getall.d.ts +3 -0
- package/dist/runtime/server/api/service/getall.js +55 -0
- package/dist/runtime/server/api/shop.d.ts +3 -0
- package/dist/runtime/server/api/shop.js +50 -0
- package/dist/runtime/server/api/subscribe.d.ts +1 -1
- package/dist/runtime/server/api/subscribe.js +19 -14
- package/dist/runtime/server/api/v2/[...slug].get.d.ts +2 -0
- package/dist/runtime/server/api/v2/[...slug].get.js +16 -0
- package/dist/runtime/server/api/webform.d.ts +3 -0
- package/dist/runtime/server/api/webform.js +52 -0
- package/dist/runtime/server/tsconfig.json +3 -3
- package/dist/runtime/stores/Cart.d.ts +12 -0
- package/dist/runtime/stores/Cart.js +56 -19
- package/dist/runtime/stores/Checkout.d.ts +9 -15
- package/dist/runtime/stores/Checkout.js +19 -24
- package/dist/runtime/stores/Search.d.ts +1 -1
- package/dist/runtime/stores/Services.js +2 -2
- package/dist/runtime/stores/auth.d.ts +8 -11
- package/dist/runtime/stores/auth.js +390 -8
- package/dist/runtime/stores/countries.d.ts +1 -3
- package/dist/runtime/stores/countries.js +4 -8
- package/dist/runtime/stores/product/slug.d.ts +1 -17
- package/dist/runtime/stores/wishlists.d.ts +114 -6
- package/dist/runtime/stores/wishlists.js +209 -9
- package/dist/runtime/utils/api.js +9 -13
- package/dist/runtime/utils/htmlCache.d.ts +2 -2
- package/dist/runtime/utils/htmlCache.js +23 -13
- package/dist/types.d.mts +6 -2
- package/package.json +30 -20
- package/dist/runtime/composables/Checkout/useBillingAddress.d.ts +0 -19
- package/dist/runtime/composables/Checkout/useBillingAddress.js +0 -82
- package/dist/runtime/composables/Checkout/useShippingAddress.d.ts +0 -9
- package/dist/runtime/composables/Checkout/useShippingAddress.js +0 -121
- package/dist/runtime/composables/useAuth.d.ts +0 -45
- package/dist/runtime/composables/useAuth.js +0 -180
- package/dist/runtime/composables/useCountries.d.ts +0 -12
- package/dist/runtime/composables/useCountries.js +0 -50
- package/dist/runtime/composables/useOrders.d.ts +0 -21
- package/dist/runtime/composables/useOrders.js +0 -82
- package/dist/runtime/composables/useQuotations.d.ts +0 -14
- package/dist/runtime/composables/useQuotations.js +0 -50
- package/dist/runtime/plugins/fullReload.client.d.ts +0 -2
- package/dist/runtime/plugins/fullReload.client.js +0 -10
- package/dist/runtime/server/api/blog/blog.js +0 -17
- package/dist/runtime/server/api/brand/[slug].js +0 -58
- package/dist/runtime/server/api/v2/[...slug].js +0 -9
- /package/dist/runtime/server/api/brand/{[slug].d.ts → [...slug].d.ts} +0 -0
- /package/dist/runtime/server/api/{blog/[slug].d.ts → cmspost/[...slug].d.ts} +0 -0
- /package/dist/runtime/server/api/page/{[slug].d.ts → [...slug].d.ts} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { defineEventHandler, createError } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
2
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
3
|
import { join } from "path";
|
|
5
|
-
|
|
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,20 +22,22 @@ export default defineEventHandler(async (event) => {
|
|
|
21
22
|
} catch (error) {
|
|
22
23
|
}
|
|
23
24
|
try {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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.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
38
|
throw createError({
|
|
36
39
|
statusCode: 500,
|
|
37
|
-
statusMessage: `Failed to fetch
|
|
40
|
+
statusMessage: `Failed to fetch banners`,
|
|
38
41
|
data: error.message
|
|
39
42
|
});
|
|
40
43
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, createError } 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.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
|
+
throw createError({
|
|
50
|
+
statusCode: 500,
|
|
51
|
+
statusMessage: `Failed to fetch brand for slug: ${slug}`,
|
|
52
|
+
data: error.message
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, createError, getCookie } 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.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
|
+
throw createError({
|
|
44
|
+
statusCode: 500,
|
|
45
|
+
statusMessage: `Failed to fetch Brands`,
|
|
46
|
+
data: error.message
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, createError } 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
|
+
throw createError({
|
|
35
|
+
statusCode: 500,
|
|
36
|
+
statusMessage: `Cache not clear for slug: ${slug}`,
|
|
37
|
+
data: error.message
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineEventHandler, createError } 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
|
+
throw createError({
|
|
11
|
+
statusCode: 500,
|
|
12
|
+
statusMessage: `Cache not cleared`,
|
|
13
|
+
data: error.message
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<
|
|
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 {
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
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<
|
|
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 {
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
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 };
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
12
|
+
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
13
|
+
},
|
|
14
|
+
body
|
|
15
|
+
});
|
|
16
|
+
return productResponse;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
setResponseStatus(event, 500);
|
|
19
|
+
return { success: false, error: error.message };
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -7,7 +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-
|
|
10
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
11
11
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
12
12
|
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
13
13
|
},
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<
|
|
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 {
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
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,49 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, createError, getCookie } 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.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
|
+
throw createError({
|
|
44
|
+
statusCode: 500,
|
|
45
|
+
statusMessage: `Failed to fetch Brands`,
|
|
46
|
+
data: error.message
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery, createError } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
1
|
+
import { defineEventHandler, getQuery, createError, getCookie } from "h3";
|
|
3
2
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
3
|
import { join } from "path";
|
|
5
|
-
|
|
4
|
+
import { useRuntimeConfig } from "#imports";
|
|
5
|
+
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
6
|
+
const CACHE_DIR = join("/tmp", ".cache", "nitro", "catalog");
|
|
6
7
|
export const catelogCache = /* @__PURE__ */ new Map();
|
|
7
8
|
async function ensureCacheDir() {
|
|
8
9
|
try {
|
|
@@ -12,9 +13,10 @@ async function ensureCacheDir() {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
export default defineEventHandler(async (event) => {
|
|
15
|
-
|
|
16
|
+
let query = getQuery(event);
|
|
17
|
+
const customerType = getCookie(event, "customertype") || "";
|
|
16
18
|
const fileName = "categories";
|
|
17
|
-
const filePath = join(CACHE_DIR, `${fileName}.json`);
|
|
19
|
+
const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
|
|
18
20
|
try {
|
|
19
21
|
const fileContent = await readFile(filePath, "utf-8");
|
|
20
22
|
const catelog = JSON.parse(fileContent);
|
|
@@ -22,21 +24,25 @@ export default defineEventHandler(async (event) => {
|
|
|
22
24
|
} catch (error) {
|
|
23
25
|
}
|
|
24
26
|
try {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
await
|
|
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 categories = await flowrixApi.get(`categories`, apiConfig, { query });
|
|
37
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
38
|
+
await ensureCacheDir();
|
|
39
|
+
await writeFile(filePath, JSON.stringify(categories, null, 2), "utf-8");
|
|
40
|
+
}
|
|
35
41
|
return categories;
|
|
36
42
|
} catch (error) {
|
|
37
43
|
throw createError({
|
|
38
44
|
statusCode: 500,
|
|
39
|
-
statusMessage: `Failed to fetch
|
|
45
|
+
statusMessage: `Failed to fetch categories`,
|
|
40
46
|
data: error.message
|
|
41
47
|
});
|
|
42
48
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, createError, getCookie } 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 = "categoriesall";
|
|
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 categories = await flowrixApi.get(`categories/all`, apiConfig, { query });
|
|
37
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
38
|
+
await ensureCacheDir();
|
|
39
|
+
await writeFile(filePath, JSON.stringify(categories, null, 2), "utf-8");
|
|
40
|
+
}
|
|
41
|
+
return categories;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw createError({
|
|
44
|
+
statusCode: 500,
|
|
45
|
+
statusMessage: `Failed to fetch categories`,
|
|
46
|
+
data: error.message
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { defineEventHandler, createError } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
1
|
+
import { defineEventHandler, getQuery, createError, getCookie } from "h3";
|
|
3
2
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
3
|
import { join } from "path";
|
|
5
|
-
|
|
4
|
+
import { useRuntimeConfig } from "#imports";
|
|
5
|
+
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
6
|
+
const CACHE_DIR = join("/tmp", ".cache", "nitro", "catalog");
|
|
6
7
|
export const catelogCache = /* @__PURE__ */ new Map();
|
|
7
8
|
async function ensureCacheDir() {
|
|
8
9
|
try {
|
|
@@ -12,8 +13,10 @@ async function ensureCacheDir() {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
export default defineEventHandler(async (event) => {
|
|
16
|
+
let query = getQuery(event);
|
|
17
|
+
const customerType = getCookie(event, "customertype") || "";
|
|
15
18
|
const fileName = "featured";
|
|
16
|
-
const filePath = join(CACHE_DIR, `${fileName}.json`);
|
|
19
|
+
const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
|
|
17
20
|
try {
|
|
18
21
|
const fileContent = await readFile(filePath, "utf-8");
|
|
19
22
|
const catelog = JSON.parse(fileContent);
|
|
@@ -21,20 +24,25 @@ export default defineEventHandler(async (event) => {
|
|
|
21
24
|
} catch (error) {
|
|
22
25
|
}
|
|
23
26
|
try {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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 featured = await flowrixApi.get(`products/featured`, apiConfig, { query });
|
|
37
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
38
|
+
await ensureCacheDir();
|
|
39
|
+
await writeFile(filePath, JSON.stringify(featured, null, 2), "utf-8");
|
|
40
|
+
}
|
|
33
41
|
return featured;
|
|
34
42
|
} catch (error) {
|
|
35
43
|
throw createError({
|
|
36
44
|
statusCode: 500,
|
|
37
|
-
statusMessage: `Failed to fetch catelog for
|
|
45
|
+
statusMessage: `Failed to fetch catelog for featured`,
|
|
38
46
|
data: error.message
|
|
39
47
|
});
|
|
40
48
|
}
|