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.
- package/dist/module.json +1 -1
- package/dist/module.mjs +23 -192
- package/dist/runtime/components/Types/page/index.d.vue.ts +5 -4
- package/dist/runtime/components/Types/page/index.vue +7 -11
- package/dist/runtime/components/Types/page/index.vue.d.ts +5 -4
- package/dist/runtime/composables/Blog/useBlogSingle.js +4 -5
- package/dist/runtime/composables/Category/useCategoryIndex.js +5 -5
- package/dist/runtime/composables/Checkout/useCheckout.d.ts +4 -0
- package/dist/runtime/composables/Checkout/useCheckout.js +15 -3
- package/dist/runtime/composables/Customer/useBillingAddress.d.ts +3 -0
- package/dist/runtime/composables/Customer/useBillingAddress.js +2 -0
- package/dist/runtime/composables/Customer/useShippingAddress.d.ts +3 -0
- package/dist/runtime/composables/Customer/useShippingAddress.js +2 -1
- package/dist/runtime/composables/Customer/useWishlists.d.ts +1 -1
- package/dist/runtime/composables/Product/CustomProduct/useCustomeScript.d.ts +4 -0
- package/dist/runtime/composables/Product/CustomProduct/useCustomeScript.js +5 -11
- package/dist/runtime/composables/Product/useProductCard.d.ts +90 -9
- package/dist/runtime/composables/Product/useProductCard.js +257 -55
- package/dist/runtime/composables/Product/useProductComponent.js +3 -10
- package/dist/runtime/composables/Product/useQuickView.d.ts +1 -1
- package/dist/runtime/composables/Product/useService.d.ts +1 -12
- package/dist/runtime/composables/Product/useService.js +2 -2
- package/dist/runtime/composables/index.d.ts +1 -1
- package/dist/runtime/composables/index.js +1 -1
- package/dist/runtime/composables/useAddresses.js +27 -6
- package/dist/runtime/composables/useApp.js +3 -4
- package/dist/runtime/composables/useCards.js +0 -1
- package/dist/runtime/composables/useClientApi.d.ts +8 -8
- package/dist/runtime/composables/useClientApi.js +74 -30
- package/dist/runtime/composables/useLocation.d.ts +3 -15
- package/dist/runtime/composables/useLocation.js +6 -27
- package/dist/runtime/composables/usePriceCalculation.d.ts +33 -0
- package/dist/runtime/composables/usePriceCalculation.js +107 -0
- package/dist/runtime/composables/useQuotationCheckout.d.ts +1 -1
- package/dist/runtime/middleware/flowrix.d.ts +5 -5
- package/dist/runtime/middleware/flowrix.js +2 -2
- package/dist/runtime/middleware/flowrixs3.d.ts +3 -0
- package/dist/runtime/middleware/flowrixs3.js +65 -0
- package/dist/runtime/pages/flowrix-default.vue +62 -15
- package/dist/runtime/plugins/full-reload.client.d.ts +2 -0
- package/dist/runtime/plugins/full-reload.client.js +28 -0
- package/dist/runtime/server/api/albums.d.ts +0 -1
- package/dist/runtime/server/api/albums.js +13 -40
- package/dist/runtime/server/api/auth/login.d.ts +0 -18
- package/dist/runtime/server/api/auth/login.js +0 -57
- package/dist/runtime/server/api/banners.d.ts +0 -1
- package/dist/runtime/server/api/banners.js +13 -40
- package/dist/runtime/server/api/brand/[...slug].d.ts +0 -1
- package/dist/runtime/server/api/brand/[...slug].js +14 -43
- package/dist/runtime/server/api/brand/index.d.ts +0 -1
- package/dist/runtime/server/api/brand/index.js +13 -39
- package/dist/runtime/server/api/cache/[...slug].delete.js +1 -2
- package/dist/runtime/server/api/cache/clean.get.js +1 -2
- package/dist/runtime/server/api/cart/[slug]/add.d.ts +0 -2
- package/dist/runtime/server/api/cart/[slug]/add.js +0 -21
- package/dist/runtime/server/api/cart/[slug]/update.d.ts +0 -2
- package/dist/runtime/server/api/cart/[slug]/update.js +0 -21
- package/dist/runtime/server/api/cart/related.d.ts +0 -2
- package/dist/runtime/server/api/cart/related.js +0 -34
- package/dist/runtime/server/api/cart/remove.d.ts +0 -2
- package/dist/runtime/server/api/cart/remove.js +0 -21
- package/dist/runtime/server/api/catalog/brands.d.ts +0 -1
- package/dist/runtime/server/api/catalog/brands.js +13 -45
- package/dist/runtime/server/api/catalog/categories.d.ts +0 -1
- package/dist/runtime/server/api/catalog/categories.js +13 -45
- package/dist/runtime/server/api/catalog/categoriesall.d.ts +0 -1
- package/dist/runtime/server/api/catalog/categoriesall.js +13 -45
- package/dist/runtime/server/api/catalog/featured.d.ts +0 -1
- package/dist/runtime/server/api/catalog/featured.js +13 -45
- package/dist/runtime/server/api/catalog/posts.d.ts +0 -1
- package/dist/runtime/server/api/catalog/posts.js +13 -45
- package/dist/runtime/server/api/catalog/samples.d.ts +0 -1
- package/dist/runtime/server/api/catalog/samples.js +13 -46
- package/dist/runtime/server/api/catalog/search.d.ts +0 -1
- package/dist/runtime/server/api/catalog/search.js +13 -46
- package/dist/runtime/server/api/category/[...slug].d.ts +1 -2
- package/dist/runtime/server/api/category/[...slug].js +34 -49
- package/dist/runtime/server/api/checkout/applyCoupon.d.ts +0 -2
- package/dist/runtime/server/api/checkout/applyCoupon.js +0 -20
- package/dist/runtime/server/api/checkout/configs.d.ts +0 -2
- package/dist/runtime/server/api/checkout/configs.js +0 -20
- package/dist/runtime/server/api/checkout/countries.d.ts +0 -2
- package/dist/runtime/server/api/checkout/countries.js +0 -13
- package/dist/runtime/server/api/checkout/paymentmethod.d.ts +0 -2
- package/dist/runtime/server/api/checkout/paymentmethod.js +0 -25
- package/dist/runtime/server/api/checkout/quotation/guest/customer.d.ts +0 -2
- package/dist/runtime/server/api/checkout/quotation/guest/customer.js +0 -20
- package/dist/runtime/server/api/checkvariables.js +1 -2
- package/dist/runtime/server/api/cmspost/[...slug].d.ts +0 -1
- package/dist/runtime/server/api/cmspost/[...slug].js +14 -44
- package/dist/runtime/server/api/cmspost/all.js +1 -2
- package/dist/runtime/server/api/company/profile.d.ts +1 -1
- package/dist/runtime/server/api/company/profile.js +13 -17
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +0 -3
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +0 -54
- package/dist/runtime/server/api/countries.js +13 -38
- package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +0 -45
- package/dist/runtime/server/api/featured.d.ts +0 -3
- package/dist/runtime/server/api/featured.js +0 -52
- package/dist/runtime/server/api/generate/robots.get.js +0 -2
- package/dist/runtime/server/api/generate/sitemap.get.d.ts +1 -1
- package/dist/runtime/server/api/generate/sitemap.get.js +8 -12
- package/dist/runtime/server/api/global/[...slug].js +20 -0
- package/dist/runtime/server/api/location.d.ts +0 -2
- package/dist/runtime/server/api/location.js +0 -25
- package/dist/runtime/server/api/nav/[id]/links.d.ts +0 -1
- package/dist/runtime/server/api/nav/[id]/links.js +13 -43
- package/dist/runtime/server/api/page/[...slug].d.ts +0 -1
- package/dist/runtime/server/api/page/[...slug].js +14 -44
- package/dist/runtime/server/api/permalink/[...slug].get.js +31 -0
- package/dist/runtime/server/api/product/[...slug].d.ts +0 -1
- package/dist/runtime/server/api/product/[...slug].js +14 -49
- package/dist/runtime/server/api/quickview/[slug].d.ts +1 -1
- package/dist/runtime/server/api/quickview/[slug].js +15 -16
- package/dist/runtime/server/api/reviews.d.ts +1 -1
- package/dist/runtime/server/api/reviews.js +1 -2
- package/dist/runtime/server/api/reviews3.js +19 -0
- package/dist/runtime/server/api/samples.d.ts +0 -1
- package/dist/runtime/server/api/samples.js +13 -46
- package/dist/runtime/server/api/search.d.ts +0 -1
- package/dist/runtime/server/api/search.js +13 -46
- package/dist/runtime/server/api/service/[slug].d.ts +0 -1
- package/dist/runtime/server/api/service/[slug].js +13 -44
- package/dist/runtime/server/api/service/availability.d.ts +1 -1
- package/dist/runtime/server/api/service/getall.d.ts +0 -1
- package/dist/runtime/server/api/service/getall.js +13 -51
- package/dist/runtime/server/api/shop.d.ts +0 -1
- package/dist/runtime/server/api/shop.js +13 -46
- package/dist/runtime/server/api/subscribe.d.ts +0 -2
- package/dist/runtime/server/api/subscribe.js +0 -25
- package/dist/runtime/server/api/webform.d.ts +0 -3
- package/dist/runtime/server/api/webform.js +0 -54
- package/dist/runtime/server/middleware/powertools.d.ts +9 -0
- package/dist/runtime/server/middleware/powertools.js +30 -0
- package/dist/runtime/stores/Booking.js +23 -7
- package/dist/runtime/stores/Cart.js +18 -3
- package/dist/runtime/stores/Checkout.js +14 -3
- package/dist/runtime/stores/NavMenu.js +2 -4
- package/dist/runtime/stores/Search.js +9 -3
- package/dist/runtime/stores/auth.d.ts +28 -1
- package/dist/runtime/stores/auth.js +0 -5
- package/dist/runtime/stores/countries.js +1 -1
- package/dist/runtime/stores/index.d.ts +0 -1
- package/dist/runtime/stores/index.js +0 -1
- package/dist/runtime/stores/locations.d.ts +1 -5
- package/dist/runtime/stores/locations.js +8 -5
- package/dist/runtime/stores/product.js +9 -3
- package/dist/runtime/stores/promotions.d.ts +51 -0
- package/dist/runtime/stores/promotions.js +65 -0
- package/dist/runtime/stores/useCompanyProfile.js +5 -2
- package/dist/runtime/stores/wishlists.d.ts +1 -1
- package/dist/runtime/stores/wishlists.js +1 -1
- package/package.json +11 -3
- package/dist/runtime/composables/useLocations.d.ts +0 -12
- package/dist/runtime/composables/useLocations.js +0 -53
- package/dist/runtime/server/api/auth/forgot.d.ts +0 -5
- package/dist/runtime/server/api/auth/forgot.js +0 -43
- package/dist/runtime/server/api/auth/logout.d.ts +0 -5
- package/dist/runtime/server/api/auth/logout.js +0 -22
- package/dist/runtime/server/api/auth/register.js +0 -50
- package/dist/runtime/server/api/auth/session.get.js +0 -44
- package/dist/runtime/server/api/auth/user/reset-password.d.ts +0 -5
- package/dist/runtime/server/api/auth/user/reset-password.js +0 -39
- package/dist/runtime/server/api/auth/user/session.js +0 -42
- package/dist/runtime/server/api/auth/user/verify-token.d.ts +0 -6
- package/dist/runtime/server/api/auth/user/verify-token.js +0 -49
- package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +0 -2
- package/dist/runtime/server/api/cart/service/[slug]/add.js +0 -16
- package/dist/runtime/server/api/check-404.d.ts +0 -4
- package/dist/runtime/server/api/check-404.js +0 -8
- package/dist/runtime/server/api/checkout/quotation/[slug].d.ts +0 -2
- package/dist/runtime/server/api/checkout/quotation/[slug].js +0 -20
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].d.ts +0 -2
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +0 -35
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].d.ts +0 -2
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +0 -22
- package/dist/runtime/server/api/contact-center/webforms/create.d.ts +0 -2
- package/dist/runtime/server/api/contact-center/webforms/create.js +0 -20
- package/dist/runtime/server/api/customer/address/add.d.ts +0 -14
- package/dist/runtime/server/api/customer/address/add.js +0 -32
- package/dist/runtime/server/api/customer/address/delete.d.ts +0 -20
- package/dist/runtime/server/api/customer/address/delete.js +0 -36
- package/dist/runtime/server/api/customer/address/setshipping.d.ts +0 -20
- package/dist/runtime/server/api/customer/address/setshipping.js +0 -40
- package/dist/runtime/server/api/customer/address/update.d.ts +0 -20
- package/dist/runtime/server/api/customer/address/update.js +0 -41
- package/dist/runtime/server/api/customer/cards/delete.d.ts +0 -2
- package/dist/runtime/server/api/customer/cards/delete.js +0 -22
- package/dist/runtime/server/api/customer/cards/get.d.ts +0 -2
- package/dist/runtime/server/api/customer/cards/get.js +0 -16
- package/dist/runtime/server/api/customer/change-password.d.ts +0 -14
- package/dist/runtime/server/api/customer/change-password.js +0 -33
- package/dist/runtime/server/api/customer/checkout.d.ts +0 -2
- package/dist/runtime/server/api/customer/checkout.js +0 -19
- package/dist/runtime/server/api/customer/orders.d.ts +0 -2
- package/dist/runtime/server/api/customer/orders.js +0 -16
- package/dist/runtime/server/api/customer/profile/update.d.ts +0 -14
- package/dist/runtime/server/api/customer/profile/update.js +0 -33
- package/dist/runtime/server/api/customer/quotations.d.ts +0 -2
- package/dist/runtime/server/api/customer/quotations.js +0 -16
- package/dist/runtime/server/api/customer/search.d.ts +0 -2
- package/dist/runtime/server/api/customer/search.js +0 -14
- package/dist/runtime/server/api/customer/tax-invoice.d.ts +0 -8
- package/dist/runtime/server/api/customer/tax-invoice.js +0 -35
- package/dist/runtime/server/api/customer/wishlist/add.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/add.js +0 -29
- package/dist/runtime/server/api/customer/wishlist/createWishList.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/createWishList.js +0 -28
- package/dist/runtime/server/api/customer/wishlist/deleteWishList.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +0 -29
- package/dist/runtime/server/api/customer/wishlist/get.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/get.js +0 -16
- package/dist/runtime/server/api/customer/wishlist/getWishListItems.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +0 -20
- package/dist/runtime/server/api/customer/wishlist/updateWishList.d.ts +0 -2
- package/dist/runtime/server/api/customer/wishlist/updateWishList.js +0 -29
- package/dist/runtime/server/api/v2/[...slug].get.d.ts +0 -2
- package/dist/runtime/server/api/v2/[...slug].get.js +0 -34
- package/dist/runtime/stores/IpLocation.d.ts +0 -109
- package/dist/runtime/stores/IpLocation.js +0 -107
- package/dist/runtime/utils/api.d.ts +0 -13
- package/dist/runtime/utils/api.js +0 -96
- /package/dist/runtime/server/api/{auth/register.d.ts → global/[...slug].d.ts} +0 -0
- /package/dist/runtime/server/api/{auth/session.get.d.ts → permalink/[...slug].get.d.ts} +0 -0
- /package/dist/runtime/server/api/{auth/user/session.d.ts → reviews3.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineEventHandler
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
2
|
import { mkdir, readFile } from "fs/promises";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { useRuntimeConfig } from "#imports";
|
|
@@ -31,7 +31,6 @@ export default defineEventHandler(async (event) => {
|
|
|
31
31
|
};
|
|
32
32
|
return apiConfig;
|
|
33
33
|
} catch (error) {
|
|
34
|
-
setResponseStatus(event, 500);
|
|
35
34
|
return { success: false, error: error.message };
|
|
36
35
|
}
|
|
37
36
|
});
|
|
@@ -1,53 +1,23 @@
|
|
|
1
|
-
import { defineEventHandler,
|
|
2
|
-
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
3
|
-
import { join } from "path";
|
|
1
|
+
import { defineEventHandler, createError } from "h3";
|
|
4
2
|
import { useRuntimeConfig } from "#imports";
|
|
5
|
-
import {
|
|
6
|
-
const CACHE_DIR = join("/tmp", ".cache", "nitro", "blogs");
|
|
7
|
-
export const blogCache = /* @__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 slug = event.context.params
|
|
17
|
-
const
|
|
18
|
-
let query = getQuery(event);
|
|
5
|
+
const slug = event.context.params?._;
|
|
6
|
+
const config = useRuntimeConfig();
|
|
19
7
|
if (!slug) {
|
|
20
8
|
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
21
9
|
}
|
|
22
|
-
const
|
|
23
|
-
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
24
|
-
const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
|
|
10
|
+
const endpoint = `post/${slug}`;
|
|
25
11
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
} catch (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...config,
|
|
36
|
-
cookies: rawCookies
|
|
37
|
-
};
|
|
38
|
-
const options = {
|
|
39
|
-
headers: {
|
|
40
|
-
"x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
|
|
41
|
-
}
|
|
12
|
+
const s3Data = await flowrixS3.get(endpoint, config);
|
|
13
|
+
console.log("Loaded from S3:", endpoint);
|
|
14
|
+
return s3Data;
|
|
15
|
+
} catch (s3Error) {
|
|
16
|
+
console.log("S3 fetch failed:", s3Error.message);
|
|
17
|
+
return {
|
|
18
|
+
status: "Error",
|
|
19
|
+
message: "File not found",
|
|
20
|
+
error: s3Error.message
|
|
42
21
|
};
|
|
43
|
-
const blog = await flowrixApi.get(`post/${slug}`, apiConfig, options);
|
|
44
|
-
if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
|
|
45
|
-
await ensureCacheDir();
|
|
46
|
-
await writeFile(filePath, JSON.stringify(blog, null, 2), "utf-8");
|
|
47
|
-
}
|
|
48
|
-
return blog;
|
|
49
|
-
} catch (error) {
|
|
50
|
-
setResponseStatus(event, 500);
|
|
51
|
-
return { success: false, error: error.message };
|
|
52
22
|
}
|
|
53
23
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery, getCookie
|
|
1
|
+
import { defineEventHandler, getQuery, getCookie } from "h3";
|
|
2
2
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { useRuntimeConfig } from "#imports";
|
|
@@ -46,7 +46,6 @@ export default defineEventHandler(async (event) => {
|
|
|
46
46
|
}
|
|
47
47
|
return posts;
|
|
48
48
|
} catch (error) {
|
|
49
|
-
setResponseStatus(event, 500);
|
|
50
49
|
return { success: false, error: error.message };
|
|
51
50
|
}
|
|
52
51
|
});
|
|
@@ -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<any>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import { defineEventHandler
|
|
2
|
-
import {
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { flowrixS3 } from "../../../middleware/flowrixs3.js";
|
|
3
3
|
import { useRuntimeConfig } from "#imports";
|
|
4
4
|
export default defineEventHandler(async (event) => {
|
|
5
|
+
const config = useRuntimeConfig();
|
|
6
|
+
const endpoint = "company_profile";
|
|
5
7
|
try {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 (" + endpoint + ")",
|
|
16
|
+
error: s3Error.message
|
|
11
17
|
};
|
|
12
|
-
const options = {
|
|
13
|
-
headers: {
|
|
14
|
-
"x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const companyProfile = await flowrixApi.get(`company/profile`, apiConfig, options);
|
|
18
|
-
return companyProfile;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
setResponseStatus(event, 500);
|
|
21
|
-
return { success: false, error: error.message };
|
|
22
18
|
}
|
|
23
19
|
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getRouterParam, getQuery, createError, readBody, getCookie, setResponseStatus } from "h3";
|
|
2
|
-
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { useRuntimeConfig } from "#imports";
|
|
5
|
-
import { flowrixApi } from "../../../../../middleware/flowrix.js";
|
|
6
|
-
const CACHE_DIR = join("/tmp", ".cache", "nitro", "webfroms");
|
|
7
|
-
export const webfromCache = /* @__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 = getRouterParam(event, "id");
|
|
17
|
-
const customerType = getCookie(event, "customertype") || "";
|
|
18
|
-
let query = getQuery(event);
|
|
19
|
-
const body = await readBody(event);
|
|
20
|
-
if (!slug) {
|
|
21
|
-
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
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}-${customerType}.json`);
|
|
26
|
-
try {
|
|
27
|
-
const fileContent = await readFile(filePath, "utf-8");
|
|
28
|
-
const webfrom = JSON.parse(fileContent);
|
|
29
|
-
return webfrom;
|
|
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
|
-
const options = {
|
|
40
|
-
headers: {
|
|
41
|
-
"x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const webfrom = await flowrixApi.get(`contact-center/webforms/${slug}/details`, apiConfig, options);
|
|
45
|
-
if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
|
|
46
|
-
await ensureCacheDir();
|
|
47
|
-
await writeFile(filePath, JSON.stringify(webfrom, null, 2), "utf-8");
|
|
48
|
-
}
|
|
49
|
-
return webfrom;
|
|
50
|
-
} catch (error) {
|
|
51
|
-
setResponseStatus(event, 500);
|
|
52
|
-
return { success: false, error: error.message };
|
|
53
|
-
}
|
|
54
|
-
});
|
|
@@ -1,44 +1,19 @@
|
|
|
1
|
-
import { defineEventHandler
|
|
2
|
-
import {
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { flowrixApi } from "../../middleware/flowrix.js";
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { flowrixS3 } from "../../middleware/flowrixs3.js";
|
|
5
3
|
import { useRuntimeConfig } from "#imports";
|
|
6
|
-
const CACHE_DIR = join("/tmp", ".cache", "nitro", "company");
|
|
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
4
|
export default defineEventHandler(async (event) => {
|
|
15
|
-
const
|
|
5
|
+
const config = useRuntimeConfig();
|
|
6
|
+
const endpoint = "countries/index";
|
|
16
7
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
} catch (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
...config,
|
|
27
|
-
cookies: rawCookies
|
|
28
|
-
};
|
|
29
|
-
const options = {
|
|
30
|
-
headers: {
|
|
31
|
-
"x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
|
|
32
|
-
}
|
|
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
|
|
33
17
|
};
|
|
34
|
-
const countries = await flowrixApi.get(`countries`, apiConfig, options);
|
|
35
|
-
if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
|
|
36
|
-
await ensureCacheDir();
|
|
37
|
-
await writeFile(filePath, JSON.stringify(countries, null, 2), "utf-8");
|
|
38
|
-
}
|
|
39
|
-
return countries;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
setResponseStatus(event, 500);
|
|
42
|
-
return { success: false, error: error.message };
|
|
43
18
|
}
|
|
44
19
|
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, readBody, getQuery, getCookie } from "h3";
|
|
2
|
-
export default defineEventHandler(async (event) => {
|
|
3
|
-
const { listId } = getQuery(event);
|
|
4
|
-
const body = await readBody(event);
|
|
5
|
-
const { productSlug } = body;
|
|
6
|
-
const accessTok = getCookie(event, "auth.token");
|
|
7
|
-
try {
|
|
8
|
-
if (!listId || !productSlug) {
|
|
9
|
-
return {
|
|
10
|
-
status: "Error",
|
|
11
|
-
statusCode: 400,
|
|
12
|
-
message: "Missing listId in query or productSlug in body"
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/wishlist/${listId}/item/delete`, {
|
|
16
|
-
method: "POST",
|
|
17
|
-
headers: {
|
|
18
|
-
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
19
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
20
|
-
"Authorization": `Bearer ${accessTok || ""}`,
|
|
21
|
-
"Content-Type": "application/json",
|
|
22
|
-
"Accept": "application/json"
|
|
23
|
-
},
|
|
24
|
-
body: JSON.stringify({ ids: { productSlug } })
|
|
25
|
-
});
|
|
26
|
-
const responseData = await response.json();
|
|
27
|
-
if (!response.ok) {
|
|
28
|
-
return {
|
|
29
|
-
status: "Error",
|
|
30
|
-
statusCode: response.status,
|
|
31
|
-
message: responseData.message || "Failed to delete from wishlist",
|
|
32
|
-
data: responseData
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return responseData;
|
|
36
|
-
} catch (error) {
|
|
37
|
-
console.error("Error in deleteFromWishList:", error);
|
|
38
|
-
return {
|
|
39
|
-
status: "Error",
|
|
40
|
-
statusCode: 500,
|
|
41
|
-
message: "Internal server error",
|
|
42
|
-
error: error.message || "Unknown error"
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery, getCookie, setResponseStatus } from "h3";
|
|
2
|
-
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { useRuntimeConfig } from "#imports";
|
|
5
|
-
import { flowrixApi } from "../../middleware/flowrix.js";
|
|
6
|
-
const CACHE_DIR = join("/tmp", ".cache", "nitro", "catalog");
|
|
7
|
-
export const catelogCache = /* @__PURE__ */ new Map();
|
|
8
|
-
async function ensureCacheDir() {
|
|
9
|
-
try {
|
|
10
|
-
await mkdir(CACHE_DIR, { recursive: true });
|
|
11
|
-
} catch (error) {
|
|
12
|
-
console.error("Error creating cache directory:", error);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export default defineEventHandler(async (event) => {
|
|
16
|
-
let query = getQuery(event);
|
|
17
|
-
const customerType = getCookie(event, "customertype") || "";
|
|
18
|
-
const fileName = "featured";
|
|
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 options = {
|
|
37
|
-
headers: {
|
|
38
|
-
"x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
|
|
39
|
-
},
|
|
40
|
-
query
|
|
41
|
-
};
|
|
42
|
-
const featured = await flowrixApi.get(`products/featured`, apiConfig, options);
|
|
43
|
-
if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
|
|
44
|
-
await ensureCacheDir();
|
|
45
|
-
await writeFile(filePath, JSON.stringify(featured, null, 2), "utf-8");
|
|
46
|
-
}
|
|
47
|
-
return featured;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
setResponseStatus(event, 500);
|
|
50
|
-
return { success: false, error: error.message };
|
|
51
|
-
}
|
|
52
|
-
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineEventHandler,
|
|
3
|
-
setResponseStatus,
|
|
4
3
|
setHeader
|
|
5
4
|
} from "h3";
|
|
6
5
|
import { useRuntimeConfig } from "#imports";
|
|
@@ -13,7 +12,6 @@ export default defineEventHandler(async (event) => {
|
|
|
13
12
|
setHeader(event, "Content-Type", "text/plain; charset=utf-8");
|
|
14
13
|
return fileContent;
|
|
15
14
|
} catch (error) {
|
|
16
|
-
setResponseStatus(event, 404);
|
|
17
15
|
setHeader(event, "Content-Type", "text/plain; charset=utf-8");
|
|
18
16
|
return `File not found`;
|
|
19
17
|
}
|
|
@@ -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<any>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineEventHandler,
|
|
3
|
-
setResponseStatus,
|
|
4
|
-
setHeader
|
|
5
|
-
} from "h3";
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
6
2
|
import { useRuntimeConfig } from "#imports";
|
|
7
|
-
import {
|
|
3
|
+
import { flowrixS3 } from "../../../middleware/flowrixs3.js";
|
|
8
4
|
export default defineEventHandler(async (event) => {
|
|
9
5
|
try {
|
|
10
6
|
let fullPath = event.path;
|
|
@@ -13,18 +9,18 @@ export default defineEventHandler(async (event) => {
|
|
|
13
9
|
}
|
|
14
10
|
const isGzip = fullPath.endsWith(".gz");
|
|
15
11
|
const config = useRuntimeConfig();
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
12
|
+
const endpoint = `_global_configurations/sitemaps/${fullPath}`;
|
|
13
|
+
const s3Data = await flowrixS3.get(endpoint, config, { filetype: true });
|
|
14
|
+
console.log("Loaded from S3:", endpoint);
|
|
19
15
|
if (isGzip) {
|
|
20
16
|
setHeader(event, "Content-Type", "application/xml; charset=utf-8");
|
|
21
17
|
setHeader(event, "Content-Encoding", "gzip");
|
|
22
|
-
return
|
|
18
|
+
return s3Data;
|
|
23
19
|
}
|
|
24
20
|
setHeader(event, "Content-Type", "application/xml; charset=utf-8");
|
|
25
|
-
return
|
|
21
|
+
return s3Data;
|
|
26
22
|
} catch (error) {
|
|
27
|
-
|
|
23
|
+
return error;
|
|
28
24
|
setHeader(event, "Content-Type", "application/xml");
|
|
29
25
|
return `<?xml version="1.0"?>
|
|
30
26
|
<error>File not found</error>`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineEventHandler } from "h3";
|
|
2
|
+
import { flowrixS3 } from "../../../middleware/flowrixs3.js";
|
|
3
|
+
import { useRuntimeConfig } from "#imports";
|
|
4
|
+
export default defineEventHandler(async (event) => {
|
|
5
|
+
const slug = event.context.params?._;
|
|
6
|
+
const config = useRuntimeConfig();
|
|
7
|
+
const endpoint = `_global_configurations/${slug}`;
|
|
8
|
+
try {
|
|
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
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, readBody, setResponseStatus } from "h3";
|
|
2
|
-
import { flowrixApi } from "../../middleware/flowrix.js";
|
|
3
|
-
import { useRuntimeConfig } from "#imports";
|
|
4
|
-
export default defineEventHandler(async (event) => {
|
|
5
|
-
try {
|
|
6
|
-
const body = await readBody(event);
|
|
7
|
-
const config = useRuntimeConfig();
|
|
8
|
-
const rawCookies = event.req.headers.cookie || "";
|
|
9
|
-
const apiConfig = {
|
|
10
|
-
...config,
|
|
11
|
-
cookies: rawCookies
|
|
12
|
-
};
|
|
13
|
-
const options = {
|
|
14
|
-
headers: {
|
|
15
|
-
"x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
|
|
16
|
-
},
|
|
17
|
-
body: JSON.stringify(body)
|
|
18
|
-
};
|
|
19
|
-
const location = await flowrixApi.post(`ip/location`, apiConfig, options);
|
|
20
|
-
return location;
|
|
21
|
-
} catch (error) {
|
|
22
|
-
setResponseStatus(event, 500);
|
|
23
|
-
return { success: false, error: error.message };
|
|
24
|
-
}
|
|
25
|
-
});
|
|
@@ -1,55 +1,25 @@
|
|
|
1
|
-
import { defineEventHandler, getRouterParam,
|
|
2
|
-
import {
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { flowrixApi } from "../../../../middleware/flowrix.js";
|
|
1
|
+
import { defineEventHandler, getRouterParam, createError } from "h3";
|
|
2
|
+
import { flowrixS3 } from "../../../../middleware/flowrixs3.js";
|
|
5
3
|
import { useRuntimeConfig } from "#imports";
|
|
6
|
-
const CACHE_DIR = join("/tmp", ".cache", "nitro", "navigation");
|
|
7
|
-
export const menuCache = /* @__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
5
|
const slug = getRouterParam(event, "id");
|
|
17
|
-
const
|
|
18
|
-
let query = getQuery(event);
|
|
6
|
+
const config = useRuntimeConfig();
|
|
19
7
|
if (!slug) {
|
|
20
8
|
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
21
9
|
}
|
|
22
10
|
if (!/^[a-zA-Z0-9-_]+$/.test(slug)) {
|
|
23
11
|
}
|
|
24
|
-
const
|
|
25
|
-
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
26
|
-
const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
|
|
12
|
+
const endpoint = `nav/${slug}/links`;
|
|
27
13
|
try {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
} catch (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
...config,
|
|
38
|
-
cookies: rawCookies
|
|
39
|
-
};
|
|
40
|
-
const options = {
|
|
41
|
-
headers: {
|
|
42
|
-
"x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
|
|
43
|
-
}
|
|
14
|
+
const s3Data = await flowrixS3.get(endpoint, config);
|
|
15
|
+
console.log("Loaded from S3:", endpoint);
|
|
16
|
+
return s3Data;
|
|
17
|
+
} catch (s3Error) {
|
|
18
|
+
console.log("S3 fetch failed:", s3Error.message);
|
|
19
|
+
return {
|
|
20
|
+
status: "Error",
|
|
21
|
+
message: "File not found",
|
|
22
|
+
error: s3Error.message
|
|
44
23
|
};
|
|
45
|
-
const menu = await flowrixApi.get(`nav/${slug}/links`, apiConfig, options);
|
|
46
|
-
if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
|
|
47
|
-
await ensureCacheDir();
|
|
48
|
-
await writeFile(filePath, JSON.stringify(menu, null, 2), "utf-8");
|
|
49
|
-
}
|
|
50
|
-
return menu;
|
|
51
|
-
} catch (error) {
|
|
52
|
-
setResponseStatus(event, 500);
|
|
53
|
-
return { success: false, error: error.message };
|
|
54
24
|
}
|
|
55
25
|
});
|
|
@@ -1,53 +1,23 @@
|
|
|
1
|
-
import { defineEventHandler,
|
|
2
|
-
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
3
|
-
import { join } from "path";
|
|
1
|
+
import { defineEventHandler, createError } from "h3";
|
|
4
2
|
import { useRuntimeConfig } from "#imports";
|
|
5
|
-
import {
|
|
6
|
-
const CACHE_DIR = join("/tmp", ".cache", "nitro", "pages");
|
|
7
|
-
export const pageCache = /* @__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 slug = event.context.params
|
|
17
|
-
const
|
|
18
|
-
const query = getQuery(event);
|
|
5
|
+
const slug = event.context.params?._;
|
|
6
|
+
const config = useRuntimeConfig();
|
|
19
7
|
if (!slug) {
|
|
20
8
|
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
21
9
|
}
|
|
22
|
-
const
|
|
23
|
-
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
24
|
-
const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
|
|
10
|
+
const endpoint = `page/${slug}`;
|
|
25
11
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
} catch (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...config,
|
|
36
|
-
cookies: rawCookies
|
|
37
|
-
};
|
|
38
|
-
const options = {
|
|
39
|
-
headers: {
|
|
40
|
-
"x-api-secret": apiConfig?.FLOWRIX_API_SECRET || ""
|
|
41
|
-
}
|
|
12
|
+
const s3Data = await flowrixS3.get(endpoint, config);
|
|
13
|
+
console.log("Loaded from S3:", endpoint);
|
|
14
|
+
return s3Data;
|
|
15
|
+
} catch (s3Error) {
|
|
16
|
+
console.log("S3 fetch failed:", s3Error.message);
|
|
17
|
+
return {
|
|
18
|
+
status: "Error",
|
|
19
|
+
message: "File not found",
|
|
20
|
+
error: s3Error.message
|
|
42
21
|
};
|
|
43
|
-
const page = await flowrixApi.get(`page/${slug}`, apiConfig, options);
|
|
44
|
-
if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
|
|
45
|
-
await ensureCacheDir();
|
|
46
|
-
await writeFile(filePath, JSON.stringify(page, null, 2), "utf-8");
|
|
47
|
-
}
|
|
48
|
-
return page;
|
|
49
|
-
} catch (error) {
|
|
50
|
-
setResponseStatus(event, 500);
|
|
51
|
-
return { success: false, error: error.message };
|
|
52
22
|
}
|
|
53
23
|
});
|