@enfyra/sdk-nuxt 0.3.18 → 0.3.20
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/auth.d.ts +43 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +1 -0
- package/dist/index.d.ts +141 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/module.cjs +97 -0
- package/dist/module.d.cts +10 -0
- package/dist/module.d.mts +10 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +94 -0
- package/dist/runtime/composables/useEnfyraApi.d.ts +0 -0
- package/dist/runtime/composables/useEnfyraApi.js +345 -0
- package/dist/runtime/composables/useEnfyraAuth.d.ts +0 -0
- package/dist/runtime/composables/useEnfyraAuth.js +81 -0
- package/dist/runtime/constants/auth.d.ts +0 -0
- package/dist/runtime/constants/auth.js +3 -0
- package/dist/runtime/constants/config.d.ts +0 -0
- package/dist/runtime/constants/config.js +1 -0
- package/dist/runtime/server/api/all.js +1 -1
- package/dist/runtime/server/api/login.post.js +2 -2
- package/dist/runtime/server/api/logout.post.js +2 -2
- package/dist/runtime/server/middleware/auth.js +2 -2
- package/dist/runtime/shims.d.ts +72 -0
- package/dist/runtime/utils/http.d.ts +0 -0
- package/dist/runtime/utils/http.js +61 -0
- package/dist/runtime/utils/server/proxy.d.ts +0 -0
- package/dist/runtime/utils/server/proxy.js +14 -0
- package/dist/runtime/utils/server/refreshToken.d.ts +0 -0
- package/dist/runtime/utils/server/refreshToken.js +69 -0
- package/dist/runtime/utils/url.d.ts +0 -0
- package/dist/runtime/utils/url.js +56 -0
- package/dist/types.d.mts +7 -0
- package/dist/types.d.ts +7 -0
- package/index.ts +1 -1
- package/module.d.ts +16 -6
- package/package.json +30 -32
- package/src/module.ts +129 -0
- package/src/{composables → runtime/composables}/useEnfyraApi.ts +17 -17
- package/src/{composables → runtime/composables}/useEnfyraAuth.ts +2 -2
- package/src/runtime/server/api/all.ts +1 -1
- package/src/runtime/server/api/login.post.ts +2 -2
- package/src/runtime/server/api/logout.post.ts +2 -2
- package/src/runtime/server/middleware/auth.ts +2 -2
- package/src/runtime/shims.d.ts +72 -0
- package/src/{utils → runtime/utils}/server/proxy.ts +1 -1
- package/src/{utils → runtime/utils}/server/refreshToken.ts +3 -3
- package/src/{utils → runtime/utils}/url.ts +11 -4
- package/dist/runtime/plugin/config-error.client.mjs +0 -107
- package/dist/runtime/server/api/all.mjs +0 -5
- package/dist/runtime/server/api/login.post.mjs +0 -62
- package/dist/runtime/server/api/logout.post.mjs +0 -35
- package/dist/runtime/server/middleware/auth.mjs +0 -36
- package/module.ts +0 -110
- package/src/types/nuxt-imports.d.ts +0 -61
- package/src/utils/config.ts +0 -22
- /package/src/{constants → runtime/constants}/auth.ts +0 -0
- /package/src/{constants → runtime/constants}/config.ts +0 -0
- /package/src/{utils → runtime/utils}/http.ts +0 -0
|
@@ -37,9 +37,6 @@ export function joinUrlPath(...paths: (string | undefined | null)[]): string {
|
|
|
37
37
|
.join('/');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
// Import from #imports at top level
|
|
41
|
-
import { useRequestHeaders, useRequestURL } from '#imports';
|
|
42
|
-
|
|
43
40
|
export function getAppUrl(): string {
|
|
44
41
|
if (process.client && typeof window !== 'undefined') {
|
|
45
42
|
return window.location.origin;
|
|
@@ -47,13 +44,23 @@ export function getAppUrl(): string {
|
|
|
47
44
|
|
|
48
45
|
if (process.server) {
|
|
49
46
|
try {
|
|
47
|
+
let useRequestHeaders: any;
|
|
48
|
+
let useRequestURL: any;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const imports = eval('require("#imports")');
|
|
52
|
+
useRequestHeaders = imports.useRequestHeaders;
|
|
53
|
+
useRequestURL = imports.useRequestURL;
|
|
54
|
+
} catch (e) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
|
|
50
58
|
try {
|
|
51
59
|
const url = useRequestURL();
|
|
52
60
|
if (url) {
|
|
53
61
|
return `${url.protocol}//${url.host}`;
|
|
54
62
|
}
|
|
55
63
|
} catch (e) {
|
|
56
|
-
// useRequestURL might not be available in all contexts
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
const headers = useRequestHeaders();
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { defineNuxtPlugin, useRuntimeConfig } from "#imports";
|
|
2
|
-
export default defineNuxtPlugin(() => {
|
|
3
|
-
const config = useRuntimeConfig().public?.enfyraSDK;
|
|
4
|
-
if (config?.configError) {
|
|
5
|
-
if (typeof window !== "undefined" && document) {
|
|
6
|
-
let showError = function() {
|
|
7
|
-
const errorDiv = document.createElement("div");
|
|
8
|
-
errorDiv.id = "enfyra-config-error";
|
|
9
|
-
errorDiv.style.cssText = `
|
|
10
|
-
position: fixed;
|
|
11
|
-
top: 0;
|
|
12
|
-
left: 0;
|
|
13
|
-
right: 0;
|
|
14
|
-
bottom: 0;
|
|
15
|
-
background: rgba(0, 0, 0, 0.9);
|
|
16
|
-
display: flex;
|
|
17
|
-
align-items: center;
|
|
18
|
-
justify-content: center;
|
|
19
|
-
z-index: 999999;
|
|
20
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
21
|
-
`;
|
|
22
|
-
const content = document.createElement("div");
|
|
23
|
-
content.style.cssText = `
|
|
24
|
-
background: white;
|
|
25
|
-
padding: 40px;
|
|
26
|
-
border-radius: 12px;
|
|
27
|
-
max-width: 600px;
|
|
28
|
-
width: 90%;
|
|
29
|
-
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
30
|
-
`;
|
|
31
|
-
content.innerHTML = `
|
|
32
|
-
<div style="display: flex; align-items: center; margin-bottom: 20px;">
|
|
33
|
-
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" style="margin-right: 12px;">
|
|
34
|
-
<circle cx="12" cy="12" r="10" stroke="#ef4444" stroke-width="2"/>
|
|
35
|
-
<path d="M12 8v4M12 16h.01" stroke="#ef4444" stroke-width="2" stroke-linecap="round"/>
|
|
36
|
-
</svg>
|
|
37
|
-
<h1 style="margin: 0; color: #1f2937; font-size: 24px; font-weight: 600;">
|
|
38
|
-
Configuration Error
|
|
39
|
-
</h1>
|
|
40
|
-
</div>
|
|
41
|
-
|
|
42
|
-
<div style="color: #4b5563; margin-bottom: 24px; line-height: 1.6;">
|
|
43
|
-
<p style="margin: 0 0 16px 0; font-size: 16px;">
|
|
44
|
-
<strong>Enfyra SDK</strong> is not configured properly.
|
|
45
|
-
</p>
|
|
46
|
-
<p style="margin: 0; color: #6b7280; font-size: 14px;">
|
|
47
|
-
${config?.configErrorMessage || "Missing required configuration"}
|
|
48
|
-
</p>
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; margin-bottom: 24px;">
|
|
52
|
-
<p style="margin: 0 0 12px 0; color: #6b7280; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px;">
|
|
53
|
-
Add to your nuxt.config.ts:
|
|
54
|
-
</p>
|
|
55
|
-
<pre style="margin: 0; background: #1f2937; color: #f3f4f6; padding: 16px; border-radius: 6px; overflow-x: auto; font-size: 14px; line-height: 1.4;"><code>export default defineNuxtConfig({
|
|
56
|
-
modules: ["@enfyra/sdk-nuxt"],
|
|
57
|
-
enfyraSDK: {
|
|
58
|
-
<span style="color: #fbbf24;">apiUrl</span>: <span style="color: #34d399;">"https://your-api-url"</span>
|
|
59
|
-
}
|
|
60
|
-
})</code></pre>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
<div style="display: flex; gap: 12px;">
|
|
64
|
-
<button onclick="location.reload()" style="
|
|
65
|
-
background: #3b82f6;
|
|
66
|
-
color: white;
|
|
67
|
-
border: none;
|
|
68
|
-
padding: 10px 20px;
|
|
69
|
-
border-radius: 6px;
|
|
70
|
-
font-size: 14px;
|
|
71
|
-
font-weight: 500;
|
|
72
|
-
cursor: pointer;
|
|
73
|
-
transition: background 0.2s;
|
|
74
|
-
" onmouseover="this.style.background='#2563eb'" onmouseout="this.style.background='#3b82f6'">
|
|
75
|
-
Reload Page
|
|
76
|
-
</button>
|
|
77
|
-
<button onclick="document.getElementById('enfyra-config-error').style.display='none'" style="
|
|
78
|
-
background: #f3f4f6;
|
|
79
|
-
color: #4b5563;
|
|
80
|
-
border: 1px solid #e5e7eb;
|
|
81
|
-
padding: 10px 20px;
|
|
82
|
-
border-radius: 6px;
|
|
83
|
-
font-size: 14px;
|
|
84
|
-
font-weight: 500;
|
|
85
|
-
cursor: pointer;
|
|
86
|
-
transition: all 0.2s;
|
|
87
|
-
" onmouseover="this.style.background='#e5e7eb'" onmouseout="this.style.background='#f3f4f6'">
|
|
88
|
-
Dismiss
|
|
89
|
-
</button>
|
|
90
|
-
</div>
|
|
91
|
-
`;
|
|
92
|
-
errorDiv.appendChild(content);
|
|
93
|
-
document.body.appendChild(errorDiv);
|
|
94
|
-
console.error(
|
|
95
|
-
"%c\u26A0\uFE0F Enfyra SDK Configuration Error",
|
|
96
|
-
"color: #ef4444; font-size: 16px; font-weight: bold;",
|
|
97
|
-
"\n\n" + (config?.configErrorMessage || "Missing required configuration") + '\n\nPlease add the following to your nuxt.config.ts:\n\nenfyraSDK: {\n apiUrl: "https://your-api-url"\n}'
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
if (document.readyState === "loading") {
|
|
101
|
-
document.addEventListener("DOMContentLoaded", showError);
|
|
102
|
-
} else {
|
|
103
|
-
showError();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineEventHandler,
|
|
3
|
-
readBody,
|
|
4
|
-
setCookie,
|
|
5
|
-
createError,
|
|
6
|
-
sendError,
|
|
7
|
-
getHeader
|
|
8
|
-
} from "h3";
|
|
9
|
-
import { useRuntimeConfig } from "#imports";
|
|
10
|
-
import { $fetch } from "ofetch";
|
|
11
|
-
import {
|
|
12
|
-
ACCESS_TOKEN_KEY,
|
|
13
|
-
REFRESH_TOKEN_KEY,
|
|
14
|
-
EXP_TIME_KEY
|
|
15
|
-
} from "../../../constants/auth";
|
|
16
|
-
import { normalizeUrl } from "../../../utils/url";
|
|
17
|
-
export default defineEventHandler(async (event) => {
|
|
18
|
-
const config = useRuntimeConfig();
|
|
19
|
-
const apiUrl = config.public.enfyraSDK?.apiUrl;
|
|
20
|
-
try {
|
|
21
|
-
const body = await readBody(event);
|
|
22
|
-
const response = await $fetch(normalizeUrl(apiUrl, "/auth/login"), {
|
|
23
|
-
method: "POST",
|
|
24
|
-
body,
|
|
25
|
-
headers: {
|
|
26
|
-
cookie: getHeader(event, "cookie") || ""
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
const { accessToken, refreshToken, expTime } = response;
|
|
30
|
-
const cookieOptions = {
|
|
31
|
-
httpOnly: true,
|
|
32
|
-
secure: true,
|
|
33
|
-
sameSite: "lax",
|
|
34
|
-
path: "/"
|
|
35
|
-
};
|
|
36
|
-
setCookie(event, ACCESS_TOKEN_KEY, accessToken, cookieOptions);
|
|
37
|
-
setCookie(event, REFRESH_TOKEN_KEY, refreshToken, cookieOptions);
|
|
38
|
-
setCookie(event, EXP_TIME_KEY, String(expTime), cookieOptions);
|
|
39
|
-
return { accessToken };
|
|
40
|
-
} catch (err) {
|
|
41
|
-
const statusCode = err?.response?.status || err?.statusCode || 401;
|
|
42
|
-
const errorData = err?.response?._data || err?.data;
|
|
43
|
-
let errorMessage = "Authentication failed";
|
|
44
|
-
let errorCode = "AUTHENTICATION_ERROR";
|
|
45
|
-
if (errorData?.error) {
|
|
46
|
-
errorMessage = errorData.error.message || errorData.message || errorMessage;
|
|
47
|
-
errorCode = errorData.error.code || errorCode;
|
|
48
|
-
}
|
|
49
|
-
return sendError(
|
|
50
|
-
event,
|
|
51
|
-
createError({
|
|
52
|
-
statusCode,
|
|
53
|
-
statusMessage: errorMessage,
|
|
54
|
-
data: {
|
|
55
|
-
code: errorCode,
|
|
56
|
-
details: errorData?.error?.details,
|
|
57
|
-
correlationId: errorData?.error?.correlationId
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getHeader, getCookie, deleteCookie } from "h3";
|
|
2
|
-
import { useRuntimeConfig } from "#imports";
|
|
3
|
-
import { $fetch } from "ofetch";
|
|
4
|
-
import {
|
|
5
|
-
ACCESS_TOKEN_KEY,
|
|
6
|
-
REFRESH_TOKEN_KEY,
|
|
7
|
-
EXP_TIME_KEY
|
|
8
|
-
} from "../../../constants/auth";
|
|
9
|
-
import { normalizeUrl } from "../../../utils/url";
|
|
10
|
-
export default defineEventHandler(async (event) => {
|
|
11
|
-
const config = useRuntimeConfig();
|
|
12
|
-
const apiUrl = config.public?.enfyraSDK?.apiUrl;
|
|
13
|
-
const refreshToken = getCookie(event, REFRESH_TOKEN_KEY);
|
|
14
|
-
try {
|
|
15
|
-
const result = await $fetch(normalizeUrl(apiUrl, "/auth/logout"), {
|
|
16
|
-
method: "POST",
|
|
17
|
-
headers: {
|
|
18
|
-
cookie: getHeader(event, "cookie") || "",
|
|
19
|
-
authorization: event.context.proxyHeaders?.authorization
|
|
20
|
-
},
|
|
21
|
-
body: {
|
|
22
|
-
refreshToken
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
deleteCookie(event, ACCESS_TOKEN_KEY);
|
|
26
|
-
deleteCookie(event, REFRESH_TOKEN_KEY);
|
|
27
|
-
deleteCookie(event, EXP_TIME_KEY);
|
|
28
|
-
return result;
|
|
29
|
-
} catch (err) {
|
|
30
|
-
deleteCookie(event, ACCESS_TOKEN_KEY);
|
|
31
|
-
deleteCookie(event, REFRESH_TOKEN_KEY);
|
|
32
|
-
deleteCookie(event, EXP_TIME_KEY);
|
|
33
|
-
return { success: false, message: "Logout completed locally" };
|
|
34
|
-
}
|
|
35
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { defineEventHandler, getCookie } from "h3";
|
|
2
|
-
import { useRuntimeConfig } from "#imports";
|
|
3
|
-
import {
|
|
4
|
-
validateTokens,
|
|
5
|
-
refreshAccessToken
|
|
6
|
-
} from "../../../utils/server/refreshToken";
|
|
7
|
-
import { REFRESH_TOKEN_KEY } from "../../../constants/auth";
|
|
8
|
-
export default defineEventHandler(async (event) => {
|
|
9
|
-
if (event.node.req.url === "/api/login" || event.node.req.url === "/api/logout") {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const { accessToken, needsRefresh } = validateTokens(event);
|
|
13
|
-
let currentAccessToken = accessToken;
|
|
14
|
-
if (needsRefresh) {
|
|
15
|
-
const refreshToken = getCookie(event, REFRESH_TOKEN_KEY);
|
|
16
|
-
if (refreshToken) {
|
|
17
|
-
try {
|
|
18
|
-
const config = useRuntimeConfig();
|
|
19
|
-
const apiUrl = config.public?.enfyraSDK?.apiUrl;
|
|
20
|
-
if (apiUrl) {
|
|
21
|
-
currentAccessToken = await refreshAccessToken(
|
|
22
|
-
event,
|
|
23
|
-
refreshToken,
|
|
24
|
-
apiUrl
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
} catch (error) {
|
|
28
|
-
currentAccessToken = null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (currentAccessToken) {
|
|
33
|
-
event.context.proxyHeaders = event.context.proxyHeaders || {};
|
|
34
|
-
event.context.proxyHeaders.authorization = `Bearer ${currentAccessToken}`;
|
|
35
|
-
}
|
|
36
|
-
});
|
package/module.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineNuxtModule,
|
|
3
|
-
createResolver,
|
|
4
|
-
addServerHandler,
|
|
5
|
-
addImportsDir,
|
|
6
|
-
addPlugin,
|
|
7
|
-
} from "@nuxt/kit";
|
|
8
|
-
import { ENFYRA_API_PREFIX } from "./src/constants/config";
|
|
9
|
-
|
|
10
|
-
export interface ModuleOptions {
|
|
11
|
-
apiUrl: string;
|
|
12
|
-
apiPrefix?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default defineNuxtModule<ModuleOptions>({
|
|
16
|
-
meta: {
|
|
17
|
-
name: "@enfyra/sdk-nuxt",
|
|
18
|
-
configKey: "enfyraSDK",
|
|
19
|
-
},
|
|
20
|
-
defaults: {
|
|
21
|
-
apiUrl: "",
|
|
22
|
-
apiPrefix: ENFYRA_API_PREFIX,
|
|
23
|
-
},
|
|
24
|
-
setup(options, nuxt) {
|
|
25
|
-
const normalizedOptions = {
|
|
26
|
-
...options,
|
|
27
|
-
apiUrl:
|
|
28
|
-
typeof options.apiUrl === "string"
|
|
29
|
-
? options.apiUrl.replace(/\/+$/, "")
|
|
30
|
-
: options.apiUrl,
|
|
31
|
-
apiPrefix:
|
|
32
|
-
typeof options.apiPrefix === "string"
|
|
33
|
-
? (options.apiPrefix.trim()
|
|
34
|
-
? "/" + options.apiPrefix.replace(/^\/+|\/+$/g, "").replace(/\/+/g, "/")
|
|
35
|
-
: ENFYRA_API_PREFIX)
|
|
36
|
-
: ENFYRA_API_PREFIX,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const apiPrefix = normalizedOptions.apiPrefix;
|
|
40
|
-
const { resolve } = createResolver(import.meta.url);
|
|
41
|
-
|
|
42
|
-
if (!normalizedOptions.apiUrl) {
|
|
43
|
-
console.warn(
|
|
44
|
-
`[Enfyra SDK Nuxt] Missing required configuration:\n` +
|
|
45
|
-
`- apiUrl is required\n` +
|
|
46
|
-
`Please configure it in your nuxt.config.ts:\n` +
|
|
47
|
-
`enfyraSDK: {\n` +
|
|
48
|
-
` apiUrl: 'https://your-api-url'\n` +
|
|
49
|
-
`}`
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
nuxt.options.runtimeConfig.public.enfyraSDK = {
|
|
53
|
-
...normalizedOptions,
|
|
54
|
-
apiPrefix: apiPrefix,
|
|
55
|
-
configError: true,
|
|
56
|
-
configErrorMessage: 'Enfyra SDK: apiUrl is required. Please configure it in nuxt.config.ts'
|
|
57
|
-
};
|
|
58
|
-
} else {
|
|
59
|
-
nuxt.options.runtimeConfig.public.enfyraSDK = {
|
|
60
|
-
...normalizedOptions,
|
|
61
|
-
apiPrefix: apiPrefix,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (!normalizedOptions.apiUrl) {
|
|
67
|
-
addPlugin({
|
|
68
|
-
src: resolve("./dist/runtime/plugin/config-error.client.mjs"),
|
|
69
|
-
mode: 'client'
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
addImportsDir(resolve("./src/composables"));
|
|
74
|
-
|
|
75
|
-
nuxt.hook('prepare:types', ({ declarations, references }: any) => {
|
|
76
|
-
references.push({
|
|
77
|
-
path: resolve('./src/types/nuxt-imports.d.ts'),
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
addServerHandler({
|
|
82
|
-
handler: resolve('./dist/runtime/server/middleware/auth.mjs'),
|
|
83
|
-
middleware: true,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
addServerHandler({
|
|
87
|
-
route: `${apiPrefix}/login`,
|
|
88
|
-
handler: resolve('./dist/runtime/server/api/login.post.mjs'),
|
|
89
|
-
method: "post",
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
addServerHandler({
|
|
93
|
-
route: `${apiPrefix}/logout`,
|
|
94
|
-
handler: resolve('./dist/runtime/server/api/logout.post.mjs'),
|
|
95
|
-
method: "post",
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
addServerHandler({
|
|
100
|
-
route: "/assets/**",
|
|
101
|
-
handler: resolve('./dist/runtime/server/api/all.mjs'),
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
addServerHandler({
|
|
105
|
-
route: `${apiPrefix}/**`,
|
|
106
|
-
handler: resolve('./dist/runtime/server/api/all.mjs'),
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type declarations for Nuxt auto-imports
|
|
3
|
-
* These are provided at runtime by Nuxt but need declarations for TypeScript
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
declare global {
|
|
7
|
-
const useEnfyraApi: typeof import('../composables/useEnfyraApi').useEnfyraApi
|
|
8
|
-
const useEnfyraAuth: typeof import('../composables/useEnfyraAuth').useEnfyraAuth
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
declare module '#imports' {
|
|
12
|
-
export const useRuntimeConfig: () => {
|
|
13
|
-
public: {
|
|
14
|
-
enfyraSDK?: {
|
|
15
|
-
apiUrl?: string;
|
|
16
|
-
apiPrefix?: string;
|
|
17
|
-
configError?: boolean;
|
|
18
|
-
configErrorMessage?: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const useRequestHeaders: (headers?: string[]) => Record<string, string | undefined>;
|
|
25
|
-
|
|
26
|
-
export const useRequestURL: () => URL;
|
|
27
|
-
|
|
28
|
-
export const useFetch: <T = any>(
|
|
29
|
-
url: string | (() => string),
|
|
30
|
-
options?: any
|
|
31
|
-
) => any;
|
|
32
|
-
|
|
33
|
-
export const useNuxtApp: () => {
|
|
34
|
-
payload: {
|
|
35
|
-
data: Record<string, any>;
|
|
36
|
-
[key: string]: any;
|
|
37
|
-
};
|
|
38
|
-
static: {
|
|
39
|
-
data: Record<string, any>;
|
|
40
|
-
[key: string]: any;
|
|
41
|
-
};
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const defineNuxtPlugin: (plugin: any) => any;
|
|
46
|
-
|
|
47
|
-
export const defineCachedEventHandler: (handler: any, options?: any) => any;
|
|
48
|
-
|
|
49
|
-
export const getCookie: (event: any, name: string) => string | undefined;
|
|
50
|
-
|
|
51
|
-
export const setCookie: (event: any, name: string, value: string, options?: any) => void;
|
|
52
|
-
|
|
53
|
-
export const deleteCookie: (event: any, name: string, options?: any) => void;
|
|
54
|
-
|
|
55
|
-
export const createError: (options: {
|
|
56
|
-
statusCode?: number;
|
|
57
|
-
statusMessage?: string;
|
|
58
|
-
message?: string;
|
|
59
|
-
data?: any;
|
|
60
|
-
}) => Error;
|
|
61
|
-
}
|
package/src/utils/config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ref } from 'vue';
|
|
2
|
-
import type { EnfyraConfig } from '../types';
|
|
3
|
-
|
|
4
|
-
const config = ref<EnfyraConfig>({
|
|
5
|
-
apiUrl: '',
|
|
6
|
-
defaultHeaders: {}
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export function useEnfyraConfig() {
|
|
10
|
-
const setConfig = (newConfig: Partial<EnfyraConfig>) => {
|
|
11
|
-
config.value = { ...config.value, ...newConfig };
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const getConfig = () => config.value;
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
setConfig,
|
|
18
|
-
getConfig
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { config };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|