From 7d56b7a6a2d8dd94acda35088c41775170d2cfcb Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 16 Nov 2024 01:17:02 +0100 Subject: [PATCH] restructure --- .../api/integrations/credentials/get.ts | 23 --------------- .../integrations/credentials/update.post.ts | 23 --------------- .../api/integrations/supabase/add.post.ts | 29 ------------------- .../server/api/integrations/supabase/get.ts | 18 ------------ .../server/api/integrations/supabase/list.ts | 16 ---------- dashboard/server/services/AppsumoService.ts | 2 +- 6 files changed, 1 insertion(+), 110 deletions(-) delete mode 100644 dashboard/server/api/integrations/credentials/get.ts delete mode 100644 dashboard/server/api/integrations/credentials/update.post.ts delete mode 100644 dashboard/server/api/integrations/supabase/add.post.ts delete mode 100644 dashboard/server/api/integrations/supabase/get.ts delete mode 100644 dashboard/server/api/integrations/supabase/list.ts diff --git a/dashboard/server/api/integrations/credentials/get.ts b/dashboard/server/api/integrations/credentials/get.ts deleted file mode 100644 index 901be50..0000000 --- a/dashboard/server/api/integrations/credentials/get.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { getUserProjectFromId } from "~/server/LIVE_DEMO_DATA"; -import { IntegrationsCredentialsModel } from '@schema/integrations/IntegrationsCredentialsSchema'; - -export default defineEventHandler(async event => { - - const project_id = getHeader(event, 'x-pid'); - if (!project_id) return; - - const user = getRequestUser(event); - const project = await getUserProjectFromId(project_id, user); - if (!project) return; - - const credentials = await IntegrationsCredentialsModel.findOne({ project_id }); - - return { - supabase: { - anon_key: credentials?.supabase_anon_key || '', - service_role_key: credentials?.supabase_service_role_key || '', - url: credentials?.supabase_url || '' - } - } - -}); \ No newline at end of file diff --git a/dashboard/server/api/integrations/credentials/update.post.ts b/dashboard/server/api/integrations/credentials/update.post.ts deleted file mode 100644 index c3e5388..0000000 --- a/dashboard/server/api/integrations/credentials/update.post.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { IntegrationsCredentialsModel } from "@schema/integrations/IntegrationsCredentialsSchema"; -import { getUserProjectFromId } from "~/server/LIVE_DEMO_DATA"; - -export default defineEventHandler(async event => { - - const project_id = getHeader(event, 'x-pid'); - if (!project_id) return; - - const user = getRequestUser(event); - const project = await getUserProjectFromId(project_id, user); - if (!project) return; - - const body = await readBody(event); - - const res = await IntegrationsCredentialsModel.updateOne({ project_id }, { - supabase_anon_key: body.supabase_anon_key || '', - supabase_service_role_key: body.supabase_service_role_key || '', - supabase_url: body.supabase_url || '', - }, { upsert: true }); - - return { ok: res.acknowledged }; - -}); \ No newline at end of file diff --git a/dashboard/server/api/integrations/supabase/add.post.ts b/dashboard/server/api/integrations/supabase/add.post.ts deleted file mode 100644 index 57ed845..0000000 --- a/dashboard/server/api/integrations/supabase/add.post.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { getUserProjectFromId } from "~/server/LIVE_DEMO_DATA"; -import { SupabaseIntegrationModel } from "@schema/integrations/SupabaseIntegrationSchema"; - -export default defineEventHandler(async event => { - - const project_id = getHeader(event, 'x-pid'); - if (!project_id) return; - - const user = getRequestUser(event); - const project = await getUserProjectFromId(project_id, user); - if (!project) return; - - const { chart_type, table_name, xField, yMode, from, to, slice, name } = await readBody(event); - - if (!project.premium) { - const supabaseIntegrationsCount = await SupabaseIntegrationModel.countDocuments({ project_id }); - if (supabaseIntegrationsCount > 0) return setResponseStatus(event, 400, 'LIMIT_REACHED'); - } - - await SupabaseIntegrationModel.create({ - name, - project_id, chart_type, - table_name, xField, yMode, - from, to, slice, - }); - - return { ok: true }; - -}); \ No newline at end of file diff --git a/dashboard/server/api/integrations/supabase/get.ts b/dashboard/server/api/integrations/supabase/get.ts deleted file mode 100644 index 72632ba..0000000 --- a/dashboard/server/api/integrations/supabase/get.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { getUserProjectFromId } from "~/server/LIVE_DEMO_DATA"; -import { SupabaseIntegrationModel } from '@schema/integrations/SupabaseIntegrationSchema'; - -export default defineEventHandler(async event => { - - const project_id = getHeader(event, 'x-pid'); - if (!project_id) return; - - const user = getRequestUser(event); - const project = await getUserProjectFromId(project_id, user); - if (!project) return; - - const integration_id = getHeader(event, 'x-integration'); - - const integration = await SupabaseIntegrationModel.findOne({ _id: integration_id }); - return integration; - -}); \ No newline at end of file diff --git a/dashboard/server/api/integrations/supabase/list.ts b/dashboard/server/api/integrations/supabase/list.ts deleted file mode 100644 index c5ca619..0000000 --- a/dashboard/server/api/integrations/supabase/list.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { getUserProjectFromId } from "~/server/LIVE_DEMO_DATA"; -import { SupabaseIntegrationModel } from '@schema/integrations/SupabaseIntegrationSchema'; - -export default defineEventHandler(async event => { - - const project_id = getHeader(event, 'x-pid'); - if (!project_id) return; - - const user = getRequestUser(event); - const project = await getUserProjectFromId(project_id, user); - if (!project) return; - - const integrations = await SupabaseIntegrationModel.find({ project_id }); - return integrations; - -}); \ No newline at end of file diff --git a/dashboard/server/services/AppsumoService.ts b/dashboard/server/services/AppsumoService.ts index 9b3540c..b5e0856 100644 --- a/dashboard/server/services/AppsumoService.ts +++ b/dashboard/server/services/AppsumoService.ts @@ -1,6 +1,6 @@ -import { AppsumoCodeModel } from '@schema/AppsumoCodeSchema'; +import { AppsumoCodeModel } from '@schema/appsumo/AppsumoCodeSchema'; import { AppsumoCodeTryModel } from '@schema/appsumo/AppsumoCodeTrySchema';