@dyrected/nuxt 0.0.1 → 1.0.0

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/LICENSE.md ADDED
@@ -0,0 +1,50 @@
1
+ Business Source License 1.1
2
+
3
+ Parameters
4
+
5
+ Licensor: Ajola Technologies Ltd
6
+ Licensed Work: Dyrected
7
+ Additional Use Grant: Commercial use is permitted as long as it is not used to provide a hosted or managed service that competes with Dyrected.
8
+ Change Date: 2030-05-11
9
+ Change License: Apache License 2.0
10
+
11
+ ---
12
+
13
+ Business Source License 1.1
14
+
15
+ License text copyright © 2024 MariaDB plc, All Rights Reserved.
16
+ “Business Source License” is a trademark of MariaDB plc.
17
+
18
+ ### Terms
19
+
20
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
21
+
22
+ Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
23
+
24
+ If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
25
+
26
+ All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
27
+
28
+ You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
29
+
30
+ Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
31
+
32
+ This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License).
33
+
34
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
35
+
36
+ MariaDB hereby grants you permission to use this License’s text to license your works, and to refer to it using the trademark “Business Source License”, as long as you comply with the Covenants of Licensor below.
37
+
38
+ ### Covenants of Licensor
39
+
40
+ In consideration of the right to use this License’s text and the “Business Source License” name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
41
+
42
+ 1. To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where “compatible” means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
43
+
44
+ 2. To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text “None”.
45
+
46
+ 3. Not to modify this License in any other way.
47
+
48
+ ---
49
+
50
+ The Business Source License (this document, or the “License”) is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
package/README.md CHANGED
@@ -1,3 +1,43 @@
1
1
  # @dyrected/nuxt
2
2
 
3
- This is the nuxt package/app for the Dyrected ecosystem.
3
+ This is the Nuxt module for the Dyrected ecosystem.
4
+
5
+ ## Composables
6
+
7
+ ### `useDyrectedCollection`
8
+
9
+ Fetch a collection of documents with auto-seeding support.
10
+
11
+ ```vue
12
+ <script setup>
13
+ const { data: posts } = await useDyrectedCollection('posts', {
14
+ initialData: [
15
+ { title: 'Welcome to Dyrected', content: '...' }
16
+ ]
17
+ })
18
+ </script>
19
+ ```
20
+
21
+ ### `useDyrectedDoc`
22
+
23
+ Fetch a single document.
24
+
25
+ ```vue
26
+ <script setup>
27
+ const { data: post } = await useDyrectedDoc('posts', 'my-post-slug', {
28
+ initialData: { title: 'Default Post', content: '...' }
29
+ })
30
+ </script>
31
+ ```
32
+
33
+ ### `useDyrectedGlobal`
34
+
35
+ Fetch global settings.
36
+
37
+ ```vue
38
+ <script setup>
39
+ const { data: settings } = await useDyrectedGlobal('site-settings', {
40
+ initialData: { siteName: 'My Awesome Site' }
41
+ })
42
+ </script>
43
+ ```
package/dist/module.d.mts CHANGED
@@ -4,9 +4,15 @@ import { NuxtModule } from '@nuxt/schema';
4
4
  interface ModuleOptions extends DyrectedConfig {
5
5
  /**
6
6
  * Mount the Dyrected API on this path.
7
- * @default '/api/dyrected'
7
+ * @default '/dyrected'
8
8
  */
9
9
  apiBase?: string;
10
+ /** API key passed to the SDK client for request authentication. */
11
+ apiKey?: string;
12
+ /** Site ID used to scope content to a specific tenant site. */
13
+ siteId?: string;
14
+ /** Optional manual path to the dyrected config file (absolute or relative to root). */
15
+ configPath?: string;
10
16
  }
11
17
 
12
18
  declare const module: NuxtModule<ModuleOptions>;
package/dist/module.d.ts CHANGED
@@ -4,9 +4,15 @@ import { NuxtModule } from '@nuxt/schema';
4
4
  interface ModuleOptions extends DyrectedConfig {
5
5
  /**
6
6
  * Mount the Dyrected API on this path.
7
- * @default '/api/dyrected'
7
+ * @default '/dyrected'
8
8
  */
9
9
  apiBase?: string;
10
+ /** API key passed to the SDK client for request authentication. */
11
+ apiKey?: string;
12
+ /** Site ID used to scope content to a specific tenant site. */
13
+ siteId?: string;
14
+ /** Optional manual path to the dyrected config file (absolute or relative to root). */
15
+ configPath?: string;
10
16
  }
11
17
 
12
18
  declare const module: NuxtModule<ModuleOptions>;
package/dist/module.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import { defineNuxtModule, createResolver, addServerHandler, addComponent, addImports } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addServerHandler, addComponent, addImports, addServerPlugin } from '@nuxt/kit';
2
+ import { join } from 'path';
3
+ import { existsSync } from 'fs';
2
4
 
3
5
  const module = defineNuxtModule({
4
6
  meta: {
@@ -6,25 +8,68 @@ const module = defineNuxtModule({
6
8
  configKey: "dyrected"
7
9
  },
8
10
  defaults: {
9
- apiBase: "/api/dyrected"
11
+ apiBase: "/dyrected"
10
12
  },
11
13
  setup(options, nuxt) {
12
14
  const resolver = createResolver(import.meta.url);
13
- addServerHandler({
14
- route: `${options.apiBase}/**`,
15
- handler: resolver.resolve("./runtime/server/handler")
16
- });
15
+ if (options.apiBase?.startsWith("/")) {
16
+ addServerHandler({
17
+ route: `${options.apiBase}/**`,
18
+ handler: resolver.resolve("./runtime/server/handler")
19
+ });
20
+ }
17
21
  addComponent({
18
22
  name: "DyrectedMedia",
19
23
  filePath: resolver.resolve("./runtime/components/DyrectedMedia.vue")
20
24
  });
25
+ addComponent({
26
+ name: "DyrectedAdmin",
27
+ filePath: resolver.resolve("./runtime/components/DyrectedAdmin.vue")
28
+ });
21
29
  addImports([
22
30
  { name: "useDyrected", from: resolver.resolve("./runtime/composables/useDyrected") },
23
- { name: "useDyrectedDoc", from: resolver.resolve("./runtime/composables/useDyrected") }
31
+ { name: "useDyrectedDoc", from: resolver.resolve("./runtime/composables/useDyrected") },
32
+ { name: "useDyrectedCollection", from: resolver.resolve("./runtime/composables/useDyrected") },
33
+ { name: "useDyrectedGlobal", from: resolver.resolve("./runtime/composables/useDyrected") },
34
+ { name: "useDyrectedAuth", from: resolver.resolve("./runtime/composables/useDyrectedAuth") },
35
+ { name: "useLivePreview", from: resolver.resolve("./runtime/composables/useLivePreview") }
24
36
  ]);
25
- nuxt.options.runtimeConfig.public.dyrected = {
37
+ const runtimeConfig = {
38
+ ...options,
26
39
  baseUrl: options.apiBase
27
40
  };
41
+ const configFiles = ["dyrected.config.ts", "dyrected.config.js", "dyrected.config.mjs"];
42
+ let configPath = options.configPath ? join(nuxt.options.rootDir, options.configPath) : "";
43
+ if (!configPath) {
44
+ for (const file of configFiles) {
45
+ const fullPath = join(nuxt.options.rootDir, file);
46
+ if (existsSync(fullPath)) {
47
+ configPath = fullPath;
48
+ break;
49
+ }
50
+ }
51
+ }
52
+ if (configPath) {
53
+ console.log("[dyrected/nuxt] Auto-detected config at:", configPath);
54
+ runtimeConfig.configPath = configPath;
55
+ addServerPlugin(resolver.resolve("./runtime/server/plugins/db"));
56
+ } else {
57
+ console.warn("[dyrected/nuxt] Could not find dyrected.config.ts. Self-hosted database re-hydration might fail.");
58
+ }
59
+ if (options.db) {
60
+ Object.defineProperty(runtimeConfig, "db", {
61
+ value: options.db,
62
+ enumerable: false,
63
+ configurable: true,
64
+ writable: true
65
+ });
66
+ }
67
+ nuxt.options.runtimeConfig.dyrected = runtimeConfig;
68
+ nuxt.options.runtimeConfig.public.dyrected = {
69
+ baseUrl: options.apiBase,
70
+ apiKey: options.apiKey,
71
+ siteId: options.siteId
72
+ };
28
73
  }
29
74
  });
30
75
 
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <div ref="container" class="dyrected-admin-wrapper"></div>
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { ref, onMounted, onUnmounted, nextTick } from "vue";
7
+ import "@dyrected/admin/styles";
8
+ // @ts-ignore
9
+ import { useRuntimeConfig } from "#imports";
10
+
11
+ const props = defineProps<{
12
+ /**
13
+ * The base path where the admin is mounted.
14
+ * @default "/cms-admin"
15
+ */
16
+ basename?: string;
17
+ }>();
18
+
19
+ const config = useRuntimeConfig();
20
+ const container = ref<HTMLElement | null>(null);
21
+ let unmount: (() => void) | null = null;
22
+
23
+ onMounted(async () => {
24
+ await nextTick();
25
+
26
+ if (container.value) {
27
+ try {
28
+ // 1. Dynamically import to ensure isolation from Vue's early bundle phase
29
+ const { renderAdminUI } = await import("@dyrected/admin");
30
+
31
+ // 2. Deep clone config to strip ALL Vue proxies/reactivity
32
+ const dyrectedRaw = JSON.parse(JSON.stringify(config.public.dyrected));
33
+
34
+ unmount = renderAdminUI(container.value, {
35
+ apiKey: String(dyrectedRaw.apiKey || ""),
36
+ siteId: String(dyrectedRaw.siteId || ""),
37
+ baseUrl: String(dyrectedRaw.baseUrl || ""),
38
+ basename: props.basename || "/cms-admin",
39
+ isEmbedded: false,
40
+ });
41
+ } catch (err) {
42
+ console.error("[DyrectedAdmin] Failed to mount admin UI:", err);
43
+ }
44
+ }
45
+ });
46
+
47
+ onUnmounted(() => {
48
+ if (unmount) {
49
+ unmount();
50
+ }
51
+ });
52
+ </script>
53
+
54
+ <style scoped>
55
+ .dyrected-admin-wrapper{height:100vh;width:100vw}
56
+ </style>
@@ -1,4 +1,19 @@
1
- export declare const useDyrected: () => import("@dyrected/sdk").DyrectedClient;
2
- export declare const useDyrectedDoc: (collection: string, slug: string, options?: {
1
+ import { type DyrectedClient, type BaseSchema } from '@dyrected/sdk';
2
+ export declare const useDyrected: <TSchema extends BaseSchema = any>() => DyrectedClient<TSchema>;
3
+ export declare const useDyrectedDoc: <T = any, TSchema extends BaseSchema = any>(collection: keyof TSchema["collections"] | string, id: string, options?: {
3
4
  depth?: number;
4
- }) => Promise<any>;
5
+ initialData?: T;
6
+ }) => any;
7
+ export declare const useDyrectedCollection: <T = any, TSchema extends BaseSchema = any>(collection: keyof TSchema["collections"] | string, options?: {
8
+ depth?: number;
9
+ limit?: number;
10
+ page?: number;
11
+ sort?: string;
12
+ where?: any;
13
+ initialData?: T[];
14
+ }) => any;
15
+ export declare function useDyrectedGlobal<T = any, TSchema extends BaseSchema = any>(slug: keyof TSchema['globals'] | string, options?: {
16
+ depth?: number;
17
+ initialData?: T;
18
+ watch?: any[];
19
+ }): any;
@@ -1,13 +1,35 @@
1
+ import { useRuntimeConfig, useAsyncData } from "#app";
1
2
  import { createClient } from "@dyrected/sdk";
2
- import { useRuntimeConfig } from "#app";
3
- export const useDyrected = () => {
3
+ function getClient() {
4
4
  const config = useRuntimeConfig().public.dyrected;
5
- const client = createClient({
6
- baseUrl: config.baseUrl
5
+ return createClient({
6
+ baseUrl: config.baseUrl,
7
+ apiKey: config.apiKey,
8
+ siteId: config.siteId
7
9
  });
8
- return client;
10
+ }
11
+ export const useDyrected = () => {
12
+ return getClient();
13
+ };
14
+ export const useDyrectedDoc = (collection, id, options) => {
15
+ const client = getClient();
16
+ return useAsyncData(
17
+ `dyrected:doc:${collection}:${id}`,
18
+ () => client.findOne(collection, id, options)
19
+ );
9
20
  };
10
- export const useDyrectedDoc = (collection, slug, options) => {
11
- const client = useDyrected();
12
- return client.collection(collection).findOne(slug, options);
21
+ export const useDyrectedCollection = (collection, options) => {
22
+ const client = getClient();
23
+ return useAsyncData(
24
+ `dyrected:collection:${collection}`,
25
+ () => client.collection(collection).find(options).exec()
26
+ );
13
27
  };
28
+ export function useDyrectedGlobal(slug, options) {
29
+ const client = getClient();
30
+ return useAsyncData(
31
+ `dyrected:global:${slug}`,
32
+ () => client.global(slug).get(options),
33
+ { watch: options?.watch }
34
+ );
35
+ }
@@ -0,0 +1,23 @@
1
+ export interface DyrectedAuthUser {
2
+ id: string;
3
+ email: string;
4
+ [key: string]: any;
5
+ }
6
+ /**
7
+ * useDyrectedAuth — composable for auth collections.
8
+ *
9
+ * Usage:
10
+ * const { login, logout, user, isLoggedIn } = useDyrectedAuth('customers')
11
+ *
12
+ * The JWT is persisted in a cookie (`dyrected_token_<collection>`) so it
13
+ * survives page reloads and is available server-side on the next request.
14
+ */
15
+ export declare function useDyrectedAuth(collection: string): {
16
+ /** Reactive: the authenticated user, or null. */
17
+ user: any;
18
+ /** Reactive: true when a valid JWT cookie exists. */
19
+ isLoggedIn: any;
20
+ login: (email: string, password: string) => Promise<DyrectedAuthUser>;
21
+ logout: () => Promise<void>;
22
+ fetchMe: () => Promise<DyrectedAuthUser | null>;
23
+ };
@@ -0,0 +1,65 @@
1
+ import { useRuntimeConfig, useState, useCookie, computed } from "#app";
2
+ import { createClient } from "@dyrected/sdk";
3
+ export function useDyrectedAuth(collection) {
4
+ const config = useRuntimeConfig().public.dyrected;
5
+ const cookieName = `dyrected_token_${collection}`;
6
+ const tokenCookie = useCookie(cookieName, {
7
+ default: () => null,
8
+ maxAge: 60 * 60 * 24 * 7,
9
+ // 7 days
10
+ sameSite: "lax"
11
+ });
12
+ const user = useState(`dyrected:auth:user:${collection}`, () => null);
13
+ const isLoggedIn = computed(() => !!tokenCookie.value);
14
+ function buildClient() {
15
+ const client = createClient({
16
+ baseUrl: config.baseUrl,
17
+ apiKey: config.apiKey,
18
+ siteId: config.siteId
19
+ });
20
+ if (tokenCookie.value) {
21
+ client.setToken(tokenCookie.value);
22
+ }
23
+ return client;
24
+ }
25
+ async function login(email, password) {
26
+ const client = buildClient();
27
+ const { token, user: userData } = await client.collection(collection).login(email, password);
28
+ tokenCookie.value = token;
29
+ user.value = userData;
30
+ return userData;
31
+ }
32
+ async function logout() {
33
+ if (tokenCookie.value) {
34
+ try {
35
+ const client = buildClient();
36
+ await client.collection(collection).logout();
37
+ } catch {
38
+ }
39
+ }
40
+ tokenCookie.value = null;
41
+ user.value = null;
42
+ }
43
+ async function fetchMe() {
44
+ if (!tokenCookie.value) return null;
45
+ try {
46
+ const client = buildClient();
47
+ const me = await client.collection(collection).me();
48
+ user.value = me;
49
+ return me;
50
+ } catch {
51
+ tokenCookie.value = null;
52
+ user.value = null;
53
+ return null;
54
+ }
55
+ }
56
+ return {
57
+ /** Reactive: the authenticated user, or null. */
58
+ user,
59
+ /** Reactive: true when a valid JWT cookie exists. */
60
+ isLoggedIn,
61
+ login,
62
+ logout,
63
+ fetchMe
64
+ };
65
+ }
@@ -0,0 +1,35 @@
1
+ import { type Ref } from 'vue';
2
+ export interface LivePreviewOptions<T> {
3
+ /**
4
+ * The initial data to show before any postMessage arrives.
5
+ * Typically the server-fetched document passed from useAsyncData.
6
+ */
7
+ initialData: T;
8
+ /**
9
+ * The origin of the Dyrected Admin UI that will send preview messages.
10
+ * Defaults to '*' (accepts from any origin).
11
+ * Set this to your Admin URL in production for security.
12
+ */
13
+ serverURL?: string;
14
+ /**
15
+ * The depth at which to resolve relationships in the preview data.
16
+ */
17
+ depth?: number;
18
+ }
19
+ /**
20
+ * useLivePreview — Vue composable for Dyrected live preview (postMessage mode).
21
+ *
22
+ * The Admin UI sends postMessage events with draft document data when the
23
+ * editor changes. This composable listens for those messages and reactively
24
+ * updates `data` so the preview page re-renders in real time.
25
+ *
26
+ * Usage:
27
+ * const { data, isLive } = useLivePreview({ initialData: serverData.value })
28
+ *
29
+ * The parent page/component must be rendered inside an iframe by the Admin UI.
30
+ * Set `admin.previewUrl` in your collection config to point to that page.
31
+ */
32
+ export declare function useLivePreview<T = any>(options: LivePreviewOptions<T>): {
33
+ data: Ref<T>;
34
+ isLive: Ref<boolean>;
35
+ };
@@ -0,0 +1,33 @@
1
+ import { ref, onMounted, onUnmounted } from "vue";
2
+ export function useLivePreview(options) {
3
+ const data = ref(options.initialData);
4
+ const isLive = ref(false);
5
+ function handleMessage(event) {
6
+ const allowedOrigin = options.serverURL || "*";
7
+ if (allowedOrigin !== "*" && event.origin !== allowedOrigin) return;
8
+ const { type, data: payload } = event.data || {};
9
+ if (type === "dyrected-live-preview") {
10
+ data.value = payload;
11
+ isLive.value = true;
12
+ }
13
+ if (type === "dyrected-live-preview-ready") {
14
+ window.parent.postMessage({ type: "dyrected-live-preview-ack" }, allowedOrigin);
15
+ }
16
+ }
17
+ onMounted(() => {
18
+ window.addEventListener("message", handleMessage);
19
+ window.parent.postMessage({ type: "dyrected-live-preview-ready" }, options.serverURL || "*");
20
+ });
21
+ onUnmounted(() => {
22
+ window.removeEventListener("message", handleMessage);
23
+ });
24
+ return {
25
+ /** Reactively updated document data from the Admin UI editor. */
26
+ data,
27
+ /**
28
+ * True once the first postMessage from the Admin has been received.
29
+ * Useful to show a "Live preview active" indicator.
30
+ */
31
+ isLive
32
+ };
33
+ }
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<Response>>;
1
+ declare const _default: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<any>>;
2
2
  export default _default;
@@ -1,8 +1,63 @@
1
- import { eventHandler, toRequest } from "h3";
2
- import { createDyrectedApp } from "@dyrected/core";
1
+ import { eventHandler } from "h3";
2
+ import { createDyrectedApp } from "@dyrected/core/server";
3
3
  import { useRuntimeConfig } from "#imports";
4
+ let app;
4
5
  export default eventHandler(async (event) => {
5
6
  const config = useRuntimeConfig().dyrected;
6
- const app = createDyrectedApp(config);
7
- return app.fetch(toRequest(event.req));
7
+ if (!app) {
8
+ const dyrectedConfig = { ...config };
9
+ if (!dyrectedConfig.db || typeof dyrectedConfig.db.find !== "function") {
10
+ dyrectedConfig.db = globalThis.__dyrected_db;
11
+ }
12
+ if (!dyrectedConfig.storage || typeof dyrectedConfig.storage.upload !== "function") {
13
+ dyrectedConfig.storage = globalThis.__dyrected_storage;
14
+ }
15
+ console.log("[dyrected/nuxt] Initializing app. DB:", !!dyrectedConfig.db, "Storage:", !!dyrectedConfig.storage);
16
+ app = await createDyrectedApp(dyrectedConfig);
17
+ }
18
+ const req = event.node?.req || event.req;
19
+ const method = req?.method || "GET";
20
+ const headers = {};
21
+ const rawHeaders = req?.headers || {};
22
+ for (const key in rawHeaders) {
23
+ const val = rawHeaders[key];
24
+ if (Array.isArray(val)) {
25
+ headers[key] = val.join(", ");
26
+ } else if (val) {
27
+ headers[key] = String(val);
28
+ }
29
+ }
30
+ const originalUrl = req?.url || "/";
31
+ const apiBase = config.apiBase || "/dyrected";
32
+ const path = originalUrl.startsWith(apiBase) ? originalUrl.slice(apiBase.length) || "/" : originalUrl;
33
+ const protocol = headers["x-forwarded-proto"] || "http";
34
+ const host = headers["host"] || "localhost:3000";
35
+ const fullUrl = new URL(path, `${protocol}://${host}`);
36
+ let body = void 0;
37
+ if (!["GET", "HEAD"].includes(method)) {
38
+ if (req && typeof req.on === "function") {
39
+ body = await new Promise((resolve, reject) => {
40
+ const chunks = [];
41
+ req.on("data", (chunk) => chunks.push(chunk));
42
+ req.on("end", () => resolve(Buffer.concat(chunks)));
43
+ req.on("error", reject);
44
+ });
45
+ } else if (req && typeof req.arrayBuffer === "function") {
46
+ body = await req.arrayBuffer();
47
+ }
48
+ }
49
+ const request = new Request(fullUrl, {
50
+ method,
51
+ headers,
52
+ body,
53
+ // @ts-ignore
54
+ duplex: "half"
55
+ });
56
+ const response = await app.fetch(request);
57
+ if (response.status === 404) {
58
+ console.warn(`[dyrected/nuxt] 404 Not Found: ${path}`);
59
+ console.log("[dyrected/nuxt] Available routes:");
60
+ console.table(app.routes.map((r) => ({ method: r.method, path: r.path })));
61
+ }
62
+ return response;
8
63
  });
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import { defineNitroPlugin } from "nitro/runtime";
2
+ import { useRuntimeConfig } from "#imports";
3
+ export default defineNitroPlugin(async (nitroApp) => {
4
+ const runtimeConfig = useRuntimeConfig().dyrected;
5
+ if (runtimeConfig?.configPath) {
6
+ try {
7
+ const configPath = runtimeConfig.configPath;
8
+ const { default: userConfig } = await import(configPath);
9
+ if (userConfig && userConfig.db) {
10
+ globalThis.__dyrected_db = userConfig.db;
11
+ console.log("[dyrected/nuxt] Database re-attached to global context");
12
+ }
13
+ if (userConfig && userConfig.storage) {
14
+ globalThis.__dyrected_storage = userConfig.storage;
15
+ console.log("[dyrected/nuxt] Storage adapter re-attached to global context");
16
+ }
17
+ } catch (err) {
18
+ console.error("[dyrected/nuxt] Failed to re-attach database:", err);
19
+ }
20
+ }
21
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyrected/nuxt",
3
- "version": "0.0.1",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "main": "./dist/module.mjs",
6
6
  "types": "./dist/module.d.ts",
@@ -10,8 +10,9 @@
10
10
  "dependencies": {
11
11
  "@nuxt/kit": "^3.11.2",
12
12
  "h3": "2.0.1-rc.22",
13
- "@dyrected/core": "0.0.1",
14
- "@dyrected/sdk": "0.0.1"
13
+ "@dyrected/core": "1.0.0",
14
+ "@dyrected/sdk": "1.0.0",
15
+ "@dyrected/admin": "1.0.0"
15
16
  },
16
17
  "devDependencies": {
17
18
  "@nuxt/module-builder": "^0.5.5",