flowrix 1.0.1-beta.136 → 1.0.1-beta.139
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 +11 -12
- package/dist/runtime/middleware/flowrix.js +6 -6
- package/dist/runtime/server/api/albums.js +2 -2
- package/dist/runtime/server/api/auth/forgot.js +3 -3
- package/dist/runtime/server/api/auth/login.js +3 -3
- package/dist/runtime/server/api/auth/logout.js +3 -3
- package/dist/runtime/server/api/auth/register.js +3 -3
- package/dist/runtime/server/api/auth/user/reset-password.js +3 -3
- package/dist/runtime/server/api/auth/user/session.js +3 -3
- package/dist/runtime/server/api/auth/user/verify-token.js +3 -3
- package/dist/runtime/server/api/banners.js +2 -2
- package/dist/runtime/server/api/brand/[...slug].js +2 -2
- package/dist/runtime/server/api/brand/index.js +1 -1
- package/dist/runtime/server/api/catalog/brands.js +2 -2
- package/dist/runtime/server/api/catalog/categories.js +2 -2
- package/dist/runtime/server/api/catalog/categoriesall.js +2 -2
- package/dist/runtime/server/api/catalog/featured.js +2 -2
- package/dist/runtime/server/api/catalog/posts.js +2 -2
- package/dist/runtime/server/api/catalog/samples.js +2 -2
- package/dist/runtime/server/api/catalog/search.js +2 -2
- package/dist/runtime/server/api/category/[...slug].js +2 -2
- package/dist/runtime/server/api/checkout/quotation/[slug].js +3 -3
- package/dist/runtime/server/api/checkout/quotation/guest/[slug].js +6 -6
- package/dist/runtime/server/api/checkout/quotation/guest/customer.js +3 -3
- package/dist/runtime/server/api/checkout/quotation/submit/[slug].js +3 -3
- package/dist/runtime/server/api/cmspost/[...slug].js +2 -2
- package/dist/runtime/server/api/cmspost/all.js +2 -2
- package/dist/runtime/server/api/company/profile.js +1 -1
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +2 -2
- package/dist/runtime/server/api/contact-center/webforms/create.js +1 -1
- package/dist/runtime/server/api/countries.js +2 -2
- package/dist/runtime/server/api/customer/address/add.js +3 -3
- package/dist/runtime/server/api/customer/address/delete.js +3 -3
- package/dist/runtime/server/api/customer/address/setshipping.js +3 -3
- package/dist/runtime/server/api/customer/address/update.js +3 -3
- package/dist/runtime/server/api/customer/cards/delete.js +3 -3
- package/dist/runtime/server/api/customer/cards/get.js +3 -3
- package/dist/runtime/server/api/customer/change-password.js +3 -3
- package/dist/runtime/server/api/customer/checkout.js +3 -3
- package/dist/runtime/server/api/customer/orders.js +3 -3
- package/dist/runtime/server/api/customer/profile/update.js +3 -3
- package/dist/runtime/server/api/customer/quotations.js +3 -3
- package/dist/runtime/server/api/customer/search.js +3 -3
- package/dist/runtime/server/api/customer/tax-invoice.js +3 -3
- package/dist/runtime/server/api/customer/wishlist/add.js +3 -3
- package/dist/runtime/server/api/customer/wishlist/createWishList.js +3 -3
- package/dist/runtime/server/api/customer/wishlist/deleteFromWishList.js +3 -3
- package/dist/runtime/server/api/customer/wishlist/deleteWishList.js +3 -3
- package/dist/runtime/server/api/customer/wishlist/get.js +3 -3
- package/dist/runtime/server/api/customer/wishlist/getWishListItems.js +3 -3
- package/dist/runtime/server/api/customer/wishlist/updateWishList.js +3 -3
- package/dist/runtime/server/api/featured.js +2 -2
- package/dist/runtime/server/api/generate/robots.get.js +1 -1
- package/dist/runtime/server/api/generate/sitemap.get.js +1 -1
- package/dist/runtime/server/api/location.js +1 -1
- package/dist/runtime/server/api/nav/[id]/links.js +2 -2
- package/dist/runtime/server/api/page/[...slug].js +2 -2
- package/dist/runtime/server/api/product/[...slug].js +2 -2
- package/dist/runtime/server/api/quickview/[slug].js +1 -1
- package/dist/runtime/server/api/reviews.js +1 -1
- package/dist/runtime/server/api/samples.js +2 -2
- package/dist/runtime/server/api/search.js +2 -2
- package/dist/runtime/server/api/service/[slug].js +2 -2
- package/dist/runtime/server/api/service/availability.js +1 -1
- package/dist/runtime/server/api/service/getall.js +2 -2
- package/dist/runtime/server/api/shop.js +2 -2
- package/dist/runtime/server/api/subscribe.js +1 -1
- package/dist/runtime/server/api/v2/[...slug].get.js +2 -2
- package/dist/runtime/server/api/webform.js +2 -2
- package/dist/runtime/utils/api.js +5 -5
- package/dist/runtime/utils/htmlCache.js +1 -1
- package/package.json +1 -1
|
@@ -3,11 +3,11 @@ export default defineEventHandler(async (event) => {
|
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
const body = await readBody(event);
|
|
5
5
|
try {
|
|
6
|
-
const response = await fetch(`${process.env.
|
|
6
|
+
const response = await fetch(`${process.env.BASE}customer/change-password`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-public-key": process.env.
|
|
10
|
-
"Origin": process.env.
|
|
9
|
+
"x-public-key": process.env.KEY || "",
|
|
10
|
+
"Origin": process.env.ORIGIN || "",
|
|
11
11
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
12
12
|
"Content-Type": "application/json",
|
|
13
13
|
"Accept": "application/json"
|
|
@@ -3,11 +3,11 @@ import { $fetch } from "ofetch";
|
|
|
3
3
|
export default defineEventHandler(async (event) => {
|
|
4
4
|
const body = await readBody(event);
|
|
5
5
|
try {
|
|
6
|
-
const checkoutResponse = await $fetch(`${process.env.
|
|
6
|
+
const checkoutResponse = await $fetch(`${process.env.BASE}customer/checkout`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-public-key": process.env.
|
|
10
|
-
"Origin": process.env.
|
|
9
|
+
"x-public-key": process.env.KEY,
|
|
10
|
+
"Origin": process.env.ORIGIN
|
|
11
11
|
},
|
|
12
12
|
body
|
|
13
13
|
});
|
|
@@ -2,10 +2,10 @@ import { defineEventHandler, getCookie } from "h3";
|
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
try {
|
|
5
|
-
const response = await $fetch(`${process.env.
|
|
5
|
+
const response = await $fetch(`${process.env.BASE}customer/orders`, {
|
|
6
6
|
headers: {
|
|
7
|
-
"x-public-key": process.env.
|
|
8
|
-
"Origin": process.env.
|
|
7
|
+
"x-public-key": process.env.KEY,
|
|
8
|
+
"Origin": process.env.ORIGIN,
|
|
9
9
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
10
10
|
}
|
|
11
11
|
});
|
|
@@ -3,11 +3,11 @@ export default defineEventHandler(async (event) => {
|
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
const body = await readBody(event);
|
|
5
5
|
try {
|
|
6
|
-
const response = await fetch(`${process.env.
|
|
6
|
+
const response = await fetch(`${process.env.BASE}customer/profile/update`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-public-key": process.env.
|
|
10
|
-
"Origin": process.env.
|
|
9
|
+
"x-public-key": process.env.KEY || "",
|
|
10
|
+
"Origin": process.env.ORIGIN || "",
|
|
11
11
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
12
12
|
"Content-Type": "application/json",
|
|
13
13
|
"Accept": "application/json"
|
|
@@ -2,10 +2,10 @@ import { defineEventHandler, getCookie } from "h3";
|
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
try {
|
|
5
|
-
const response = await $fetch(`${process.env.
|
|
5
|
+
const response = await $fetch(`${process.env.BASE}customer/quotations`, {
|
|
6
6
|
headers: {
|
|
7
|
-
"x-public-key": process.env.
|
|
8
|
-
"Origin": process.env.
|
|
7
|
+
"x-public-key": process.env.KEY,
|
|
8
|
+
"Origin": process.env.ORIGIN,
|
|
9
9
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
10
10
|
}
|
|
11
11
|
});
|
|
@@ -2,11 +2,11 @@ import { defineEventHandler, readBody } from "h3";
|
|
|
2
2
|
import { $fetch } from "ofetch";
|
|
3
3
|
export default defineEventHandler(async (event) => {
|
|
4
4
|
const body = await readBody(event);
|
|
5
|
-
const search = await $fetch(`${process.env.
|
|
5
|
+
const search = await $fetch(`${process.env.BASE}customers/search`, {
|
|
6
6
|
method: "POST",
|
|
7
7
|
headers: {
|
|
8
|
-
"x-public-key": process.env.
|
|
9
|
-
"Origin": process.env.
|
|
8
|
+
"x-public-key": process.env.KEY,
|
|
9
|
+
"Origin": process.env.ORIGIN
|
|
10
10
|
},
|
|
11
11
|
body
|
|
12
12
|
});
|
|
@@ -8,11 +8,11 @@ export default defineEventHandler(async (event) => {
|
|
|
8
8
|
}
|
|
9
9
|
try {
|
|
10
10
|
const apiRes = await fetch(
|
|
11
|
-
`${process.env.
|
|
11
|
+
`${process.env.BASE}customer/orders/${orderNo}/tax-invoice`,
|
|
12
12
|
{
|
|
13
13
|
headers: {
|
|
14
|
-
"x-public-key": process.env.
|
|
15
|
-
"Origin": process.env.
|
|
14
|
+
"x-public-key": process.env.KEY,
|
|
15
|
+
"Origin": process.env.ORIGIN,
|
|
16
16
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -4,11 +4,11 @@ export default defineEventHandler(async (event) => {
|
|
|
4
4
|
const body = await readBody(event);
|
|
5
5
|
const { listId, productSlug } = getQuery(event);
|
|
6
6
|
try {
|
|
7
|
-
const response = await fetch(`${process.env.
|
|
7
|
+
const response = await fetch(`${process.env.BASE}customer/wishlist/${listId}/${productSlug}/add`, {
|
|
8
8
|
method: "POST",
|
|
9
9
|
headers: {
|
|
10
|
-
"x-public-key": process.env.
|
|
11
|
-
"Origin": process.env.
|
|
10
|
+
"x-public-key": process.env.KEY || "",
|
|
11
|
+
"Origin": process.env.ORIGIN || "",
|
|
12
12
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
13
13
|
"Content-Type": "application/json",
|
|
14
14
|
"Accept": "application/json"
|
|
@@ -3,11 +3,11 @@ export default defineEventHandler(async (event) => {
|
|
|
3
3
|
const body = await readBody(event);
|
|
4
4
|
const accessTok = getCookie(event, "auth.token");
|
|
5
5
|
try {
|
|
6
|
-
const response = await fetch(`${process.env.
|
|
6
|
+
const response = await fetch(`${process.env.BASE}customer/wishlist/add`, {
|
|
7
7
|
method: "POST",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-public-key": process.env.
|
|
10
|
-
"Origin": process.env.
|
|
9
|
+
"x-public-key": process.env.KEY || "",
|
|
10
|
+
"Origin": process.env.ORIGIN || "",
|
|
11
11
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
12
12
|
"Content-Type": "application/json",
|
|
13
13
|
"Accept": "application/json"
|
|
@@ -12,11 +12,11 @@ export default defineEventHandler(async (event) => {
|
|
|
12
12
|
message: "Missing listId in query or productSlug in body"
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
const response = await fetch(`${process.env.
|
|
15
|
+
const response = await fetch(`${process.env.BASE}customer/wishlist/${listId}/item/delete`, {
|
|
16
16
|
method: "POST",
|
|
17
17
|
headers: {
|
|
18
|
-
"x-public-key": process.env.
|
|
19
|
-
"Origin": process.env.
|
|
18
|
+
"x-public-key": process.env.KEY || "",
|
|
19
|
+
"Origin": process.env.ORIGIN || "",
|
|
20
20
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
"Accept": "application/json"
|
|
@@ -4,11 +4,11 @@ export default defineEventHandler(async (event) => {
|
|
|
4
4
|
const accessTok = getCookie(event, "auth.token");
|
|
5
5
|
try {
|
|
6
6
|
const { id } = body;
|
|
7
|
-
const response = await fetch(`${process.env.
|
|
7
|
+
const response = await fetch(`${process.env.BASE}customer/wishlist/${id}/delete`, {
|
|
8
8
|
method: "POST",
|
|
9
9
|
headers: {
|
|
10
|
-
"x-public-key": process.env.
|
|
11
|
-
"Origin": process.env.
|
|
10
|
+
"x-public-key": process.env.KEY || "",
|
|
11
|
+
"Origin": process.env.ORIGIN || "",
|
|
12
12
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
13
13
|
"Content-Type": "application/json",
|
|
14
14
|
"Accept": "application/json"
|
|
@@ -2,10 +2,10 @@ import { defineEventHandler, getCookie } from "h3";
|
|
|
2
2
|
export default defineEventHandler(async (event) => {
|
|
3
3
|
const accessTok = getCookie(event, "auth.token");
|
|
4
4
|
try {
|
|
5
|
-
const response = await $fetch(`${process.env.
|
|
5
|
+
const response = await $fetch(`${process.env.BASE}customer/wishlist`, {
|
|
6
6
|
headers: {
|
|
7
|
-
"x-public-key": process.env.
|
|
8
|
-
"Origin": process.env.
|
|
7
|
+
"x-public-key": process.env.KEY,
|
|
8
|
+
"Origin": process.env.ORIGIN,
|
|
9
9
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
10
10
|
}
|
|
11
11
|
});
|
|
@@ -3,11 +3,11 @@ export default defineEventHandler(async (event) => {
|
|
|
3
3
|
const { listId } = getQuery(event);
|
|
4
4
|
const accessTok = getCookie(event, "auth.token");
|
|
5
5
|
try {
|
|
6
|
-
const response = await fetch(`${process.env.
|
|
6
|
+
const response = await fetch(`${process.env.BASE}customer/wishlist/${listId}/products`, {
|
|
7
7
|
method: "GET",
|
|
8
8
|
headers: {
|
|
9
|
-
"x-public-key": process.env.
|
|
10
|
-
"Origin": process.env.
|
|
9
|
+
"x-public-key": process.env.KEY,
|
|
10
|
+
"Origin": process.env.ORIGIN,
|
|
11
11
|
"Authorization": `Bearer ${accessTok || ""}`
|
|
12
12
|
}
|
|
13
13
|
});
|
|
@@ -4,11 +4,11 @@ export default defineEventHandler(async (event) => {
|
|
|
4
4
|
const accessTok = getCookie(event, "auth.token");
|
|
5
5
|
try {
|
|
6
6
|
const { id } = body;
|
|
7
|
-
const response = await fetch(`${process.env.
|
|
7
|
+
const response = await fetch(`${process.env.BASE}customer/wishlist/${id}/update`, {
|
|
8
8
|
method: "POST",
|
|
9
9
|
headers: {
|
|
10
|
-
"x-public-key": process.env.
|
|
11
|
-
"Origin": process.env.
|
|
10
|
+
"x-public-key": process.env.KEY || "",
|
|
11
|
+
"Origin": process.env.ORIGIN || "",
|
|
12
12
|
"Authorization": `Bearer ${accessTok || ""}`,
|
|
13
13
|
"Content-Type": "application/json",
|
|
14
14
|
"Accept": "application/json"
|
|
@@ -35,12 +35,12 @@ export default defineEventHandler(async (event) => {
|
|
|
35
35
|
};
|
|
36
36
|
const options = {
|
|
37
37
|
headers: {
|
|
38
|
-
"x-api-secret": apiConfig?.
|
|
38
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
39
39
|
},
|
|
40
40
|
query
|
|
41
41
|
};
|
|
42
42
|
const featured = await flowrixApi.get(`products/featured`, apiConfig, options);
|
|
43
|
-
if (config.
|
|
43
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
44
44
|
await ensureCacheDir();
|
|
45
45
|
await writeFile(filePath, JSON.stringify(featured, null, 2), "utf-8");
|
|
46
46
|
}
|
|
@@ -8,7 +8,7 @@ import { $fetch } from "ofetch";
|
|
|
8
8
|
export default defineEventHandler(async (event) => {
|
|
9
9
|
try {
|
|
10
10
|
const config = useRuntimeConfig();
|
|
11
|
-
const fileUrl = config.
|
|
11
|
+
const fileUrl = config.CDN + "robots.txt";
|
|
12
12
|
const fileContent = await $fetch(fileUrl);
|
|
13
13
|
setHeader(event, "Content-Type", "text/plain; charset=utf-8");
|
|
14
14
|
return fileContent;
|
|
@@ -13,7 +13,7 @@ export default defineEventHandler(async (event) => {
|
|
|
13
13
|
}
|
|
14
14
|
const isGzip = fullPath.endsWith(".gz");
|
|
15
15
|
const config = useRuntimeConfig();
|
|
16
|
-
const cdnUrl = config.
|
|
16
|
+
const cdnUrl = config.CDN + "sitemaps/" + fullPath;
|
|
17
17
|
const buffer = await $fetch(cdnUrl, { responseType: "arrayBuffer" });
|
|
18
18
|
const data = Buffer.from(buffer);
|
|
19
19
|
if (isGzip) {
|
|
@@ -39,11 +39,11 @@ export default defineEventHandler(async (event) => {
|
|
|
39
39
|
};
|
|
40
40
|
const options = {
|
|
41
41
|
headers: {
|
|
42
|
-
"x-api-secret": apiConfig?.
|
|
42
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
const menu = await flowrixApi.get(`nav/${slug}/links`, apiConfig, options);
|
|
46
|
-
if (config.
|
|
46
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
47
47
|
await ensureCacheDir();
|
|
48
48
|
await writeFile(filePath, JSON.stringify(menu, null, 2), "utf-8");
|
|
49
49
|
}
|
|
@@ -38,11 +38,11 @@ export default defineEventHandler(async (event) => {
|
|
|
38
38
|
};
|
|
39
39
|
const options = {
|
|
40
40
|
headers: {
|
|
41
|
-
"x-api-secret": apiConfig?.
|
|
41
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
const page = await flowrixApi.get(`page/${slug}`, apiConfig, options);
|
|
45
|
-
if (config.
|
|
45
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
46
46
|
await ensureCacheDir();
|
|
47
47
|
await writeFile(filePath, JSON.stringify(page, null, 2), "utf-8");
|
|
48
48
|
}
|
|
@@ -41,13 +41,13 @@ export default defineEventHandler(async (event) => {
|
|
|
41
41
|
};
|
|
42
42
|
const options = {
|
|
43
43
|
headers: {
|
|
44
|
-
"x-api-secret": apiConfig?.
|
|
44
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
45
45
|
},
|
|
46
46
|
query,
|
|
47
47
|
body: JSON.stringify(body)
|
|
48
48
|
};
|
|
49
49
|
const product = await flowrixApi.post(`product/${slug}`, apiConfig, options);
|
|
50
|
-
if (config.
|
|
50
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
51
51
|
await ensureCacheDir();
|
|
52
52
|
await writeFile(filePath, JSON.stringify(product, null, 2), "utf-8");
|
|
53
53
|
}
|
|
@@ -11,7 +11,7 @@ export default defineEventHandler(async (event) => {
|
|
|
11
11
|
};
|
|
12
12
|
const options = {
|
|
13
13
|
headers: {
|
|
14
|
-
"x-api-secret": apiConfig?.
|
|
14
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
const reviews = await flowrixApi.get(`reviews`, apiConfig, options);
|
|
@@ -36,12 +36,12 @@ export default defineEventHandler(async (event) => {
|
|
|
36
36
|
};
|
|
37
37
|
const options = {
|
|
38
38
|
headers: {
|
|
39
|
-
"x-api-secret": apiConfig?.
|
|
39
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
40
40
|
},
|
|
41
41
|
query
|
|
42
42
|
};
|
|
43
43
|
const samples = await flowrixApi.get(`samples`, apiConfig, options);
|
|
44
|
-
if (config.
|
|
44
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
45
45
|
await ensureCacheDir();
|
|
46
46
|
await writeFile(filePath, JSON.stringify(samples, null, 2), "utf-8");
|
|
47
47
|
}
|
|
@@ -36,12 +36,12 @@ export default defineEventHandler(async (event) => {
|
|
|
36
36
|
};
|
|
37
37
|
const options = {
|
|
38
38
|
headers: {
|
|
39
|
-
"x-api-secret": apiConfig?.
|
|
39
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
40
40
|
},
|
|
41
41
|
query
|
|
42
42
|
};
|
|
43
43
|
const search = await flowrixApi.get(`search`, apiConfig, options);
|
|
44
|
-
if (config.
|
|
44
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
45
45
|
await ensureCacheDir();
|
|
46
46
|
await writeFile(filePath, JSON.stringify(search, null, 2), "utf-8");
|
|
47
47
|
}
|
|
@@ -41,11 +41,11 @@ export default defineEventHandler(async (event) => {
|
|
|
41
41
|
};
|
|
42
42
|
const options = {
|
|
43
43
|
headers: {
|
|
44
|
-
"x-api-secret": apiConfig?.
|
|
44
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
const service = await flowrixApi.get(`services/${slug}`, apiConfig, options);
|
|
48
|
-
if (config.
|
|
48
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
49
49
|
await ensureCacheDir();
|
|
50
50
|
await writeFile(filePath, JSON.stringify(service, null, 2), "utf-8");
|
|
51
51
|
}
|
|
@@ -41,11 +41,11 @@ export default defineEventHandler(async (event) => {
|
|
|
41
41
|
};
|
|
42
42
|
const options = {
|
|
43
43
|
headers: {
|
|
44
|
-
"x-api-secret": apiConfig?.
|
|
44
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
const service = await flowrixApi.get(`services`, apiConfig, options);
|
|
48
|
-
if (config.
|
|
48
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
49
49
|
await ensureCacheDir();
|
|
50
50
|
await writeFile(filePath, JSON.stringify(service, null, 2), "utf-8");
|
|
51
51
|
}
|
|
@@ -36,12 +36,12 @@ export default defineEventHandler(async (event) => {
|
|
|
36
36
|
};
|
|
37
37
|
const options = {
|
|
38
38
|
headers: {
|
|
39
|
-
"x-api-secret": apiConfig?.
|
|
39
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
40
40
|
},
|
|
41
41
|
query
|
|
42
42
|
};
|
|
43
43
|
const search = await flowrixApi.get(`search`, apiConfig, options);
|
|
44
|
-
if (config.
|
|
44
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
45
45
|
await ensureCacheDir();
|
|
46
46
|
await writeFile(filePath, JSON.stringify(search, null, 2), "utf-8");
|
|
47
47
|
}
|
|
@@ -14,11 +14,11 @@ export default defineEventHandler(async (event) => {
|
|
|
14
14
|
};
|
|
15
15
|
const options = {
|
|
16
16
|
headers: {
|
|
17
|
-
"x-api-secret": apiConfig?.
|
|
17
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
const page = await flowrixApi.get(`permalink/${slug}`, apiConfig, options);
|
|
21
|
-
if (config.
|
|
21
|
+
if (config.CACHE != "true" || config.public?.CACHE != "true") {
|
|
22
22
|
const CACHE_DIR = join("/tmp", ".cache");
|
|
23
23
|
if (existsSync(CACHE_DIR)) {
|
|
24
24
|
await rm(CACHE_DIR, { recursive: true, force: true });
|
|
@@ -38,11 +38,11 @@ export default defineEventHandler(async (event) => {
|
|
|
38
38
|
};
|
|
39
39
|
const options = {
|
|
40
40
|
headers: {
|
|
41
|
-
"x-api-secret": apiConfig?.
|
|
41
|
+
"x-api-secret": apiConfig?.SECRET || ""
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
const webfrom = await flowrixApi.get(`contact-center/webforms/${slug}/details`, apiConfig, options);
|
|
45
|
-
if (config.
|
|
45
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
46
46
|
await ensureCacheDir();
|
|
47
47
|
await writeFile(filePath, JSON.stringify(webfrom, null, 2), "utf-8");
|
|
48
48
|
}
|
|
@@ -37,15 +37,15 @@ function getLocationHeaders() {
|
|
|
37
37
|
export function useApi() {
|
|
38
38
|
const authStore = useAuthStore();
|
|
39
39
|
const config = useRuntimeConfig();
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const baseURL =
|
|
40
|
+
const KEY = config.KEY;
|
|
41
|
+
const ORIGIN = config.ORIGIN;
|
|
42
|
+
const BASE = config.BASE;
|
|
43
|
+
const baseURL = BASE || "";
|
|
44
44
|
async function request(method, url, data = null, options = {}, extraHeaders = {}) {
|
|
45
45
|
const locationHeaders = getLocationHeaders();
|
|
46
46
|
const headers = {
|
|
47
47
|
"Content-Type": "application/json",
|
|
48
|
-
"x-public-key":
|
|
48
|
+
"x-public-key": KEY,
|
|
49
49
|
// Add location headers from cookies
|
|
50
50
|
...locationHeaders,
|
|
51
51
|
// Add extra headers
|
|
@@ -54,7 +54,7 @@ export default defineEventHandler(async (event) => {
|
|
|
54
54
|
if (chunk) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
55
55
|
const html = Buffer.concat(chunks).toString("utf-8");
|
|
56
56
|
if (event.node.res.statusCode === 200 && html.includes("<!DOCTYPE html>")) {
|
|
57
|
-
if (config.
|
|
57
|
+
if (config.CACHE == "true" || config.public.CACHE == "true") {
|
|
58
58
|
writeCache(url, html, customerType);
|
|
59
59
|
}
|
|
60
60
|
}
|