This commit is contained in:
Emily
2024-09-27 20:33:49 +02:00
parent 8e3ad2920f
commit 3c77a727cd
37 changed files with 815 additions and 491752 deletions

View File

@@ -0,0 +1,23 @@
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 || ''
}
}
});

View File

@@ -0,0 +1,23 @@
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 };
});