@dyrected/nuxt 2.3.1 → 2.3.3
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,11 +1,13 @@
|
|
|
1
|
-
import { useRuntimeConfig, useAsyncData } from "#app";
|
|
1
|
+
import { useRuntimeConfig, useAsyncData, useRequestFetch } from "#app";
|
|
2
2
|
import { createClient } from "@dyrected/sdk";
|
|
3
3
|
function getClient() {
|
|
4
4
|
const config = useRuntimeConfig().public.dyrected;
|
|
5
|
+
const fetcher = useRequestFetch();
|
|
5
6
|
return createClient({
|
|
6
7
|
baseUrl: config.baseUrl,
|
|
7
8
|
apiKey: config.apiKey,
|
|
8
|
-
siteId: config.siteId
|
|
9
|
+
siteId: config.siteId,
|
|
10
|
+
fetch: fetcher
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
export const useDyrected = () => {
|
|
@@ -20,15 +22,17 @@ export const useDyrectedDoc = (collection, id, options) => {
|
|
|
20
22
|
};
|
|
21
23
|
export const useDyrectedCollection = (collection, options) => {
|
|
22
24
|
const client = getClient();
|
|
25
|
+
const key = `dyrected:coll:${collection}:${JSON.stringify(options || {})}`;
|
|
23
26
|
return useAsyncData(
|
|
24
|
-
|
|
27
|
+
key,
|
|
25
28
|
() => client.collection(collection).find(options).exec()
|
|
26
29
|
);
|
|
27
30
|
};
|
|
28
31
|
export function useDyrectedGlobal(slug, options) {
|
|
29
32
|
const client = getClient();
|
|
33
|
+
const key = `dyrected:global:${slug}:${JSON.stringify(options || {})}`;
|
|
30
34
|
return useAsyncData(
|
|
31
|
-
|
|
35
|
+
key,
|
|
32
36
|
() => client.global(slug).get(options),
|
|
33
37
|
{ watch: options?.watch }
|
|
34
38
|
);
|
|
@@ -57,6 +57,13 @@ export default defineEventHandler(async (event) => {
|
|
|
57
57
|
duplex: "half"
|
|
58
58
|
});
|
|
59
59
|
const response = await app.fetch(request);
|
|
60
|
+
const responseData = await response.clone().json().catch(() => null);
|
|
61
|
+
if (process.env.DEBUG_DYRECTED) {
|
|
62
|
+
console.log(`[dyrected/api] ${method} ${path} ${response.status}`);
|
|
63
|
+
if (responseData) {
|
|
64
|
+
console.log(`[dyrected/api] Response Docs Count:`, responseData.docs?.length);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
60
67
|
if (response.status === 404) {
|
|
61
68
|
console.warn(`[dyrected/nuxt] 404 Not Found: ${path}`);
|
|
62
69
|
console.log("[dyrected/nuxt] Available routes:");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyrected/nuxt",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/module.mjs",
|
|
6
6
|
"types": "./dist/module.d.ts",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@nuxt/kit": "^3.11.2",
|
|
12
12
|
"h3": "^1.15.0",
|
|
13
|
-
"@dyrected/admin": "2.4.
|
|
14
|
-
"@dyrected/core": "2.4.
|
|
15
|
-
"@dyrected/sdk": "2.4.
|
|
13
|
+
"@dyrected/admin": "2.4.2",
|
|
14
|
+
"@dyrected/core": "2.4.1",
|
|
15
|
+
"@dyrected/sdk": "2.4.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"nuxt": "^3.0.0",
|