- Implemented `useDesignPersistence` composable for managing design records. - Enhanced `useSlipmatDesigner` to support loading designs from JSON. - Created global authentication middleware for route protection. - Added Supabase client plugin for database interactions. - Developed API endpoints for fetching, saving, and retrieving designs. - Introduced utility functions for Auth0 token verification and Supabase client retrieval. - Updated Nuxt configuration to include Auth0 and Supabase environment variables. - Added necessary dependencies for Auth0 and Supabase. - Enhanced TypeScript configuration for improved type support.
28 lines
779 B
TypeScript
28 lines
779 B
TypeScript
import { createClient, type SupabaseClient } from "@supabase/supabase-js";
|
|
import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
|
|
|
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
const { url, anonKey } = useRuntimeConfig().public.supabase;
|
|
|
|
if (!url || !anonKey) {
|
|
if (process.env.NODE_ENV !== "production") {
|
|
console.warn(
|
|
"Supabase configuration is incomplete. Set SUPABASE_URL and SUPABASE_ANON_KEY in your environment."
|
|
);
|
|
}
|
|
|
|
nuxtApp.provide("supabase", null);
|
|
return;
|
|
}
|
|
|
|
const supabase = createClient(url, anonKey, {
|
|
auth: {
|
|
persistSession: true,
|
|
storageKey: "slipmatz.supabase.auth",
|
|
},
|
|
});
|
|
|
|
nuxtApp.provide("supabase", supabase);
|
|
nuxtApp.vueApp.config.globalProperties.$supabase = supabase;
|
|
});
|