mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
restructure
This commit is contained in:
@@ -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 || ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -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 };
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -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 };
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -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;
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -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;
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import { AppsumoCodeModel } from '@schema/AppsumoCodeSchema';
|
import { AppsumoCodeModel } from '@schema/appsumo/AppsumoCodeSchema';
|
||||||
import { AppsumoCodeTryModel } from '@schema/appsumo/AppsumoCodeTrySchema';
|
import { AppsumoCodeTryModel } from '@schema/appsumo/AppsumoCodeTrySchema';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user