diff --git a/backend/package.json b/backend/package.json index 0bbd885..0a3c30d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -29,7 +29,6 @@ "@infisical/sdk": "^4.0.6", "@mmote/niimbluelib": "^0.0.1-alpha.29", "@prisma/client": "^6.15.0", - "@supabase/supabase-js": "^2.56.1", "@zip.js/zip.js": "^2.7.73", "archiver": "^7.0.1", "axios": "^1.12.1", diff --git a/backend/src/index.ts b/backend/src/index.ts index 46bbacd..f9edff1 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,6 +1,5 @@ import Fastify from "fastify"; import swaggerPlugin from "./plugins/swagger" -import supabasePlugin from "./plugins/supabase"; import dayjsPlugin from "./plugins/dayjs"; import healthRoutes from "./routes/health"; import meRoutes from "./routes/auth/me"; @@ -73,7 +72,6 @@ async function main() { // Plugins Global verfügbar await app.register(swaggerPlugin); - await app.register(supabasePlugin); await app.register(tenantPlugin); await app.register(dayjsPlugin); await app.register(dbPlugin); diff --git a/backend/src/plugins/supabase.ts b/backend/src/plugins/supabase.ts deleted file mode 100644 index eb5ca98..0000000 --- a/backend/src/plugins/supabase.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { FastifyInstance } from "fastify"; -import fp from "fastify-plugin"; -import { createClient, SupabaseClient } from "@supabase/supabase-js"; -import {secrets} from "../utils/secrets"; - -export default fp(async (server: FastifyInstance) => { - const supabaseUrl = secrets.SUPABASE_URL - const supabaseServiceKey = secrets.SUPABASE_SERVICE_ROLE_KEY - const supabase: SupabaseClient = createClient(supabaseUrl, supabaseServiceKey); - - // Fastify um supabase erweitern - server.decorate("supabase", supabase); -}); - -declare module "fastify" { - interface FastifyInstance { - supabase: SupabaseClient; - } -} \ No newline at end of file diff --git a/backend/src/routes/exports.ts b/backend/src/routes/exports.ts index e00b4db..31f3aa1 100644 --- a/backend/src/routes/exports.ts +++ b/backend/src/routes/exports.ts @@ -1,6 +1,4 @@ import { FastifyInstance } from "fastify"; -import jwt from "jsonwebtoken"; -import {insertHistoryItem} from "../utils/history"; import {buildExportZip} from "../utils/export/datev"; import {s3} from "../utils/s3"; import {GetObjectCommand, PutObjectCommand} from "@aws-sdk/client-s3" @@ -9,6 +7,8 @@ import dayjs from "dayjs"; import {randomUUID} from "node:crypto"; import {secrets} from "../utils/secrets"; import {createSEPAExport} from "../utils/export/sepa"; +import {generatedexports} from "../../db/schema"; +import {eq} from "drizzle-orm"; const createDatevExport = async (server:FastifyInstance,req:any,startDate,endDate,beraternr,mandantennr) => { try { @@ -45,25 +45,21 @@ const createDatevExport = async (server:FastifyInstance,req:any,startDate,endDat console.log(url) - // 5) In Supabase-DB speichern - const { data, error } = await server.supabase - .from("exports") - .insert([ - { - tenant_id: req.user.tenant_id, - start_date: startDate, - end_date: endDate, - valid_until: dayjs().add(24,"hours").toISOString(), - file_path: fileKey, - url: url, - created_at: new Date().toISOString(), - }, - ]) - .select() - .single() + // 5) In Haupt-DB speichern + const inserted = await server.db + .insert(generatedexports) + .values({ + tenantId: req.user.tenant_id, + startDate: new Date(startDate), + endDate: new Date(endDate), + validUntil: dayjs().add(24, "hours").toDate(), + filePath: fileKey, + url, + type: "datev", + }) + .returning() - console.log(data) - console.log(error) + console.log(inserted[0]) } catch (error) { console.log(error) } @@ -120,9 +116,22 @@ export default async function exportRoutes(server: FastifyInstance) { //List Exports Available for Download server.get("/exports", async (req,reply) => { - const {data,error} = await server.supabase.from("exports").select().eq("tenant_id",req.user.tenant_id) + const data = await server.db + .select({ + id: generatedexports.id, + created_at: generatedexports.createdAt, + tenant_id: generatedexports.tenantId, + start_date: generatedexports.startDate, + end_date: generatedexports.endDate, + valid_until: generatedexports.validUntil, + type: generatedexports.type, + url: generatedexports.url, + file_path: generatedexports.filePath, + }) + .from(generatedexports) + .where(eq(generatedexports.tenantId, req.user.tenant_id)) - console.log(data,error) + console.log(data) reply.send(data) }) @@ -131,4 +140,4 @@ export default async function exportRoutes(server: FastifyInstance) { -} \ No newline at end of file +} diff --git a/backend/src/routes/health.ts b/backend/src/routes/health.ts index a1d8e19..1594ad8 100644 --- a/backend/src/routes/health.ts +++ b/backend/src/routes/health.ts @@ -3,12 +3,11 @@ import { FastifyInstance } from "fastify"; export default async function routes(server: FastifyInstance) { server.get("/ping", async () => { // Testquery gegen DB - const { data, error } = await server.supabase.from("tenants").select("id").limit(1); + const result = await server.db.execute("SELECT NOW()"); return { status: "ok", - db: error ? "not connected" : "connected", - tenant_count: data?.length ?? 0 + db: JSON.stringify(result.rows[0]), }; }); } \ No newline at end of file diff --git a/backend/src/utils/secrets.ts b/backend/src/utils/secrets.ts index c21e2d7..6abeaf8 100644 --- a/backend/src/utils/secrets.ts +++ b/backend/src/utils/secrets.ts @@ -14,8 +14,6 @@ export let secrets = { PORT: number HOST: string DATABASE_URL: string - SUPABASE_URL: string - SUPABASE_SERVICE_ROLE_KEY: string S3_BUCKET: string ENCRYPTION_KEY: string MAILER_SMTP_HOST: string diff --git a/frontend/composables/useErrorLogging.js b/frontend/composables/useErrorLogging.js deleted file mode 100644 index 298ccd0..0000000 --- a/frontend/composables/useErrorLogging.js +++ /dev/null @@ -1,25 +0,0 @@ - -export const useErrorLogging = (resourceType) => { - const supabase = useSupabaseClient() - const toast = useToast() - const profileStore = useProfileStore() - - const logError = async (error) => { - let errorData = { - message: error, - tenant: profileStore.currentTenant, - profile: profileStore.activeProfile.id - } - - const {data:supabaseData,error:supabaseError} = await supabase.from("errors").insert(errorData).select().single() - - if(supabaseError) { - console.error(supabaseError) - } else if(supabaseData) { - return supabaseData.id - } - - } - - return { logError} -} diff --git a/frontend/composables/useFiles.ts b/frontend/composables/useFiles.ts index 7323c8e..4e0edd5 100644 --- a/frontend/composables/useFiles.ts +++ b/frontend/composables/useFiles.ts @@ -1,6 +1,5 @@ export const useFiles = () => { - const supabase = useSupabaseClient() const toast = useToast() const auth = useAuthStore() diff --git a/frontend/composables/useNumberRange.js b/frontend/composables/useNumberRange.js deleted file mode 100644 index 27131e2..0000000 --- a/frontend/composables/useNumberRange.js +++ /dev/null @@ -1,61 +0,0 @@ - -export const useNumberRange = (resourceType) => { - const supabase = useSupabaseClient() - - const dataStore = useDataStore() - const profileStore = useProfileStore() - - const numberRanges = profileStore.ownTenant.numberRanges - - const numberRange = numberRanges[resourceType] - - const useNextNumber = async () => { - - let nextNumber = numberRange.nextNumber - - let newNumberRanges = numberRanges - - newNumberRanges[resourceType].nextNumber += 1 - - const {data,error} = await supabase - .from("tenants") - .update({numberRanges: newNumberRanges}) - .eq('id',profileStore.currentTenant) - - - await profileStore.fetchOwnTenant() - - return (numberRange.prefix ? numberRange.prefix : "") + nextNumber + (numberRange.suffix ? numberRange.suffix : "") - } - - return { useNextNumber} -} - -/*export const useNumberRange = (resourceType) => { - const supabase = useSupabaseClient() - - const {numberRanges} = storeToRefs(useDataStore()) - const {fetchNumberRanges} = useDataStore() - - const numberRange = numberRanges.value.find(range => range.resourceType === resourceType) - - - - - const useNextNumber = async () => { - - let nextNumber = numberRange.nextNumber - - const {data,error} = await supabase - .from("numberranges") - .update({nextNumber: nextNumber + 1}) - .eq('id',numberRange.id) - - fetchNumberRanges() - - return (numberRange.prefix ? numberRange.prefix : "") + nextNumber + (numberRange.suffix ? numberRange.suffix : "") - - } - - return { useNextNumber} -}*/ \ No newline at end of file diff --git a/frontend/composables/usePrintLabel.js b/frontend/composables/usePrintLabel.js deleted file mode 100644 index 9ce3245..0000000 --- a/frontend/composables/usePrintLabel.js +++ /dev/null @@ -1,27 +0,0 @@ - -import Handlebars from "handlebars"; - -export const usePrintLabel = async (printServerId,printerName , rawZPL ) => { - const supabase = useSupabaseClient() - const dataStore = useDataStore() - const profileStore = useProfileStore() - - await supabase.from("printJobs").insert({ - tenant: profileStore.currentTenant, - rawContent: rawZPL, - printerName: printerName, - printServer: printServerId - }) - - - -} - -export const useGenerateZPL = (rawZPL,data) => { - let template = Handlebars.compile(rawZPL) - - return template(data) -} - - - diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index 20c8874..63eaffe 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -34,12 +34,6 @@ export default defineNuxtConfig({ }, - supabase: { - key: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV3cHB2Y3hmbHJjc2lidXpzYmlsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDA5MzgxOTQsImV4cCI6MjAxNjUxNDE5NH0.CkxYSQH0uLfwx9GVUlO6AYMU2FMLAxGMrwEKvyPv7Oo", - url: "https://uwppvcxflrcsibuzsbil.supabase.co", - redirect: false - }, - vite: { resolve: { dedupe: [ diff --git a/frontend/package.json b/frontend/package.json index 978da93..2015e64 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,7 +12,6 @@ "devDependencies": { "@capacitor/cli": "^7.0.0", "@nuxtjs/leaflet": "^1.2.3", - "@nuxtjs/supabase": "^1.1.4", "@vite-pwa/nuxt": "^1.1.0", "@vueuse/core": "^14.1.0", "@vueuse/nuxt": "^14.1.0", diff --git a/frontend/stores/data.js b/frontend/stores/data.js index 153c06e..1b1febb 100644 --- a/frontend/stores/data.js +++ b/frontend/stores/data.js @@ -1,7 +1,6 @@ import {defineStore} from 'pinia' import dayjs from "dayjs" //import {typeOf} from "uri-js/dist/esnext/util"; -import {useNumberRange} from "~/composables/useNumberRange.js"; import projecttype from "~/components/columnRenderings/projecttype.vue"