nuxt-kirby 3.0.0 โ 3.0.1
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/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
- ๐ Protected Kirby credentials when sending queries
|
|
13
13
|
- ๐ชข Supports token-based authentication with the [Kirby Headless plugin](https://kirby.tools/docs/headless/getting-started/) (recommended)
|
|
14
|
-
- ๐ฑ Handle request just like with the [`useFetch`](https://nuxt.com/docs/getting-started/data-fetching
|
|
14
|
+
- ๐ฑ Handle request just like with the [`useFetch`](https://nuxt.com/docs/getting-started/data-fetching) composable
|
|
15
15
|
- ๐ฆฆ [Multiple starter kits](https://nuxt-kirby.byjohann.dev/essentials/starter-kits) available
|
|
16
16
|
- ๐ Cached query responses
|
|
17
17
|
- ๐คน No CORS issues!
|
package/dist/module.d.mts
CHANGED
|
@@ -8,9 +8,17 @@ interface ModuleOptions {
|
|
|
8
8
|
* @default process.env.KIRBY_BASE_URL
|
|
9
9
|
*/
|
|
10
10
|
url?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Kirby KQL API endpoint path
|
|
13
|
+
*
|
|
14
|
+
* @default 'api/query' // for `basic` authentication
|
|
15
|
+
* @default 'api/kql' // for `bearer` authentication
|
|
16
|
+
*/
|
|
17
|
+
kqlPath?: string;
|
|
11
18
|
/**
|
|
12
19
|
* Kirby KQL API route path
|
|
13
20
|
*
|
|
21
|
+
* @deprecated Use `kqlPath` instead
|
|
14
22
|
* @default 'api/query' // for `basic` authentication
|
|
15
23
|
* @default 'api/kql' // for `bearer` authentication
|
|
16
24
|
*/
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -34,7 +34,7 @@ async function prefetchQueries(options) {
|
|
|
34
34
|
try {
|
|
35
35
|
results.set(
|
|
36
36
|
key,
|
|
37
|
-
await ofetch(options.
|
|
37
|
+
await ofetch(options.kqlPath, {
|
|
38
38
|
baseURL: options.url,
|
|
39
39
|
method: "POST",
|
|
40
40
|
body: language ? query.query : query,
|
|
@@ -85,6 +85,7 @@ const module = defineNuxtModule({
|
|
|
85
85
|
},
|
|
86
86
|
defaults: {
|
|
87
87
|
url: process.env.KIRBY_BASE_URL || "",
|
|
88
|
+
kqlPath: "",
|
|
88
89
|
prefix: "",
|
|
89
90
|
auth: "basic",
|
|
90
91
|
token: process.env.KIRBY_API_TOKEN || "",
|
|
@@ -110,11 +111,15 @@ const module = defineNuxtModule({
|
|
|
110
111
|
logger.error("Missing `KIRBY_API_USERNAME` and `KIRBY_API_PASSWORD` environment variable for basic authentication");
|
|
111
112
|
if (options.auth === "bearer" && !options.token)
|
|
112
113
|
logger.error("Missing `KIRBY_API_TOKEN` environment variable for bearer authentication");
|
|
113
|
-
if (!options.
|
|
114
|
+
if (options.prefix && !options.kqlPath) {
|
|
115
|
+
logger.warn("The `prefix` option is deprecated. Please use `kqlPath` instead.");
|
|
116
|
+
options.kqlPath = options.prefix;
|
|
117
|
+
}
|
|
118
|
+
if (!options.kqlPath) {
|
|
114
119
|
if (options.auth === "basic")
|
|
115
|
-
options.
|
|
120
|
+
options.kqlPath = "api/query";
|
|
116
121
|
else if (options.auth === "bearer")
|
|
117
|
-
options.
|
|
122
|
+
options.kqlPath = "api/kql";
|
|
118
123
|
}
|
|
119
124
|
if (!nuxt.options.ssr) {
|
|
120
125
|
logger.info("Kirby requests are client-only because SSR is disabled");
|
|
@@ -38,7 +38,7 @@ export function $kql(query, opts = {}) {
|
|
|
38
38
|
},
|
|
39
39
|
body: query
|
|
40
40
|
};
|
|
41
|
-
const request = useRequestFetch()(kirby.client ? kirby.
|
|
41
|
+
const request = useRequestFetch()(kirby.client ? kirby.kqlPath : buildApiProxyPath(_key), {
|
|
42
42
|
...fetchOptions,
|
|
43
43
|
...kirby.client ? _clientFetchOptions : _serverFetchOptions
|
|
44
44
|
}).then((response) => {
|
|
@@ -27,7 +27,7 @@ export default defineEventHandler(async (event) => {
|
|
|
27
27
|
body: body2
|
|
28
28
|
}) => {
|
|
29
29
|
const isQueryRequest2 = key2.startsWith("$kql");
|
|
30
|
-
const response = await globalThis.$fetch.raw(isQueryRequest2 ? kirby.
|
|
30
|
+
const response = await globalThis.$fetch.raw(isQueryRequest2 ? kirby.kqlPath : path, {
|
|
31
31
|
responseType: "arrayBuffer",
|
|
32
32
|
ignoreResponseError: true,
|
|
33
33
|
baseURL: kirby.url,
|
|
@@ -18,7 +18,7 @@ export function $kirby(path, opts = {}) {
|
|
|
18
18
|
export function $kql(query, opts = {}) {
|
|
19
19
|
const { headers, language, ...fetchOptions } = opts;
|
|
20
20
|
const kirby = useRuntimeConfig().kirby;
|
|
21
|
-
return globalThis.$fetch(kirby.
|
|
21
|
+
return globalThis.$fetch(kirby.kqlPath, {
|
|
22
22
|
...fetchOptions,
|
|
23
23
|
baseURL: kirby.url,
|
|
24
24
|
method: "POST",
|
package/package.json
CHANGED