flowrix 1.0.1-beta.8 → 1.0.1-beta.81
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 +94 -29
- 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 +36 -28
- package/dist/runtime/composables/Checkout/{useBillingAddress.d.ts → useCheckoutBillingAddress.d.ts} +6 -6
- package/dist/runtime/composables/Checkout/{useBillingAddress.js → useCheckoutBillingAddress.js} +6 -1
- package/dist/runtime/composables/Checkout/{useShippingAddress.d.ts → useCheckoutShippingAddress.d.ts} +1 -1
- package/dist/runtime/composables/Checkout/{useShippingAddress.js → useCheckoutShippingAddress.js} +7 -2
- 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/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 +15 -12
- package/dist/runtime/composables/index.js +15 -12
- package/dist/runtime/composables/useAddresses.js +6 -6
- package/dist/runtime/composables/useCards.js +2 -2
- 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/plugin.d.ts +1 -1
- package/dist/runtime/server/api/albums.js +1 -1
- 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 +2 -2
- package/dist/runtime/server/api/brand/{[slug].js → [...slug].js} +17 -17
- package/dist/runtime/server/api/brand/index.d.ts +2 -0
- package/dist/runtime/server/api/brand/index.js +23 -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.js +1 -1
- package/dist/runtime/server/api/cart/[slug]/update.js +1 -1
- package/dist/runtime/server/api/cart/related.d.ts +2 -0
- 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.js +1 -1
- package/dist/runtime/server/api/catalog/categories.js +5 -4
- package/dist/runtime/server/api/catalog/categoriesall.d.ts +3 -0
- package/dist/runtime/server/api/catalog/categoriesall.js +44 -0
- package/dist/runtime/server/api/catalog/featured.js +5 -4
- package/dist/runtime/server/api/catalog/samples.js +5 -4
- package/dist/runtime/server/api/catalog/search.js +5 -4
- package/dist/runtime/server/api/category/[...slug].js +18 -14
- package/dist/runtime/server/api/checkout/applyCoupon.js +1 -1
- package/dist/runtime/server/api/checkout/configs.d.ts +1 -1
- package/dist/runtime/server/api/checkout/configs.js +10 -11
- package/dist/runtime/server/api/checkout/countries.js +1 -1
- package/dist/runtime/server/api/checkout/paymentmethod.js +7 -7
- 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} +7 -9
- package/dist/runtime/server/api/{blog/blog.js → cmspost/all.js} +2 -2
- 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.js +1 -1
- package/dist/runtime/server/api/contact-center/webforms/create.js +1 -1
- package/dist/runtime/server/api/countries.d.ts +2 -0
- package/dist/runtime/server/api/countries.js +35 -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 +2 -0
- package/dist/runtime/server/api/featured.js +16 -0
- package/dist/runtime/server/api/location.js +1 -1
- package/dist/runtime/server/api/nav/[id]/links.js +1 -1
- package/dist/runtime/server/api/page/{[slug].js → [...slug].js} +6 -8
- package/dist/runtime/server/api/product/[...slug].js +8 -5
- package/dist/runtime/server/api/quickview/[slug].d.ts +2 -0
- package/dist/runtime/server/api/quickview/[slug].js +16 -0
- package/dist/runtime/server/api/samples.d.ts +3 -0
- package/dist/runtime/server/api/samples.js +20 -0
- package/dist/runtime/server/api/search.d.ts +3 -0
- package/dist/runtime/server/api/search.js +15 -0
- package/dist/runtime/server/api/service/[slug].js +5 -4
- package/dist/runtime/server/api/service/availability.js +1 -1
- package/dist/runtime/server/api/service/getall.d.ts +3 -0
- package/dist/runtime/server/api/service/getall.js +52 -0
- package/dist/runtime/server/api/shop.d.ts +3 -0
- package/dist/runtime/server/api/shop.js +15 -0
- package/dist/runtime/server/api/subscribe.js +1 -1
- package/dist/runtime/server/api/v2/[...slug].js +3 -1
- package/dist/runtime/server/api/webform.d.ts +3 -0
- package/dist/runtime/server/api/webform.js +16 -0
- package/dist/runtime/stores/Cart.d.ts +12 -0
- package/dist/runtime/stores/Cart.js +50 -16
- package/dist/runtime/stores/Checkout.d.ts +9 -15
- package/dist/runtime/stores/Checkout.js +19 -5
- 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 +5 -0
- package/dist/runtime/utils/htmlCache.js +60 -0
- package/dist/types.d.mts +6 -2
- package/package.json +32 -20
- 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/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/{blog/blog.d.ts → cmspost/all.d.ts} +0 -0
- /package/dist/runtime/server/api/page/{[slug].d.ts → [...slug].d.ts} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineEventHandler, setResponseStatus, readBody, getMethod } from "h3";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
const method = getMethod(event);
|
|
5
|
+
const body = method === "POST" ? await readBody(event) : void 0;
|
|
6
|
+
try {
|
|
7
|
+
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}checkout/quotation/customer`, {
|
|
8
|
+
method,
|
|
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 response;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
setResponseStatus(event, 500);
|
|
19
|
+
return { success: false, error: error.message };
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineEventHandler, setResponseStatus, readBody, getCookie, getRouterParam } 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
|
+
const accessTok = getCookie(event, "authToken");
|
|
7
|
+
try {
|
|
8
|
+
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}mystore/customer/checkout/quotation/${slug}`, {
|
|
9
|
+
method: "POST",
|
|
10
|
+
headers: {
|
|
11
|
+
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
12
|
+
"x-api-secret": process.env.FLOWRIX_API_SECRET || "",
|
|
13
|
+
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
14
|
+
"Authorization": `Bearer ${accessTok || ""}`
|
|
15
|
+
},
|
|
16
|
+
body
|
|
17
|
+
});
|
|
18
|
+
return response;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
setResponseStatus(event, error.statusCode || 500);
|
|
21
|
+
return { success: false, error: error.message, data: error.data };
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineEventHandler,
|
|
1
|
+
import { defineEventHandler, getQuery, createError, readBody, getCookie } from "h3";
|
|
2
2
|
import { $fetch } from "ofetch";
|
|
3
3
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
4
|
import { join } from "path";
|
|
5
|
-
const CACHE_DIR = join(
|
|
5
|
+
const CACHE_DIR = join("/tmp", ".cache", "nitro", "blogs");
|
|
6
6
|
export const blogCache = /* @__PURE__ */ new Map();
|
|
7
7
|
async function ensureCacheDir() {
|
|
8
8
|
try {
|
|
@@ -12,18 +12,16 @@ async function ensureCacheDir() {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export default defineEventHandler(async (event) => {
|
|
15
|
-
const slug =
|
|
15
|
+
const slug = event.context.params._;
|
|
16
|
+
const customerType = getCookie(event, "customertype") || "";
|
|
16
17
|
const query = getQuery(event);
|
|
17
18
|
const body = await readBody(event);
|
|
18
19
|
if (!slug) {
|
|
19
20
|
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
20
21
|
}
|
|
21
|
-
if (!/^[a-zA-Z0-9-_]+$/.test(slug)) {
|
|
22
|
-
throw createError({ statusCode: 400, statusMessage: "Invalid slug" });
|
|
23
|
-
}
|
|
24
22
|
const cacheKey = `${slug}-${JSON.stringify(query)}`;
|
|
25
23
|
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
26
|
-
const filePath = join(CACHE_DIR, `${fileName}.json`);
|
|
24
|
+
const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
|
|
27
25
|
try {
|
|
28
26
|
const fileContent = await readFile(filePath, "utf-8");
|
|
29
27
|
const blog = JSON.parse(fileContent);
|
|
@@ -31,9 +29,9 @@ export default defineEventHandler(async (event) => {
|
|
|
31
29
|
} catch (error) {
|
|
32
30
|
}
|
|
33
31
|
try {
|
|
34
|
-
const blog = await $fetch(`${process.env.FLOWRIX_API_BASE}
|
|
32
|
+
const blog = await $fetch(`${process.env.FLOWRIX_API_BASE}post/${slug}`, {
|
|
35
33
|
headers: {
|
|
36
|
-
"x-
|
|
34
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
37
35
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
38
36
|
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
39
37
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineEventHandler, getRouterParam } from "h3";
|
|
1
|
+
import { defineEventHandler, getQuery, getRouterParam } from "h3";
|
|
2
2
|
import { $fetch } from "ofetch";
|
|
3
3
|
export const Page = /* @__PURE__ */ new Map();
|
|
4
4
|
export default defineEventHandler(async (event) => {
|
|
@@ -7,7 +7,7 @@ export default defineEventHandler(async (event) => {
|
|
|
7
7
|
const page = await $fetch(`${process.env.FLOWRIX_API_BASE}posts`, {
|
|
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,15 +1,15 @@
|
|
|
1
1
|
import { defineEventHandler, setResponseStatus } 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
|
try {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
6
|
+
const config = useRuntimeConfig();
|
|
7
|
+
const rawCookies = event.req.headers.cookie || "";
|
|
8
|
+
const apiConfig = {
|
|
9
|
+
...config,
|
|
10
|
+
cookies: rawCookies
|
|
11
|
+
};
|
|
12
|
+
const companyProfile = await flowrixApi.get(`company/profile`, apiConfig);
|
|
13
13
|
return companyProfile;
|
|
14
14
|
} catch (error) {
|
|
15
15
|
setResponseStatus(event, 500);
|
|
@@ -8,7 +8,7 @@ export default defineEventHandler(async (event) => {
|
|
|
8
8
|
}
|
|
9
9
|
const webform = await $fetch(`${process.env.FLOWRIX_API_BASE}contact-center/webforms/${id}/details`, {
|
|
10
10
|
headers: {
|
|
11
|
-
"x-
|
|
11
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
12
12
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
13
13
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
14
14
|
"Content-Type": "application/json"
|
|
@@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
|
|
|
5
5
|
const webform = await $fetch(`${process.env.FLOWRIX_API_BASE}contact-center/webforms/create`, {
|
|
6
6
|
method: "POST",
|
|
7
7
|
headers: {
|
|
8
|
-
"x-
|
|
8
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
9
9
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
10
10
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
11
11
|
"Content-Type": "application/json"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineEventHandler, 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", "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
|
+
export default defineEventHandler(async (event) => {
|
|
15
|
+
const filePath = join(CACHE_DIR, `countries.json`);
|
|
16
|
+
try {
|
|
17
|
+
const fileContent = await readFile(filePath, "utf-8");
|
|
18
|
+
const countries = JSON.parse(fileContent);
|
|
19
|
+
return countries;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const config = useRuntimeConfig();
|
|
24
|
+
const countries = await flowrixApi.get(`countries`, config);
|
|
25
|
+
await ensureCacheDir();
|
|
26
|
+
await writeFile(filePath, JSON.stringify(countries, null, 2), "utf-8");
|
|
27
|
+
return countries;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw createError({
|
|
30
|
+
statusCode: 500,
|
|
31
|
+
statusMessage: `Failed to fetch countires `,
|
|
32
|
+
data: error.message
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
|
|
6
6
|
const responseData = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/address/add`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-
|
|
9
|
+
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
10
10
|
"x-api-secret": process.env.FLOWRIX_API_SECRET || "",
|
|
11
11
|
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
12
12
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery } from "h3";
|
|
1
|
+
import { defineEventHandler, getQuery, getCookie } from "h3";
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
const { addressId } = getQuery(event);
|
|
@@ -13,7 +13,7 @@ export default defineEventHandler(async (event) => {
|
|
|
13
13
|
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/address/${addressId}/delete`, {
|
|
14
14
|
method: "PATCH",
|
|
15
15
|
headers: {
|
|
16
|
-
"x-
|
|
16
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
17
17
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
18
18
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
19
19
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
@@ -13,7 +13,7 @@ export default defineEventHandler(async (event) => {
|
|
|
13
13
|
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/address/${addressId}/setshipping`, {
|
|
14
14
|
method: "POST",
|
|
15
15
|
headers: {
|
|
16
|
-
"x-
|
|
16
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
17
17
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
18
18
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
19
19
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -15,7 +15,7 @@ export default defineEventHandler(async (event) => {
|
|
|
15
15
|
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/address/${addressId}/update`, {
|
|
16
16
|
method: "PATCH",
|
|
17
17
|
headers: {
|
|
18
|
-
"x-
|
|
18
|
+
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
19
19
|
"x-api-secret": process.env.FLOWRIX_API_SECRET || "",
|
|
20
20
|
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
21
21
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
1
|
+
import { defineEventHandler, getCookie } from "h3";
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
const { cardId } = getQuery(event);
|
|
@@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
|
|
6
6
|
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/cards/${cardId}`, {
|
|
7
7
|
method: "DELETE",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-
|
|
9
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
10
10
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
11
11
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
12
12
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
1
|
+
import { defineEventHandler, getCookie } from "h3";
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
try {
|
|
5
5
|
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/cards`, {
|
|
6
6
|
headers: {
|
|
7
|
-
"x-
|
|
7
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
8
8
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
9
9
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
10
10
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineEventHandler, readBody } from "h3";
|
|
1
|
+
import { defineEventHandler, readBody, getCookie } from "h3";
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
const body = await readBody(event);
|
|
@@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
|
|
6
6
|
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/change-password`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-
|
|
9
|
+
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
10
10
|
"x-api-secret": process.env.FLOWRIX_API_SECRET || "",
|
|
11
11
|
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
12
12
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
|
|
6
6
|
const checkoutResponse = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/checkout`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-
|
|
9
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
10
10
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
11
11
|
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
12
12
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
1
|
+
import { defineEventHandler, getCookie } from "h3";
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
try {
|
|
5
5
|
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/orders`, {
|
|
6
6
|
headers: {
|
|
7
|
-
"x-
|
|
7
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
8
8
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
9
9
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
10
10
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
@@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
|
|
6
6
|
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/profile/update`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-
|
|
9
|
+
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
10
10
|
"x-api-secret": process.env.FLOWRIX_API_SECRET || "",
|
|
11
11
|
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
12
12
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
1
|
+
import { defineEventHandler, getCookie } from "h3";
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
try {
|
|
5
5
|
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/quotations`, {
|
|
6
6
|
headers: {
|
|
7
|
-
"x-
|
|
7
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
8
8
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
9
9
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
10
10
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
@@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
|
|
|
5
5
|
const search = await $fetch(`${process.env.FLOWRIX_API_BASE}customers/search`, {
|
|
6
6
|
method: "POST",
|
|
7
7
|
headers: {
|
|
8
|
-
"x-
|
|
8
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
9
9
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
10
10
|
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
11
11
|
},
|
|
@@ -11,7 +11,7 @@ export default defineEventHandler(async (event) => {
|
|
|
11
11
|
`${process.env.FLOWRIX_API_BASE}customer/orders/${orderNo}/tax-invoice`,
|
|
12
12
|
{
|
|
13
13
|
headers: {
|
|
14
|
-
"x-
|
|
14
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
15
15
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
16
16
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
17
17
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
@@ -7,7 +7,7 @@ export default defineEventHandler(async (event) => {
|
|
|
7
7
|
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/wishlist/${listId}/${productSlug}/add`, {
|
|
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
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
|
|
6
6
|
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/wishlist/add`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-
|
|
9
|
+
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
10
10
|
"x-api-secret": process.env.FLOWRIX_API_SECRET || "",
|
|
11
11
|
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
12
12
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -15,7 +15,7 @@ export default defineEventHandler(async (event) => {
|
|
|
15
15
|
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/wishlist/${listId}/item/delete`, {
|
|
16
16
|
method: "POST",
|
|
17
17
|
headers: {
|
|
18
|
-
"x-
|
|
18
|
+
"x-public-key": process.env.FLOWRIX_API_KEY || "",
|
|
19
19
|
"x-api-secret": process.env.FLOWRIX_API_SECRET || "",
|
|
20
20
|
"Origin": process.env.FLOWRIX_API_ORIGIN || "",
|
|
21
21
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -7,7 +7,7 @@ export default defineEventHandler(async (event) => {
|
|
|
7
7
|
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/wishlist/${id}/delete`, {
|
|
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
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
1
|
+
import { defineEventHandler, getCookie } from "h3";
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
try {
|
|
5
5
|
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}customer/wishlist`, {
|
|
6
6
|
headers: {
|
|
7
|
-
"x-
|
|
7
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
8
8
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
9
9
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
10
10
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
@@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
|
|
6
6
|
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/wishlist/${listId}/products`, {
|
|
7
7
|
method: "GET",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-
|
|
9
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
10
10
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
11
11
|
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
12
12
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineEventHandler, readBody } from "h3";
|
|
1
|
+
import { defineEventHandler, readBody, getCookie } from "h3";
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const body = await readBody(event);
|
|
4
4
|
const accessTok = getCookie(event, "auth.token");
|
|
@@ -7,7 +7,7 @@ export default defineEventHandler(async (event) => {
|
|
|
7
7
|
const response = await fetch(`${process.env.FLOWRIX_API_BASE}customer/wishlist/${id}/update`, {
|
|
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
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineEventHandler, getCookie } from "h3";
|
|
2
|
+
export default defineEventHandler(async (event) => {
|
|
3
|
+
const accessTok = getCookie(event, "auth.token");
|
|
4
|
+
try {
|
|
5
|
+
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}products/featured`, {
|
|
6
|
+
headers: {
|
|
7
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
8
|
+
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
9
|
+
"Origin": process.env.FLOWRIX_API_ORIGIN,
|
|
10
|
+
"Authorization": `Bearer ${accessTok || ""}`
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return response;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -4,7 +4,7 @@ export default defineEventHandler(async () => {
|
|
|
4
4
|
const location = await $fetch(`${process.env.FLOWRIX_API_BASE}ip/location`, {
|
|
5
5
|
method: "POST",
|
|
6
6
|
headers: {
|
|
7
|
-
"x-
|
|
7
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
8
8
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
9
9
|
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
10
10
|
}
|
|
@@ -6,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
|
|
6
6
|
const response = await $fetch(`${process.env.FLOWRIX_API_BASE}nav/${id}/links`, {
|
|
7
7
|
method: "GET",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-
|
|
9
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
10
10
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
11
11
|
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
12
12
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineEventHandler,
|
|
1
|
+
import { defineEventHandler, getQuery, createError, readBody, getCookie } from "h3";
|
|
2
2
|
import { $fetch } from "ofetch";
|
|
3
3
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
4
|
import { join } from "path";
|
|
5
|
-
const CACHE_DIR = join(
|
|
5
|
+
const CACHE_DIR = join("/tmp", ".cache", "nitro", "pages");
|
|
6
6
|
export const pageCache = /* @__PURE__ */ new Map();
|
|
7
7
|
async function ensureCacheDir() {
|
|
8
8
|
try {
|
|
@@ -12,18 +12,16 @@ async function ensureCacheDir() {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export default defineEventHandler(async (event) => {
|
|
15
|
-
const slug =
|
|
15
|
+
const slug = event.context.params._;
|
|
16
|
+
const customerType = getCookie(event, "customertype") || "";
|
|
16
17
|
const query = getQuery(event);
|
|
17
18
|
const body = await readBody(event);
|
|
18
19
|
if (!slug) {
|
|
19
20
|
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
20
21
|
}
|
|
21
|
-
if (!/^[a-zA-Z0-9-_]+$/.test(slug)) {
|
|
22
|
-
throw createError({ statusCode: 400, statusMessage: "Invalid slug" });
|
|
23
|
-
}
|
|
24
22
|
const cacheKey = `${slug}-${JSON.stringify(query)}`;
|
|
25
23
|
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
26
|
-
const filePath = join(CACHE_DIR, `${fileName}.json`);
|
|
24
|
+
const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
|
|
27
25
|
try {
|
|
28
26
|
const fileContent = await readFile(filePath, "utf-8");
|
|
29
27
|
const page = JSON.parse(fileContent);
|
|
@@ -33,7 +31,7 @@ export default defineEventHandler(async (event) => {
|
|
|
33
31
|
try {
|
|
34
32
|
const page = await $fetch(`${process.env.FLOWRIX_API_BASE}page/${slug}`, {
|
|
35
33
|
headers: {
|
|
36
|
-
"x-
|
|
34
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
37
35
|
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
38
36
|
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
39
37
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery, createError, readBody } from "h3";
|
|
1
|
+
import { defineEventHandler, getQuery, createError, readBody, getCookie } from "h3";
|
|
2
2
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
5
|
-
|
|
5
|
+
import { useRuntimeConfig } from "#imports";
|
|
6
|
+
const CACHE_DIR = join("/tmp", ".cache", "nitro", "products");
|
|
6
7
|
export const productCache = /* @__PURE__ */ new Map();
|
|
7
8
|
async function ensureCacheDir() {
|
|
8
9
|
try {
|
|
@@ -13,6 +14,7 @@ async function ensureCacheDir() {
|
|
|
13
14
|
}
|
|
14
15
|
export default defineEventHandler(async (event) => {
|
|
15
16
|
const slug = event.context.params._;
|
|
17
|
+
const customerType = getCookie(event, "customertype") || "";
|
|
16
18
|
const query = getQuery(event);
|
|
17
19
|
const body = await readBody(event);
|
|
18
20
|
if (!slug) {
|
|
@@ -20,7 +22,7 @@ export default defineEventHandler(async (event) => {
|
|
|
20
22
|
}
|
|
21
23
|
const cacheKey = `${slug}-${JSON.stringify(query)}`;
|
|
22
24
|
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
23
|
-
const filePath = join(CACHE_DIR, `${fileName}.json`);
|
|
25
|
+
const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
|
|
24
26
|
try {
|
|
25
27
|
const fileContent = await readFile(filePath, "utf-8");
|
|
26
28
|
const product = JSON.parse(fileContent);
|
|
@@ -28,9 +30,10 @@ export default defineEventHandler(async (event) => {
|
|
|
28
30
|
} catch (error) {
|
|
29
31
|
}
|
|
30
32
|
try {
|
|
31
|
-
const
|
|
33
|
+
const config = useRuntimeConfig();
|
|
34
|
+
const product = await flowrixApi.post(`product/${slug}`, config, {
|
|
32
35
|
body: JSON.stringify(body)
|
|
33
|
-
}
|
|
36
|
+
});
|
|
34
37
|
await ensureCacheDir();
|
|
35
38
|
await writeFile(filePath, JSON.stringify(product, null, 2), "utf-8");
|
|
36
39
|
return product;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam, 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
|
+
const page = await $fetch(`${process.env.FLOWRIX_API_BASE}quickview/${slug}`, {
|
|
7
|
+
method: "POST",
|
|
8
|
+
headers: {
|
|
9
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
10
|
+
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
11
|
+
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
12
|
+
},
|
|
13
|
+
body
|
|
14
|
+
});
|
|
15
|
+
return page;
|
|
16
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from "h3";
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
3
|
+
export const SamplesCache = /* @__PURE__ */ new Map();
|
|
4
|
+
export default defineEventHandler(async (event) => {
|
|
5
|
+
const query = getQuery(event);
|
|
6
|
+
const cacheKey = `samples-${JSON.stringify(query)}`;
|
|
7
|
+
if (SamplesCache.has(cacheKey)) {
|
|
8
|
+
return SamplesCache.get(cacheKey);
|
|
9
|
+
}
|
|
10
|
+
const samples = await $fetch(`${process.env.FLOWRIX_API_BASE}samples`, {
|
|
11
|
+
headers: {
|
|
12
|
+
"x-public-key": process.env.FLOWRIX_API_KEY,
|
|
13
|
+
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
14
|
+
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
15
|
+
},
|
|
16
|
+
params: query
|
|
17
|
+
});
|
|
18
|
+
SamplesCache.set(cacheKey, samples);
|
|
19
|
+
return samples;
|
|
20
|
+
});
|