flowrix 1.0.1-beta.20 → 1.0.1-beta.22

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "flowrix",
3
3
  "configKey": "flowrix",
4
- "version": "1.0.1-beta.20",
4
+ "version": "1.0.1-beta.22",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -9,9 +9,6 @@ const module = defineNuxtModule({
9
9
  async setup(_options, nuxt) {
10
10
  const env = process.env;
11
11
  const runtimeConfig = nuxt.options.runtimeConfig;
12
- if (!runtimeConfig.public) {
13
- runtimeConfig.public = {};
14
- }
15
12
  runtimeConfig.FLOWRIX_API_KEY ||= env.FLOWRIX_API_KEY || "";
16
13
  runtimeConfig.FLOWRIX_API_SECRET ||= env.FLOWRIX_API_SECRET || "";
17
14
  runtimeConfig.FLOWRIX_API_ORIGIN ||= env.FLOWRIX_API_ORIGIN || "";
@@ -1,6 +1,7 @@
1
+ export declare function setFlowrixConfig(config: any): void;
1
2
  export declare const flowrixApi: {
2
- get: (endpoint: string, options?: {}, apiversion?: string) => Promise<unknown>;
3
- post: (endpoint: string, options?: {}, apiversion?: string) => Promise<unknown>;
4
- put: (endpoint: string, options?: {}, apiversion?: string) => Promise<unknown>;
5
- delete: (endpoint: string, options?: {}, apiversion?: string) => Promise<unknown>;
3
+ get: (endpoint: any, options?: {}, apiversion?: string) => Promise<unknown>;
4
+ post: (endpoint: any, options?: {}, apiversion?: string) => Promise<unknown>;
5
+ put: (endpoint: any, options?: {}, apiversion?: string) => Promise<unknown>;
6
+ delete: (endpoint: any, options?: {}, apiversion?: string) => Promise<unknown>;
6
7
  };
@@ -1,31 +1,28 @@
1
- let getRuntimeConfig = null;
2
- try {
3
- const nuxtApp = require("#app");
4
- if (nuxtApp?.useRuntimeConfig) {
5
- getRuntimeConfig = nuxtApp.useRuntimeConfig;
6
- }
7
- } catch (_) {
8
- }
9
1
  const isServer = typeof process !== "undefined" && process.server;
2
+ let nuxtRuntimeConfig = null;
3
+ export function setFlowrixConfig(config) {
4
+ nuxtRuntimeConfig = config;
5
+ }
10
6
  function getEnv(key) {
11
- if (getRuntimeConfig) {
12
- const config = getRuntimeConfig();
7
+ if (typeof useRuntimeConfig === "function") {
8
+ const config = useRuntimeConfig();
9
+ console.log(config);
13
10
  return config.public?.[key] || config[key];
14
11
  }
15
12
  return process.env[key];
16
13
  }
17
- async function request(method, endpoint, options = {}, apiversion = "v1") {
14
+ async function request(method, endpoint, options = {}, apiversion) {
18
15
  const FLOWRIX_API_KEY = getEnv("FLOWRIX_API_KEY");
19
16
  const FLOWRIX_API_SECRET = getEnv("FLOWRIX_API_SECRET");
20
17
  const FLOWRIX_API_ORIGIN = getEnv("FLOWRIX_API_ORIGIN");
21
18
  let FLOWRIX_API_BASE = getEnv("FLOWRIX_API_BASE");
22
- if (apiversion === "v2") {
19
+ if (apiversion == "v2") {
23
20
  FLOWRIX_API_BASE = getEnv("FLOWRIX_API_BASE_V2");
24
21
  }
25
22
  const headers = {
26
23
  "x-api-key": FLOWRIX_API_KEY,
27
24
  "x-api-secret": FLOWRIX_API_SECRET,
28
- Origin: FLOWRIX_API_ORIGIN,
25
+ "Origin": FLOWRIX_API_ORIGIN,
29
26
  ...options.headers
30
27
  };
31
28
  try {
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { setFlowrixConfig } from "flowrix/api/flowrix";
2
+ export default defineNuxtPlugin(() => {
3
+ const config = useRuntimeConfig();
4
+ setFlowrixConfig(config);
5
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowrix",
3
- "version": "1.0.1-beta.20",
3
+ "version": "1.0.1-beta.22",
4
4
  "description": "lug-and-play Nuxt eCommerce cart powered by FLOWRiX. Subscription required.",
5
5
  "license": "MIT",
6
6
  "type": "module",