flowrix 1.0.1-beta.96 → 1.0.1-beta.98

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.
Files changed (31) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +7 -6
  3. package/dist/runtime/server/api/albums.js +1 -1
  4. package/dist/runtime/server/api/banners.js +1 -1
  5. package/dist/runtime/server/api/brand/[...slug].js +1 -1
  6. package/dist/runtime/server/api/brand/index.js +1 -1
  7. package/dist/runtime/server/api/catalog/brands.js +1 -1
  8. package/dist/runtime/server/api/catalog/categories.js +1 -1
  9. package/dist/runtime/server/api/catalog/categoriesall.js +1 -1
  10. package/dist/runtime/server/api/catalog/featured.js +1 -1
  11. package/dist/runtime/server/api/catalog/posts.js +1 -1
  12. package/dist/runtime/server/api/catalog/samples.js +1 -1
  13. package/dist/runtime/server/api/catalog/search.js +1 -1
  14. package/dist/runtime/server/api/category/[...slug].js +1 -1
  15. package/dist/runtime/server/api/cmspost/[...slug].js +1 -1
  16. package/dist/runtime/server/api/cmspost/all.js +1 -1
  17. package/dist/runtime/server/api/contact-center/webforms/[id]/details.js +1 -1
  18. package/dist/runtime/server/api/countries.js +1 -1
  19. package/dist/runtime/server/api/featured.js +1 -1
  20. package/dist/runtime/server/api/nav/[id]/links.js +1 -1
  21. package/dist/runtime/server/api/page/[...slug].js +1 -1
  22. package/dist/runtime/server/api/product/[...slug].js +1 -1
  23. package/dist/runtime/server/api/samples.js +1 -1
  24. package/dist/runtime/server/api/search.js +1 -1
  25. package/dist/runtime/server/api/service/[slug].js +1 -1
  26. package/dist/runtime/server/api/service/getall.js +1 -1
  27. package/dist/runtime/server/api/shop.js +1 -1
  28. package/dist/runtime/server/api/v2/[...slug].get.js +15 -0
  29. package/dist/runtime/server/api/webform.js +1 -1
  30. package/dist/runtime/utils/htmlCache.js +1 -1
  31. package/package.json +1 -1
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "flowrix",
3
3
  "configKey": "flowrix",
4
- "version": "1.0.1-beta.96",
4
+ "version": "1.0.1-beta.98",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -9,19 +9,20 @@ const module$1 = defineNuxtModule({
9
9
  async setup(_options, nuxt) {
10
10
  const env = process.env;
11
11
  const runtimeConfig = nuxt.options.runtimeConfig;
12
- runtimeConfig.FLOWRIX_API_KEY = env.KEY || "";
13
- runtimeConfig.FLOWRIX_API_ORIGIN = env.ORIGIN || "";
14
- runtimeConfig.FLOWRIX_API_BASE = env.BASE || "";
15
- runtimeConfig.FLOWRIX_CACHE = env.CACHE || false;
16
- runtimeConfig.FLOWRIX_CDN = env.CDN || "";
12
+ runtimeConfig.FLOWRIX_API_KEY = env.KEY || runtimeConfig.FLOWRIX_API_KEY || "";
13
+ runtimeConfig.FLOWRIX_API_ORIGIN = env.ORIGIN || runtimeConfig.FLOWRIX_API_ORIGIN || "";
14
+ runtimeConfig.FLOWRIX_API_BASE = env.BASE || runtimeConfig.FLOWRIX_API_BASE || "";
15
+ runtimeConfig.FLOWRIX_CACHE = env.CACHE || runtimeConfig.FLOWRIX_CACHE || "false";
16
+ runtimeConfig.FLOWRIX_CDN = env.CDN || runtimeConfig.FLOWRIX_CDN || "";
17
17
  Object.assign(runtimeConfig.public, {
18
18
  ...runtimeConfig.public,
19
19
  FLOWRIX_API_KEY: runtimeConfig.public.FLOWRIX_API_KEY || env.KEY || runtimeConfig.FLOWRIX_API_KEY || "",
20
20
  FLOWRIX_API_ORIGIN: runtimeConfig.public.FLOWRIX_API_ORIGIN || env.ORIGIN || runtimeConfig.FLOWRIX_API_ORIGIN || "",
21
21
  FLOWRIX_API_BASE: runtimeConfig.public.FLOWRIX_API_BASE || env.BASE || runtimeConfig.FLOWRIX_API_BASE || "",
22
- FLOWRIX_CACHE: runtimeConfig.public.FLOWRIX_CACHE || env.CACHE || runtimeConfig.FLOWRIX_CACHE || false,
22
+ FLOWRIX_CACHE: runtimeConfig.public.FLOWRIX_CACHE || env.CACHE || runtimeConfig.FLOWRIX_CACHE || "false",
23
23
  FLOWRIX_CDN: runtimeConfig.public.FLOWRIX_CDN || env.FCDN || runtimeConfig.FLOWRIX_CDN || ""
24
24
  });
25
+ console.log("runtimeConfig", runtimeConfig);
25
26
  const resolver = createResolver(import.meta.url);
26
27
  await installModule("@pinia/nuxt");
27
28
  addServerHandler({
@@ -29,7 +29,7 @@ export default defineEventHandler(async (event) => {
29
29
  cookies: rawCookies
30
30
  };
31
31
  const albums = await flowrixApi.get(`albums`, apiConfig);
32
- if (config.FLOWRIX_CACHE == true) {
32
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
33
33
  await ensureCacheDir();
34
34
  await writeFile(filePath, JSON.stringify(albums, null, 2), "utf-8");
35
35
  }
@@ -29,7 +29,7 @@ export default defineEventHandler(async (event) => {
29
29
  cookies: rawCookies
30
30
  };
31
31
  const banners = await flowrixApi.get(`banners`, apiConfig);
32
- if (config.FLOWRIX_CACHE == true) {
32
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
33
33
  await ensureCacheDir();
34
34
  await writeFile(filePath, JSON.stringify(banners, null, 2), "utf-8");
35
35
  }
@@ -40,7 +40,7 @@ export default defineEventHandler(async (event) => {
40
40
  ...query
41
41
  };
42
42
  const brand = await flowrixApi.get(`brands/${slug}`, apiConfig, { query });
43
- if (config.FLOWRIX_CACHE == true) {
43
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
44
44
  await ensureCacheDir();
45
45
  await writeFile(filePath, JSON.stringify(brand, null, 2), "utf-8");
46
46
  }
@@ -34,7 +34,7 @@ export default defineEventHandler(async (event) => {
34
34
  ...query
35
35
  };
36
36
  const brands = await flowrixApi.get(`brands`, apiConfig, { query });
37
- if (config.FLOWRIX_CACHE == true) {
37
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
38
  await ensureCacheDir();
39
39
  await writeFile(filePath, JSON.stringify(brands, null, 2), "utf-8");
40
40
  }
@@ -34,7 +34,7 @@ export default defineEventHandler(async (event) => {
34
34
  ...query
35
35
  };
36
36
  const brands = await flowrixApi.get(`brands`, apiConfig, { query });
37
- if (config.FLOWRIX_CACHE == true) {
37
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
38
  await ensureCacheDir();
39
39
  await writeFile(filePath, JSON.stringify(brands, null, 2), "utf-8");
40
40
  }
@@ -34,7 +34,7 @@ export default defineEventHandler(async (event) => {
34
34
  ...query
35
35
  };
36
36
  const categories = await flowrixApi.get(`categories`, apiConfig, { query });
37
- if (config.FLOWRIX_CACHE == true) {
37
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
38
  await ensureCacheDir();
39
39
  await writeFile(filePath, JSON.stringify(categories, null, 2), "utf-8");
40
40
  }
@@ -34,7 +34,7 @@ export default defineEventHandler(async (event) => {
34
34
  ...query
35
35
  };
36
36
  const categories = await flowrixApi.get(`categories/all`, apiConfig, { query });
37
- if (config.FLOWRIX_CACHE == true) {
37
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
38
  await ensureCacheDir();
39
39
  await writeFile(filePath, JSON.stringify(categories, null, 2), "utf-8");
40
40
  }
@@ -34,7 +34,7 @@ export default defineEventHandler(async (event) => {
34
34
  ...query
35
35
  };
36
36
  const featured = await flowrixApi.get(`products/featured`, apiConfig, { query });
37
- if (config.FLOWRIX_CACHE == true) {
37
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
38
  await ensureCacheDir();
39
39
  await writeFile(filePath, JSON.stringify(featured, null, 2), "utf-8");
40
40
  }
@@ -34,7 +34,7 @@ export default defineEventHandler(async (event) => {
34
34
  ...query
35
35
  };
36
36
  const posts = await flowrixApi.post(`posts`, apiConfig, { query });
37
- if (config.FLOWRIX_CACHE == true) {
37
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
38
  await ensureCacheDir();
39
39
  await writeFile(filePath, JSON.stringify(posts, null, 2), "utf-8");
40
40
  }
@@ -35,7 +35,7 @@ export default defineEventHandler(async (event) => {
35
35
  ...query
36
36
  };
37
37
  const samples = await flowrixApi.get(`samples`, apiConfig, { query });
38
- if (config.FLOWRIX_CACHE == true) {
38
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
39
39
  await ensureCacheDir();
40
40
  await writeFile(filePath, JSON.stringify(samples, null, 2), "utf-8");
41
41
  }
@@ -35,7 +35,7 @@ export default defineEventHandler(async (event) => {
35
35
  ...query
36
36
  };
37
37
  const search = await flowrixApi.get(`search`, apiConfig, { query });
38
- if (config.FLOWRIX_CACHE == true) {
38
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
39
39
  await ensureCacheDir();
40
40
  await writeFile(filePath, JSON.stringify(search, null, 2), "utf-8");
41
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 (config.FLOWRIX_CACHE == true) {
45
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
46
46
  await ensureCacheDir();
47
47
  await writeFile(filePath, JSON.stringify(category, null, 2), "utf-8");
48
48
  }
@@ -37,7 +37,7 @@ export default defineEventHandler(async (event) => {
37
37
  cookies: rawCookies
38
38
  };
39
39
  const blog = await flowrixApi.get(`post/${slug}`, apiConfig, {});
40
- if (config.FLOWRIX_CACHE == true) {
40
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
41
41
  await ensureCacheDir();
42
42
  await writeFile(filePath, JSON.stringify(blog, null, 2), "utf-8");
43
43
  }
@@ -34,7 +34,7 @@ export default defineEventHandler(async (event) => {
34
34
  ...query
35
35
  };
36
36
  const posts = await flowrixApi.post(`posts`, apiConfig, { query });
37
- if (config.FLOWRIX_CACHE == true) {
37
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
38
  await ensureCacheDir();
39
39
  await writeFile(filePath, JSON.stringify(posts, null, 2), "utf-8");
40
40
  }
@@ -37,7 +37,7 @@ export default defineEventHandler(async (event) => {
37
37
  cookies: rawCookies
38
38
  };
39
39
  const webfrom = await flowrixApi.get(`contact-center/webforms/${slug}/details`, apiConfig, {});
40
- if (config.FLOWRIX_CACHE == true) {
40
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
41
41
  await ensureCacheDir();
42
42
  await writeFile(filePath, JSON.stringify(webfrom, null, 2), "utf-8");
43
43
  }
@@ -27,7 +27,7 @@ export default defineEventHandler(async (event) => {
27
27
  cookies: rawCookies
28
28
  };
29
29
  const countries = await flowrixApi.get(`countries`, apiConfig);
30
- if (config.FLOWRIX_CACHE == true) {
30
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
31
31
  await ensureCacheDir();
32
32
  await writeFile(filePath, JSON.stringify(countries, null, 2), "utf-8");
33
33
  }
@@ -34,7 +34,7 @@ export default defineEventHandler(async (event) => {
34
34
  ...query
35
35
  };
36
36
  const featured = await flowrixApi.get(`products/featured`, apiConfig, { query });
37
- if (config.FLOWRIX_CACHE == true) {
37
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
38
38
  await ensureCacheDir();
39
39
  await writeFile(filePath, JSON.stringify(featured, null, 2), "utf-8");
40
40
  }
@@ -38,7 +38,7 @@ export default defineEventHandler(async (event) => {
38
38
  cookies: rawCookies
39
39
  };
40
40
  const menu = await flowrixApi.get(`nav/${slug}/links`, apiConfig, {});
41
- if (config.FLOWRIX_CACHE == true) {
41
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
42
42
  await ensureCacheDir();
43
43
  await writeFile(filePath, JSON.stringify(menu, null, 2), "utf-8");
44
44
  }
@@ -37,7 +37,7 @@ export default defineEventHandler(async (event) => {
37
37
  cookies: rawCookies
38
38
  };
39
39
  const page = await flowrixApi.get(`page/${slug}`, apiConfig, {});
40
- if (config.FLOWRIX_CACHE == true) {
40
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
41
41
  await ensureCacheDir();
42
42
  await writeFile(filePath, JSON.stringify(page, null, 2), "utf-8");
43
43
  }
@@ -43,7 +43,7 @@ export default defineEventHandler(async (event) => {
43
43
  body: JSON.stringify(body),
44
44
  query
45
45
  });
46
- if (config.FLOWRIX_CACHE == true) {
46
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
47
47
  await ensureCacheDir();
48
48
  await writeFile(filePath, JSON.stringify(product, null, 2), "utf-8");
49
49
  }
@@ -35,7 +35,7 @@ export default defineEventHandler(async (event) => {
35
35
  ...query
36
36
  };
37
37
  const samples = await flowrixApi.get(`samples`, apiConfig, { query });
38
- if (config.FLOWRIX_CACHE == true) {
38
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
39
39
  await ensureCacheDir();
40
40
  await writeFile(filePath, JSON.stringify(samples, null, 2), "utf-8");
41
41
  }
@@ -35,7 +35,7 @@ export default defineEventHandler(async (event) => {
35
35
  ...query
36
36
  };
37
37
  const search = await flowrixApi.get(`search`, apiConfig, { query });
38
- if (config.FLOWRIX_CACHE == true) {
38
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
39
39
  await ensureCacheDir();
40
40
  await writeFile(filePath, JSON.stringify(search, null, 2), "utf-8");
41
41
  }
@@ -40,7 +40,7 @@ export default defineEventHandler(async (event) => {
40
40
  cookies: rawCookies
41
41
  };
42
42
  const service = await flowrixApi.get(`services/${slug}`, apiConfig, {});
43
- if (config.FLOWRIX_CACHE == true) {
43
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
44
44
  await ensureCacheDir();
45
45
  await writeFile(filePath, JSON.stringify(service, null, 2), "utf-8");
46
46
  }
@@ -40,7 +40,7 @@ export default defineEventHandler(async (event) => {
40
40
  cookies: rawCookies
41
41
  };
42
42
  const service = await flowrixApi.get(`services`, apiConfig, {});
43
- if (config.FLOWRIX_CACHE == true) {
43
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
44
44
  await ensureCacheDir();
45
45
  await writeFile(filePath, JSON.stringify(service, null, 2), "utf-8");
46
46
  }
@@ -35,7 +35,7 @@ export default defineEventHandler(async (event) => {
35
35
  ...query
36
36
  };
37
37
  const search = await flowrixApi.get(`search`, apiConfig, { query });
38
- if (config.FLOWRIX_CACHE == true) {
38
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
39
39
  await ensureCacheDir();
40
40
  await writeFile(filePath, JSON.stringify(search, null, 2), "utf-8");
41
41
  }
@@ -1,6 +1,9 @@
1
1
  import { defineEventHandler } from "h3";
2
2
  import { flowrixApi } from "../../../middleware/flowrix.js";
3
3
  import { useRuntimeConfig } from "#imports";
4
+ import { existsSync } from "fs";
5
+ import { join } from "path";
6
+ import { rm } from "fs/promises";
4
7
  export default defineEventHandler(async (event) => {
5
8
  const slug = event.context.params._;
6
9
  const config = useRuntimeConfig();
@@ -10,6 +13,18 @@ export default defineEventHandler(async (event) => {
10
13
  cookies: rawCookies
11
14
  };
12
15
  const page = await flowrixApi.get(`permalink/${slug}`, apiConfig);
16
+ console.log("config.FLOWRIX_CACHE", config);
17
+ if (config.FLOWRIX_CACHE != "true" || config.public?.FLOWRIX_CACHE != "true") {
18
+ const CACHE_DIR = join("/tmp", ".cache");
19
+ console.log("\u{1F9F9} CACHE_DIR0", CACHE_DIR);
20
+ if (existsSync(CACHE_DIR)) {
21
+ console.log("\u{1F9F9} Flowrix: .cache folder found \u2014 removing entire folder...");
22
+ await rm(CACHE_DIR, { recursive: true, force: true });
23
+ console.log("\u2705 Flowrix: Entire .cache folder removed.");
24
+ } else {
25
+ console.log("\u2139\uFE0F Flowrix: No .cache folder found \u2014 skipping cleanup.");
26
+ }
27
+ }
13
28
  if (page.status === "Success" && page.data.type === "Redirect") {
14
29
  }
15
30
  return page;
@@ -37,7 +37,7 @@ export default defineEventHandler(async (event) => {
37
37
  cookies: rawCookies
38
38
  };
39
39
  const webfrom = await flowrixApi.get(`contact-center/webforms/${slug}/details`, apiConfig, {});
40
- if (config.FLOWRIX_CACHE == true) {
40
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
41
41
  await ensureCacheDir();
42
42
  await writeFile(filePath, JSON.stringify(webfrom, null, 2), "utf-8");
43
43
  }
@@ -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.FLOWRIX_CACHE == true) {
57
+ if (config.FLOWRIX_CACHE == "true" || config.public.FLOWRIX_CACHE == "true") {
58
58
  writeCache(url, html, customerType);
59
59
  }
60
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowrix",
3
- "version": "1.0.1-beta.96",
3
+ "version": "1.0.1-beta.98",
4
4
  "description": "Plug-and-play Nuxt eCommerce cart powered by FLOWRiX. Subscription required.",
5
5
  "license": "MIT",
6
6
  "type": "module",