flowrix 1.0.1-beta.89 → 1.0.1-beta.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/server/api/albums.d.ts +1 -0
- package/dist/runtime/server/api/albums.js +38 -12
- package/dist/runtime/server/api/banners.js +11 -10
- package/dist/runtime/server/api/brand/[...slug].js +7 -12
- package/dist/runtime/server/api/brand/index.d.ts +1 -0
- package/dist/runtime/server/api/brand/index.js +40 -14
- package/dist/runtime/server/api/cart/[slug]/add.d.ts +1 -1
- package/dist/runtime/server/api/cart/[slug]/add.js +11 -11
- package/dist/runtime/server/api/cart/[slug]/update.d.ts +1 -1
- package/dist/runtime/server/api/cart/[slug]/update.js +11 -11
- package/dist/runtime/server/api/cart/service/[slug]/add.d.ts +1 -1
- package/dist/runtime/server/api/cart/service/[slug]/add.js +12 -12
- package/dist/runtime/server/api/catalog/brands.d.ts +3 -0
- package/dist/runtime/server/api/catalog/brands.js +49 -0
- package/dist/runtime/server/api/catalog/categories.js +13 -12
- package/dist/runtime/server/api/catalog/categoriesall.js +15 -12
- package/dist/runtime/server/api/catalog/featured.js +16 -11
- package/dist/runtime/server/api/catalog/posts.d.ts +3 -0
- package/dist/runtime/server/api/catalog/posts.js +49 -0
- package/dist/runtime/server/api/catalog/samples.js +15 -12
- package/dist/runtime/server/api/catalog/search.js +14 -11
- package/dist/runtime/server/api/category/[...slug].js +1 -1
- package/dist/runtime/server/api/checkout/applyCoupon.d.ts +1 -1
- package/dist/runtime/server/api/checkout/applyCoupon.js +13 -13
- package/dist/runtime/server/api/checkout/configs.js +2 -1
- package/dist/runtime/server/api/checkout/countries.d.ts +1 -1
- package/dist/runtime/server/api/checkout/countries.js +5 -9
- package/dist/runtime/server/api/checkout/paymentmethod.d.ts +1 -1
- package/dist/runtime/server/api/checkout/paymentmethod.js +17 -12
- package/dist/runtime/server/api/cmspost/[...slug].js +9 -10
- package/dist/runtime/server/api/cmspost/all.d.ts +1 -1
- package/dist/runtime/server/api/cmspost/all.js +47 -15
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.d.ts +1 -1
- package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +48 -15
- package/dist/runtime/server/api/contact-center/webforms/create.d.ts +1 -1
- package/dist/runtime/server/api/contact-center/webforms/create.js +10 -10
- package/dist/runtime/server/api/countries.js +7 -2
- package/dist/runtime/server/api/featured.d.ts +2 -1
- package/dist/runtime/server/api/featured.js +44 -11
- package/dist/runtime/server/api/location.d.ts +1 -1
- package/dist/runtime/server/api/location.js +20 -12
- package/dist/runtime/server/api/nav/[id]/links.d.ts +1 -0
- package/dist/runtime/server/api/nav/[id]/links.js +48 -14
- package/dist/runtime/server/api/page/[...slug].js +8 -9
- package/dist/runtime/server/api/product/[...slug].js +12 -3
- package/dist/runtime/server/api/quickview/[slug].d.ts +1 -1
- package/dist/runtime/server/api/quickview/[slug].js +11 -10
- package/dist/runtime/server/api/reviews.d.ts +1 -1
- package/dist/runtime/server/api/reviews.js +9 -9
- package/dist/runtime/server/api/samples.d.ts +1 -1
- package/dist/runtime/server/api/samples.js +46 -16
- package/dist/runtime/server/api/search.d.ts +1 -1
- package/dist/runtime/server/api/search.js +48 -13
- package/dist/runtime/server/api/service/[slug].js +10 -9
- package/dist/runtime/server/api/service/availability.d.ts +1 -1
- package/dist/runtime/server/api/service/availability.js +11 -13
- package/dist/runtime/server/api/service/getall.js +11 -10
- package/dist/runtime/server/api/shop.d.ts +1 -1
- package/dist/runtime/server/api/shop.js +48 -13
- package/dist/runtime/server/api/subscribe.d.ts +1 -1
- package/dist/runtime/server/api/subscribe.js +19 -14
- package/dist/runtime/server/api/v2/[...slug].get.js +6 -2
- package/dist/runtime/server/api/webform.d.ts +1 -1
- package/dist/runtime/server/api/webform.js +50 -14
- package/dist/runtime/utils/htmlCache.js +1 -1
- package/package.json +1 -4
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defineEventHandler, getQuery, createError, getCookie } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
2
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
3
|
import { join } from "path";
|
|
4
|
+
import { useRuntimeConfig } from "#imports";
|
|
5
|
+
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
5
6
|
const CACHE_DIR = join("/tmp", ".cache", "nitro", "catalog");
|
|
6
7
|
export const catelogCache = /* @__PURE__ */ new Map();
|
|
7
8
|
async function ensureCacheDir() {
|
|
@@ -12,7 +13,7 @@ async function ensureCacheDir() {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
export default defineEventHandler(async (event) => {
|
|
15
|
-
|
|
16
|
+
let query = getQuery(event);
|
|
16
17
|
const customerType = getCookie(event, "customertype") || "";
|
|
17
18
|
const cacheKey = `samples-${JSON.stringify(query)}`;
|
|
18
19
|
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
@@ -24,15 +25,17 @@ export default defineEventHandler(async (event) => {
|
|
|
24
25
|
} catch (error) {
|
|
25
26
|
}
|
|
26
27
|
try {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const config = useRuntimeConfig();
|
|
29
|
+
const rawCookies = event.req.headers.cookie || "";
|
|
30
|
+
const apiConfig = {
|
|
31
|
+
...config,
|
|
32
|
+
cookies: rawCookies
|
|
33
|
+
};
|
|
34
|
+
query = {
|
|
35
|
+
...query
|
|
36
|
+
};
|
|
37
|
+
const samples = await flowrixApi.get(`samples`, apiConfig, { query });
|
|
38
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
36
39
|
await ensureCacheDir();
|
|
37
40
|
await writeFile(filePath, JSON.stringify(samples, null, 2), "utf-8");
|
|
38
41
|
}
|
|
@@ -40,7 +43,7 @@ export default defineEventHandler(async (event) => {
|
|
|
40
43
|
} catch (error) {
|
|
41
44
|
throw createError({
|
|
42
45
|
statusCode: 500,
|
|
43
|
-
statusMessage: `Failed to fetch
|
|
46
|
+
statusMessage: `Failed to fetch samples`,
|
|
44
47
|
data: error.message
|
|
45
48
|
});
|
|
46
49
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defineEventHandler, getQuery, createError, getCookie } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
2
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
3
|
import { join } from "path";
|
|
4
|
+
import { useRuntimeConfig } from "#imports";
|
|
5
|
+
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
5
6
|
const CACHE_DIR = join("/tmp", ".cache", "nitro", "catalog");
|
|
6
7
|
export const catelogCache = /* @__PURE__ */ new Map();
|
|
7
8
|
async function ensureCacheDir() {
|
|
@@ -12,7 +13,7 @@ async function ensureCacheDir() {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
export default defineEventHandler(async (event) => {
|
|
15
|
-
|
|
16
|
+
let query = getQuery(event);
|
|
16
17
|
const customerType = getCookie(event, "customertype") || "";
|
|
17
18
|
const cacheKey = `search-${JSON.stringify(query)}`;
|
|
18
19
|
const fileName = cacheKey.replace(/[^a-zA-Z0-9-_]/g, "_");
|
|
@@ -24,15 +25,17 @@ export default defineEventHandler(async (event) => {
|
|
|
24
25
|
} catch (error) {
|
|
25
26
|
}
|
|
26
27
|
try {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const config = useRuntimeConfig();
|
|
29
|
+
const rawCookies = event.req.headers.cookie || "";
|
|
30
|
+
const apiConfig = {
|
|
31
|
+
...config,
|
|
32
|
+
cookies: rawCookies
|
|
33
|
+
};
|
|
34
|
+
query = {
|
|
35
|
+
...query
|
|
36
|
+
};
|
|
37
|
+
const search = await flowrixApi.get(`search`, apiConfig, { query });
|
|
38
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
36
39
|
await ensureCacheDir();
|
|
37
40
|
await writeFile(filePath, JSON.stringify(search, null, 2), "utf-8");
|
|
38
41
|
}
|
|
@@ -42,7 +42,7 @@ export default defineEventHandler(async (event) => {
|
|
|
42
42
|
"scope[withchildren]": "true"
|
|
43
43
|
};
|
|
44
44
|
const category = await flowrixApi.get(`categories/${slug}`, apiConfig, { query });
|
|
45
|
-
if (
|
|
45
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
46
46
|
await ensureCacheDir();
|
|
47
47
|
await writeFile(filePath, JSON.stringify(category, null, 2), "utf-8");
|
|
48
48
|
}
|
|
@@ -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,20 +1,20 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
1
2
|
import { defineEventHandler, setResponseStatus, readBody } from "h3";
|
|
2
|
-
import {
|
|
3
|
+
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
3
4
|
export default defineEventHandler(async (event) => {
|
|
4
5
|
const body = await readBody(event);
|
|
5
6
|
try {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return productResponse;
|
|
7
|
+
const config = useRuntimeConfig();
|
|
8
|
+
const response = await flowrixApi.post(
|
|
9
|
+
`checkout/applyCoupon`,
|
|
10
|
+
config,
|
|
11
|
+
{
|
|
12
|
+
body
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
return response;
|
|
16
16
|
} catch (error) {
|
|
17
|
-
setResponseStatus(event,
|
|
18
|
-
return { success: false,
|
|
17
|
+
setResponseStatus(event, 500);
|
|
18
|
+
return { success: false, error: error.message };
|
|
19
19
|
}
|
|
20
20
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
1
2
|
import { defineEventHandler, setResponseStatus, readBody } from "h3";
|
|
2
3
|
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
3
4
|
export default defineEventHandler(async (event) => {
|
|
@@ -5,7 +6,7 @@ export default defineEventHandler(async (event) => {
|
|
|
5
6
|
try {
|
|
6
7
|
const config = useRuntimeConfig();
|
|
7
8
|
const response = await flowrixApi.post(
|
|
8
|
-
|
|
9
|
+
`checkout/configs`,
|
|
9
10
|
config,
|
|
10
11
|
{
|
|
11
12
|
body
|
|
@@ -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,11 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
1
2
|
import { defineEventHandler, setResponseStatus } from "h3";
|
|
2
|
-
import {
|
|
3
|
+
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
3
4
|
export default defineEventHandler(async (event) => {
|
|
4
5
|
try {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"x-api-secret": process.env.FLOWRIX_API_SECRET,
|
|
9
|
-
"Origin": process.env.FLOWRIX_API_ORIGIN
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
return countriesResponse.data;
|
|
6
|
+
const config = useRuntimeConfig();
|
|
7
|
+
const response = await flowrixApi.get(`countries`, config, {});
|
|
8
|
+
return response;
|
|
13
9
|
} catch (error) {
|
|
14
10
|
setResponseStatus(event, 500);
|
|
15
11
|
return { success: false, error: error.message };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
1
2
|
import { defineEventHandler, setResponseStatus, readBody } from "h3";
|
|
2
|
-
import {
|
|
3
|
+
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
3
4
|
export default defineEventHandler(async (event) => {
|
|
4
5
|
const body = await readBody(event);
|
|
5
6
|
try {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const config = useRuntimeConfig();
|
|
8
|
+
const rawCookies = event.req.headers.cookie || "";
|
|
9
|
+
const apiConfig = {
|
|
10
|
+
...config,
|
|
11
|
+
cookies: rawCookies
|
|
12
|
+
};
|
|
13
|
+
const response = await flowrixApi.post(
|
|
14
|
+
`checkout/paymentmethod`,
|
|
15
|
+
apiConfig,
|
|
16
|
+
{
|
|
17
|
+
body
|
|
18
|
+
}
|
|
19
|
+
);
|
|
15
20
|
return response;
|
|
16
21
|
} catch (error) {
|
|
17
|
-
setResponseStatus(event,
|
|
18
|
-
return { success: false, error: error.message
|
|
22
|
+
setResponseStatus(event, 500);
|
|
23
|
+
return { success: false, error: error.message };
|
|
19
24
|
}
|
|
20
25
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineEventHandler, getQuery, createError, readBody, getCookie } from "h3";
|
|
2
|
-
import { $fetch } from "ofetch";
|
|
3
2
|
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
4
3
|
import { join } from "path";
|
|
5
4
|
import { useRuntimeConfig } from "#imports";
|
|
5
|
+
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
6
6
|
const CACHE_DIR = join("/tmp", ".cache", "nitro", "blogs");
|
|
7
7
|
export const blogCache = /* @__PURE__ */ new Map();
|
|
8
8
|
async function ensureCacheDir() {
|
|
@@ -15,7 +15,7 @@ async function ensureCacheDir() {
|
|
|
15
15
|
export default defineEventHandler(async (event) => {
|
|
16
16
|
const slug = event.context.params._;
|
|
17
17
|
const customerType = getCookie(event, "customertype") || "";
|
|
18
|
-
|
|
18
|
+
let query = getQuery(event);
|
|
19
19
|
const body = await readBody(event);
|
|
20
20
|
if (!slug) {
|
|
21
21
|
throw createError({ statusCode: 400, statusMessage: "Missing slug parameter" });
|
|
@@ -31,14 +31,13 @@ export default defineEventHandler(async (event) => {
|
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
33
|
const config = useRuntimeConfig();
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (process.env.FLOWRIX_CACHE == true) {
|
|
34
|
+
const rawCookies = event.req.headers.cookie || "";
|
|
35
|
+
const apiConfig = {
|
|
36
|
+
...config,
|
|
37
|
+
cookies: rawCookies
|
|
38
|
+
};
|
|
39
|
+
const blog = await flowrixApi.get(`post/${slug}`, apiConfig, {});
|
|
40
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
42
41
|
await ensureCacheDir();
|
|
43
42
|
await writeFile(filePath, JSON.stringify(blog, null, 2), "utf-8");
|
|
44
43
|
}
|
|
@@ -1,17 +1,49 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery,
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { defineEventHandler, getQuery, createError, getCookie } from "h3";
|
|
2
|
+
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { useRuntimeConfig } from "#imports";
|
|
5
|
+
import { flowrixApi } from "../../../middleware/flowrix.js";
|
|
6
|
+
const CACHE_DIR = join("/tmp", ".cache", "nitro", "catalog");
|
|
7
|
+
export const catelogCache = /* @__PURE__ */ new Map();
|
|
8
|
+
async function ensureCacheDir() {
|
|
9
|
+
try {
|
|
10
|
+
await mkdir(CACHE_DIR, { recursive: true });
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.error("Error creating cache directory:", error);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
4
15
|
export default defineEventHandler(async (event) => {
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
let query = getQuery(event);
|
|
17
|
+
const customerType = getCookie(event, "customertype") || "";
|
|
18
|
+
const fileName = "posts";
|
|
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 posts = await flowrixApi.post(`posts`, apiConfig, { query });
|
|
37
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
38
|
+
await ensureCacheDir();
|
|
39
|
+
await writeFile(filePath, JSON.stringify(posts, null, 2), "utf-8");
|
|
40
|
+
}
|
|
41
|
+
return posts;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw createError({
|
|
44
|
+
statusCode: 500,
|
|
45
|
+
statusMessage: `Failed to fetch Brands`,
|
|
46
|
+
data: error.message
|
|
47
|
+
});
|
|
48
|
+
}
|
|
17
49
|
});
|
|
@@ -1,19 +1,52 @@
|
|
|
1
|
-
import { defineEventHandler, getRouterParam } from "h3";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { defineEventHandler, getRouterParam, getQuery, createError, readBody, getCookie } from "h3";
|
|
2
|
+
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { useRuntimeConfig } from "#imports";
|
|
5
|
+
import { flowrixApi } from "../../../../../middleware/flowrix.js";
|
|
6
|
+
const CACHE_DIR = join("/tmp", ".cache", "nitro", "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
|
+
}
|
|
4
15
|
export default defineEventHandler(async (event) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
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) {
|
|
8
31
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
32
|
+
try {
|
|
33
|
+
const config = useRuntimeConfig();
|
|
34
|
+
const rawCookies = event.req.headers.cookie || "";
|
|
35
|
+
const apiConfig = {
|
|
36
|
+
...config,
|
|
37
|
+
cookies: rawCookies
|
|
38
|
+
};
|
|
39
|
+
const webfrom = await flowrixApi.get(`contact-center/webforms/${slug}/details`, apiConfig, {});
|
|
40
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
41
|
+
await ensureCacheDir();
|
|
42
|
+
await writeFile(filePath, JSON.stringify(webfrom, null, 2), "utf-8");
|
|
15
43
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
44
|
+
return webfrom;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw createError({
|
|
47
|
+
statusCode: 500,
|
|
48
|
+
statusMessage: `Failed to fetch webfrom for id: ${slug}`,
|
|
49
|
+
data: error.message
|
|
50
|
+
});
|
|
51
|
+
}
|
|
19
52
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { defineEventHandler, readBody } from "h3";
|
|
2
|
-
import {
|
|
2
|
+
import { flowrixApi } from "../../../../middleware/flowrix.js";
|
|
3
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
4
|
export default defineEventHandler(async (event) => {
|
|
4
5
|
const body = await readBody(event);
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
body: JSON.stringify(body)
|
|
6
|
+
const config = useRuntimeConfig();
|
|
7
|
+
const rawCookies = event.req.headers.cookie || "";
|
|
8
|
+
const apiConfig = {
|
|
9
|
+
...config,
|
|
10
|
+
cookies: rawCookies
|
|
11
|
+
};
|
|
12
|
+
const webform = await flowrixApi.post(`posts`, apiConfig, {
|
|
13
|
+
body
|
|
14
14
|
});
|
|
15
15
|
return webform;
|
|
16
16
|
});
|
|
@@ -21,8 +21,13 @@ export default defineEventHandler(async (event) => {
|
|
|
21
21
|
}
|
|
22
22
|
try {
|
|
23
23
|
const config = useRuntimeConfig();
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const rawCookies = event.req.headers.cookie || "";
|
|
25
|
+
const apiConfig = {
|
|
26
|
+
...config,
|
|
27
|
+
cookies: rawCookies
|
|
28
|
+
};
|
|
29
|
+
const countries = await flowrixApi.get(`countries`, apiConfig);
|
|
30
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
26
31
|
await ensureCacheDir();
|
|
27
32
|
await writeFile(filePath, JSON.stringify(countries, null, 2), "utf-8");
|
|
28
33
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
export declare const catelogCache: Map<any, any>;
|
|
2
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
|
|
2
3
|
export default _default;
|
|
@@ -1,16 +1,49 @@
|
|
|
1
|
-
import { defineEventHandler, getCookie } from "h3";
|
|
1
|
+
import { defineEventHandler, getQuery, createError, getCookie } from "h3";
|
|
2
|
+
import { writeFile, mkdir, readFile } from "fs/promises";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { useRuntimeConfig } from "#imports";
|
|
5
|
+
import { flowrixApi } from "../../middleware/flowrix.js";
|
|
6
|
+
const CACHE_DIR = join("/tmp", ".cache", "nitro", "catalog");
|
|
7
|
+
export const catelogCache = /* @__PURE__ */ new Map();
|
|
8
|
+
async function ensureCacheDir() {
|
|
9
|
+
try {
|
|
10
|
+
await mkdir(CACHE_DIR, { recursive: true });
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.error("Error creating cache directory:", error);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
2
15
|
export default defineEventHandler(async (event) => {
|
|
3
|
-
|
|
16
|
+
let query = getQuery(event);
|
|
17
|
+
const customerType = getCookie(event, "customertype") || "";
|
|
18
|
+
const fileName = "featured";
|
|
19
|
+
const filePath = join(CACHE_DIR, `${fileName}-${customerType}.json`);
|
|
4
20
|
try {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
21
|
+
const fileContent = await readFile(filePath, "utf-8");
|
|
22
|
+
const catelog = JSON.parse(fileContent);
|
|
23
|
+
return catelog;
|
|
14
24
|
} catch (error) {
|
|
15
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 featured = await flowrixApi.get(`products/featured`, apiConfig, { query });
|
|
37
|
+
if (config.public.FLOWRIX_CACHE == true) {
|
|
38
|
+
await ensureCacheDir();
|
|
39
|
+
await writeFile(filePath, JSON.stringify(featured, null, 2), "utf-8");
|
|
40
|
+
}
|
|
41
|
+
return featured;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw createError({
|
|
44
|
+
statusCode: 500,
|
|
45
|
+
statusMessage: `Failed to fetch catelog for featured`,
|
|
46
|
+
data: error.message
|
|
47
|
+
});
|
|
48
|
+
}
|
|
16
49
|
});
|
|
@@ -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,13 +1,21 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 location = await flowrixApi.post(`ip/location`, apiConfig, {
|
|
14
|
+
body: JSON.stringify(body)
|
|
15
|
+
});
|
|
16
|
+
return location;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
setResponseStatus(event, 500);
|
|
19
|
+
return { success: false, error: error.message };
|
|
20
|
+
}
|
|
13
21
|
});
|