flowrix 1.0.1-beta.14 → 1.0.1-beta.141
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 +169 -30
- package/dist/runtime/composables/Blog/useBlogIndex.d.ts +2 -5
- package/dist/runtime/composables/Blog/useBlogSingle.js +2 -4
- package/dist/runtime/composables/Brand/brand.d.ts +1 -1
- package/dist/runtime/composables/Brand/brand.js +30 -2
- package/dist/runtime/composables/Cart/useCart.d.ts +40 -0
- package/dist/runtime/composables/Cart/useCart.js +10 -0
- package/dist/runtime/composables/Cart/useCartComponent.d.ts +1 -0
- package/dist/runtime/composables/Cart/useCartComponent.js +11 -0
- package/dist/runtime/composables/Cart/useCartDetail.d.ts +15 -5
- package/dist/runtime/composables/Cart/useCartDetail.js +3 -0
- package/dist/runtime/composables/Category/useCategoryIndex.d.ts +25 -32
- package/dist/runtime/composables/Category/useCategoryIndex.js +63 -44
- package/dist/runtime/composables/Checkout/PaymentMethods/useDirectDeposit.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useEway.js +16 -6
- package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.d.ts +40 -1
- package/dist/runtime/composables/Checkout/PaymentMethods/useFlowrixpay.js +10 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.d.ts +40 -1
- package/dist/runtime/composables/Checkout/PaymentMethods/useOpayo.js +10 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/usePaymentMethods.js +3 -14
- package/dist/runtime/composables/Checkout/PaymentMethods/usePaypal.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.d.ts +2 -2
- package/dist/runtime/composables/Checkout/PaymentMethods/useStripe.js +8 -0
- package/dist/runtime/composables/Checkout/PaymentMethods/useZippay.js +8 -0
- package/dist/runtime/composables/Checkout/useCheckout.d.ts +85 -73
- package/dist/runtime/composables/Checkout/useCheckout.js +84 -53
- 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 +18 -11
- 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 +121 -13
- package/dist/runtime/composables/Customer/useRegister.js +310 -35
- 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 +130 -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} +7 -20
- package/dist/runtime/composables/{useWishlists.js → Customer/useWishlists.js} +21 -30
- package/dist/runtime/composables/Extras/useCountry.d.ts +11 -6
- package/dist/runtime/composables/Extras/useCountry.js +5 -4
- package/dist/runtime/composables/Footer/useFooter.d.ts +4 -4
- package/dist/runtime/composables/Footer/useFooter.js +12 -8
- 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/useCustomeScript.js +4 -5
- package/dist/runtime/composables/Product/CustomProduct/useSteps.d.ts +1 -1
- package/dist/runtime/composables/Product/useProductComponent.js +110 -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 +42 -15
- package/dist/runtime/composables/Product/useService.js +137 -48
- package/dist/runtime/composables/Samples/useSamples.d.ts +5 -6
- package/dist/runtime/composables/Samples/useSamples.js +19 -15
- 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 +18 -12
- package/dist/runtime/composables/index.js +18 -12
- package/dist/runtime/composables/useAddresses.js +6 -6
- package/dist/runtime/composables/useApp.d.ts +1 -0
- package/dist/runtime/composables/useApp.js +88 -0
- package/dist/runtime/composables/useCards.js +2 -2
- package/dist/runtime/composables/useDataLayer.js +1 -1
- package/dist/runtime/composables/useDotDigital.d.ts +3 -0
- package/dist/runtime/composables/useDotDigital.js +122 -0
- package/dist/runtime/composables/useLocation.d.ts +61 -19
- package/dist/runtime/composables/useLocation.js +353 -25
- package/dist/runtime/composables/useMetaLayer.js +11 -11
- package/dist/runtime/composables/useQuotationCheckout.d.ts +78 -0
- package/dist/runtime/composables/useQuotationCheckout.js +137 -0
- package/dist/runtime/composables/useSubscriptions.d.ts +17 -10
- package/dist/runtime/composables/useSubscriptions.js +68 -33
- package/dist/runtime/composables/useTikTokDatalayer.js +7 -7
- package/dist/runtime/composables/useWebforms.d.ts +38 -9
- package/dist/runtime/composables/useWebforms.js +93 -60
- package/dist/runtime/middleware/flowrix.d.ts +5 -4
- package/dist/runtime/middleware/flowrix.js +40 -22
- package/dist/runtime/pages/404.d.vue.ts +3 -0
- package/dist/runtime/pages/404.vue +6 -0
- package/dist/runtime/pages/404.vue.d.ts +3 -0
- package/dist/runtime/pages/flowrix-default.d.vue.ts +3 -0
- package/dist/runtime/pages/flowrix-default.vue +42 -0
- package/dist/runtime/pages/flowrix-default.vue.d.ts +3 -0
- package/dist/runtime/plugin.d.ts +1 -1
- package/dist/runtime/plugins/router.d.ts +2 -0
- package/dist/runtime/plugins/router.js +11 -0
- package/dist/runtime/server/api/albums.d.ts +1 -0
- package/dist/runtime/server/api/albums.js +35 -7
- package/dist/runtime/server/api/auth/forgot.js +1 -2
- package/dist/runtime/server/api/auth/login.d.ts +7 -0
- package/dist/runtime/server/api/auth/login.js +4 -16
- package/dist/runtime/server/api/auth/logout.js +1 -2
- package/dist/runtime/server/api/auth/register.js +1 -2
- package/dist/runtime/server/api/auth/session.get.js +1 -3
- package/dist/runtime/server/api/auth/user/reset-password.js +1 -2
- package/dist/runtime/server/api/auth/user/session.js +1 -2
- package/dist/runtime/server/api/auth/user/verify-token.js +1 -2
- package/dist/runtime/server/api/banners.js +20 -15
- 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 +46 -0
- package/dist/runtime/server/api/cache/[...slug].delete.d.ts +4 -1
- package/dist/runtime/server/api/cache/[...slug].delete.js +4 -7
- package/dist/runtime/server/api/cache/clean.get.d.ts +5 -0
- package/dist/runtime/server/api/cache/clean.get.js +4 -7
- 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/{v2/[...slug].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.d.ts +1 -1
- package/dist/runtime/server/api/cart/remove.js +10 -10
- 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 +52 -0
- package/dist/runtime/server/api/catalog/categories.js +28 -19
- package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
- package/dist/runtime/server/api/catalog/categoriesall.js +52 -0
- package/dist/runtime/server/api/catalog/featured.js +28 -17
- package/dist/runtime/server/api/catalog/posts.d.ts +3 -0
- package/dist/runtime/server/api/catalog/posts.js +52 -0
- package/dist/runtime/server/api/catalog/samples.js +28 -19
- package/dist/runtime/server/api/catalog/search.js +28 -19
- package/dist/runtime/server/api/category/[...slug].js +31 -20
- package/dist/runtime/server/api/check-404.d.ts +4 -0
- package/dist/runtime/server/api/check-404.js +8 -0
- 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/{blog/blog.d.ts → checkout/quotation/[slug].d.ts} +0 -1
- package/dist/runtime/server/api/checkout/quotation/[slug].js +20 -0
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +35 -0
- package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/guest/customer.js +20 -0
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +2 -0
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +22 -0
- package/dist/runtime/server/api/checkvariables.d.ts +3 -0
- package/dist/runtime/server/api/checkvariables.js +37 -0
- package/dist/runtime/server/api/cmspost/[...slug].js +54 -0
- package/dist/runtime/server/api/cmspost/all.d.ts +3 -0
- package/dist/runtime/server/api/cmspost/all.js +52 -0
- package/dist/runtime/server/api/company/profile.d.ts +1 -1
- package/dist/runtime/server/api/company/profile.js +12 -7
- 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 +50 -15
- package/dist/runtime/server/api/contact-center/webforms/create.d.ts +1 -1
- package/dist/runtime/server/api/contact-center/webforms/create.js +13 -9
- package/dist/runtime/server/api/countries.d.ts +2 -0
- package/dist/runtime/server/api/countries.js +44 -0
- package/dist/runtime/server/api/customer/address/add.js +1 -2
- package/dist/runtime/server/api/customer/address/delete.js +2 -3
- package/dist/runtime/server/api/customer/address/setshipping.js +1 -2
- package/dist/runtime/server/api/customer/address/update.js +1 -2
- package/dist/runtime/server/api/customer/cards/delete.js +2 -3
- package/dist/runtime/server/api/customer/cards/get.js +2 -3
- package/dist/runtime/server/api/customer/change-password.js +2 -3
- package/dist/runtime/server/api/customer/checkout.js +1 -2
- package/dist/runtime/server/api/customer/orders.js +2 -3
- package/dist/runtime/server/api/customer/profile/update.js +1 -2
- package/dist/runtime/server/api/customer/quotations.js +2 -3
- package/dist/runtime/server/api/customer/search.js +1 -2
- package/dist/runtime/server/api/customer/tax-invoice.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/add.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/createWishList.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/get.js +2 -3
- package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +1 -2
- package/dist/runtime/server/api/customer/wishlist/updateWishList.js +2 -3
- package/dist/runtime/server/api/featured.d.ts +3 -0
- package/dist/runtime/server/api/featured.js +52 -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 +24 -12
- package/dist/runtime/server/api/nav/[id]/links.d.ts +1 -0
- package/dist/runtime/server/api/nav/[id]/links.js +46 -10
- package/dist/runtime/server/api/page/[...slug].js +54 -0
- package/dist/runtime/server/api/product/[...slug].js +28 -13
- package/dist/runtime/server/api/quickview/[slug].d.ts +2 -0
- package/dist/runtime/server/api/quickview/[slug].js +21 -0
- package/dist/runtime/server/api/reviews.d.ts +2 -0
- package/dist/runtime/server/api/reviews.js +23 -0
- package/dist/runtime/server/api/samples.d.ts +3 -0
- package/dist/runtime/server/api/samples.js +53 -0
- package/dist/runtime/server/api/search.d.ts +3 -0
- package/dist/runtime/server/api/search.js +53 -0
- package/dist/runtime/server/api/service/[slug].js +22 -16
- package/dist/runtime/server/api/service/availability.d.ts +1 -1
- package/dist/runtime/server/api/service/availability.js +14 -12
- package/dist/runtime/server/api/service/getall.d.ts +3 -0
- package/dist/runtime/server/api/service/getall.js +57 -0
- package/dist/runtime/server/api/shop.d.ts +3 -0
- package/dist/runtime/server/api/shop.js +53 -0
- package/dist/runtime/server/api/subscribe.d.ts +1 -1
- package/dist/runtime/server/api/subscribe.js +23 -14
- package/dist/runtime/server/api/v2/[...slug].get.d.ts +2 -0
- package/dist/runtime/server/api/v2/[...slug].get.js +32 -0
- package/dist/runtime/server/api/webform.d.ts +3 -0
- package/dist/runtime/server/api/webform.js +54 -0
- package/dist/runtime/server/tsconfig.json +3 -3
- package/dist/runtime/stores/Cart.d.ts +12 -0
- package/dist/runtime/stores/Cart.js +62 -17
- package/dist/runtime/stores/Checkout.d.ts +9 -15
- package/dist/runtime/stores/Checkout.js +38 -45
- package/dist/runtime/stores/IpLocation.d.ts +95 -4
- package/dist/runtime/stores/IpLocation.js +93 -15
- package/dist/runtime/stores/Search.d.ts +1 -1
- package/dist/runtime/stores/Services.d.ts +5 -0
- package/dist/runtime/stores/Services.js +59 -8
- package/dist/runtime/stores/auth.d.ts +8 -11
- package/dist/runtime/stores/auth.js +385 -8
- package/dist/runtime/stores/countries.d.ts +1 -3
- package/dist/runtime/stores/countries.js +4 -8
- package/dist/runtime/stores/product/README.md +6 -6
- package/dist/runtime/stores/product/slug.d.ts +1 -17
- package/dist/runtime/stores/webforms.d.ts +24 -9
- package/dist/runtime/stores/webforms.js +105 -5
- package/dist/runtime/stores/wishlists.d.ts +125 -8
- package/dist/runtime/stores/wishlists.js +212 -20
- package/dist/runtime/utils/api.js +7 -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 +16 -5
- 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/server/api/blog/[slug].js +0 -51
- 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/page/[slug].js +0 -51
- 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,51 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getRouterParam, getQuery, createError, readBody } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
|
-
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
|
-
import { join } from "path";
|
|
5
|
-
const CACHE_DIR = join(process.cwd(), ".nuxt", "cache", "nitro", "blogs");
|
|
6
|
-
export const blogCache = /* @__PURE__ */ new Map();
|
|
7
|
-
async function ensureCacheDir() {
|
|
8
|
-
try {
|
|
9
|
-
await mkdir(CACHE_DIR, { recursive: true });
|
|
10
|
-
} catch (error) {
|
|
11
|
-
console.error("Error creating cache directory:", error);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export default defineEventHandler(async (event) => {
|
|
15
|
-
const slug = getRouterParam(event, "slug");
|
|
16
|
-
const query = getQuery(event);
|
|
17
|
-
const body = await readBody(event);
|
|
18
|
-
if (!slug) {
|
|
19
|
-
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
20
|
-
}
|
|
21
|
-
if (!/^[a-zA-Z0-9-_]+$/.test(slug)) {
|
|
22
|
-
throw createError({ statusCode: 400, statusMessage: "Invalid slug" });
|
|
23
|
-
}
|
|
24
|
-
const cacheKey = `${slug}-${JSON.stringify(query)}`;
|
|
25
|
-
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
26
|
-
const filePath = join(CACHE_DIR, `${fileName}.json`);
|
|
27
|
-
try {
|
|
28
|
-
const fileContent = await readFile(filePath, "utf-8");
|
|
29
|
-
const blog = JSON.parse(fileContent);
|
|
30
|
-
return blog;
|
|
31
|
-
} catch (error) {
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
const blog = await $fetch(`${process.env.FLOWRIX_API_BASE}posts/${slug}`, {
|
|
35
|
-
headers: {
|
|
36
|
-
"x-api-key": process.env.FLOWRIX_API_KEY,
|
|
37
|
-
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
38
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
await ensureCacheDir();
|
|
42
|
-
await writeFile(filePath, JSON.stringify(blog, null, 2), "utf-8");
|
|
43
|
-
return blog;
|
|
44
|
-
} catch (error) {
|
|
45
|
-
throw createError({
|
|
46
|
-
statusCode: 500,
|
|
47
|
-
statusMessage: `Failed to fetch blog for slug: ${slug}`,
|
|
48
|
-
data: error.message
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getRouterParam } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
|
-
export const Page = /* @__PURE__ */ new Map();
|
|
4
|
-
export default defineEventHandler(async (event) => {
|
|
5
|
-
const slug = getRouterParam(event, "slug");
|
|
6
|
-
const query = getQuery(event);
|
|
7
|
-
const page = await $fetch(`${process.env.FLOWRIX_API_BASE}posts`, {
|
|
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
|
-
query
|
|
15
|
-
});
|
|
16
|
-
return page;
|
|
17
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getRouterParam, getQuery, createError, readBody } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
|
-
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
|
-
import { join } from "path";
|
|
5
|
-
const CACHE_DIR = join(process.cwd(), ".nuxt", "cache", "nitro", "brands");
|
|
6
|
-
export const brandCache = /* @__PURE__ */ new Map();
|
|
7
|
-
async function ensureCacheDir() {
|
|
8
|
-
try {
|
|
9
|
-
await mkdir(CACHE_DIR, { recursive: true });
|
|
10
|
-
} catch (error) {
|
|
11
|
-
console.error("Error creating cache directory:", error);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export default defineEventHandler(async (event) => {
|
|
15
|
-
const slug = getRouterParam(event, "slug");
|
|
16
|
-
const query = getQuery(event);
|
|
17
|
-
const body = await readBody(event);
|
|
18
|
-
const isclearcashe = query.clearcache || false;
|
|
19
|
-
delete query.clearcache;
|
|
20
|
-
if (!slug) {
|
|
21
|
-
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
22
|
-
}
|
|
23
|
-
if (!/^[a-zA-Z0-9-_]+$/.test(slug)) {
|
|
24
|
-
throw createError({ statusCode: 400, statusMessage: "Invalid slug" });
|
|
25
|
-
}
|
|
26
|
-
const cacheKey = `${slug}-${JSON.stringify(query)}`;
|
|
27
|
-
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
28
|
-
const filePath = join(CACHE_DIR, `${fileName}.json`);
|
|
29
|
-
if (!isclearcashe) {
|
|
30
|
-
try {
|
|
31
|
-
const fileContent = await readFile(filePath, "utf-8");
|
|
32
|
-
const brand = JSON.parse(fileContent);
|
|
33
|
-
return brand;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
try {
|
|
38
|
-
const brand = await $fetch(`${process.env.FLOWRIX_API_BASE}brands/${slug}`, {
|
|
39
|
-
query,
|
|
40
|
-
method: "get",
|
|
41
|
-
headers: {
|
|
42
|
-
"x-api-key": process.env.FLOWRIX_API_KEY,
|
|
43
|
-
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
44
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
45
|
-
},
|
|
46
|
-
body: JSON.stringify(body)
|
|
47
|
-
});
|
|
48
|
-
await ensureCacheDir();
|
|
49
|
-
await writeFile(filePath, JSON.stringify(brand, null, 2), "utf-8");
|
|
50
|
-
return brand;
|
|
51
|
-
} catch (error) {
|
|
52
|
-
throw createError({
|
|
53
|
-
statusCode: 500,
|
|
54
|
-
statusMessage: `Failed to fetch brand for slug: ${slug}`,
|
|
55
|
-
data: error.message
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getRouterParam, getQuery, createError, readBody } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
|
-
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
|
-
import { join } from "path";
|
|
5
|
-
const CACHE_DIR = join(process.cwd(), ".nuxt", "cache", "nitro", "pages");
|
|
6
|
-
export const pageCache = /* @__PURE__ */ new Map();
|
|
7
|
-
async function ensureCacheDir() {
|
|
8
|
-
try {
|
|
9
|
-
await mkdir(CACHE_DIR, { recursive: true });
|
|
10
|
-
} catch (error) {
|
|
11
|
-
console.error("Error creating cache directory:", error);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export default defineEventHandler(async (event) => {
|
|
15
|
-
const slug = getRouterParam(event, "slug");
|
|
16
|
-
const query = getQuery(event);
|
|
17
|
-
const body = await readBody(event);
|
|
18
|
-
if (!slug) {
|
|
19
|
-
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
20
|
-
}
|
|
21
|
-
if (!/^[a-zA-Z0-9-_]+$/.test(slug)) {
|
|
22
|
-
throw createError({ statusCode: 400, statusMessage: "Invalid slug" });
|
|
23
|
-
}
|
|
24
|
-
const cacheKey = `${slug}-${JSON.stringify(query)}`;
|
|
25
|
-
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
26
|
-
const filePath = join(CACHE_DIR, `${fileName}.json`);
|
|
27
|
-
try {
|
|
28
|
-
const fileContent = await readFile(filePath, "utf-8");
|
|
29
|
-
const page = JSON.parse(fileContent);
|
|
30
|
-
return page;
|
|
31
|
-
} catch (error) {
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
const page = await $fetch(`${process.env.FLOWRIX_API_BASE}page/${slug}`, {
|
|
35
|
-
headers: {
|
|
36
|
-
"x-api-key": process.env.FLOWRIX_API_KEY,
|
|
37
|
-
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
38
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
await ensureCacheDir();
|
|
42
|
-
await writeFile(filePath, JSON.stringify(page, null, 2), "utf-8");
|
|
43
|
-
return page;
|
|
44
|
-
} catch (error) {
|
|
45
|
-
throw createError({
|
|
46
|
-
statusCode: 500,
|
|
47
|
-
statusMessage: `Failed to fetch page for slug: ${slug}`,
|
|
48
|
-
data: error.message
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
2
|
-
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
3
|
-
export const Page = /* @__PURE__ */ new Map();
|
|
4
|
-
export default defineEventHandler(async (event) => {
|
|
5
|
-
const slug = event.context.params._;
|
|
6
|
-
const page = await flowrixApi.get(`permalink/${slug}`, "", "v2");
|
|
7
|
-
Page.set(slug, page);
|
|
8
|
-
return page;
|
|
9
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|