Fix Novu API import error

This commit is contained in:
gpt-engineer-app[bot]
2025-10-12 15:43:19 +00:00
parent 1333a5e8c8
commit f294020d0b
6 changed files with 21 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"; import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
import { Novu } from "npm:@novu/api@0.0.7"; import { Novu } from "npm:@novu/api@1.6.0";
// TODO: In production, restrict CORS to specific domains // TODO: In production, restrict CORS to specific domains
// For now, allowing all origins for development flexibility // For now, allowing all origins for development flexibility
@@ -21,9 +21,8 @@ serve(async (req) => {
throw new Error('NOVU_API_KEY is not configured'); throw new Error('NOVU_API_KEY is not configured');
} }
const novu = new Novu({ const novu = new Novu({
apiKey: novuApiKey, secretKey: novuApiKey
baseURL: Deno.env.get('VITE_NOVU_API_URL') || 'https://api.novu.co',
}); });
// Parse and validate request body // Parse and validate request body

View File

@@ -20,7 +20,7 @@ declare module 'https://esm.sh/@supabase/supabase-js@2.57.4' {
export * from '@supabase/supabase-js'; export * from '@supabase/supabase-js';
} }
declare module 'npm:@novu/api@0.0.7' { declare module 'npm:@novu/api@1.6.0' {
export * from '@novu/api'; export * from '@novu/api';
} }

View File

@@ -1,6 +1,6 @@
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"; import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4"; import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
import { Novu } from "npm:@novu/api@0.0.7"; import { Novu } from "npm:@novu/api@1.6.0";
const corsHeaders = { const corsHeaders = {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
@@ -24,9 +24,8 @@ serve(async (req) => {
// Create Supabase client with service role for admin access // Create Supabase client with service role for admin access
const supabase = createClient(supabaseUrl, supabaseServiceKey); const supabase = createClient(supabaseUrl, supabaseServiceKey);
const novu = new Novu({ const novu = new Novu({
apiKey: novuApiKey, secretKey: novuApiKey
baseURL: Deno.env.get('VITE_NOVU_API_URL') || 'https://api.novu.co',
}); });
// Fetch users who don't have Novu subscriber IDs // Fetch users who don't have Novu subscriber IDs

View File

@@ -1,5 +1,5 @@
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"; import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
import { Novu } from "npm:@novu/api@0.0.7"; import { Novu } from "npm:@novu/api@1.6.0";
const corsHeaders = { const corsHeaders = {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
@@ -18,17 +18,19 @@ serve(async (req) => {
throw new Error('NOVU_API_KEY is not configured'); throw new Error('NOVU_API_KEY is not configured');
} }
const novu = new Novu({ const novu = new Novu({
apiKey: novuApiKey, secretKey: novuApiKey
baseURL: Deno.env.get('VITE_NOVU_API_URL') || 'https://api.novu.co',
}); });
const { workflowId, subscriberId, payload, overrides } = await req.json(); const { workflowId, subscriberId, payload, overrides } = await req.json();
console.log('Triggering notification:', { workflowId, subscriberId }); console.log('Triggering notification:', { workflowId, subscriberId });
const result = await novu.events.trigger(workflowId, { const result = await novu.trigger({
to: subscriberId, to: {
subscriberId,
},
workflowId,
payload, payload,
overrides, overrides,
}); });

View File

@@ -1,5 +1,5 @@
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"; import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
import { Novu } from "npm:@novu/api@0.0.7"; import { Novu } from "npm:@novu/api@1.6.0";
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4"; import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
const corsHeaders = { const corsHeaders = {
@@ -21,9 +21,8 @@ serve(async (req) => {
throw new Error('NOVU_API_KEY is not configured'); throw new Error('NOVU_API_KEY is not configured');
} }
const novu = new Novu({ const novu = new Novu({
apiKey: novuApiKey, secretKey: novuApiKey
baseURL: Deno.env.get('VITE_NOVU_API_URL') || 'https://api.novu.co',
}); });
const supabase = createClient(supabaseUrl, supabaseServiceKey); const supabase = createClient(supabaseUrl, supabaseServiceKey);

View File

@@ -1,5 +1,5 @@
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"; import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
import { Novu } from "npm:@novu/api@0.0.7"; import { Novu } from "npm:@novu/api@1.6.0";
const corsHeaders = { const corsHeaders = {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
@@ -18,9 +18,8 @@ serve(async (req) => {
throw new Error('NOVU_API_KEY is not configured'); throw new Error('NOVU_API_KEY is not configured');
} }
const novu = new Novu({ const novu = new Novu({
apiKey: novuApiKey, secretKey: novuApiKey
baseURL: Deno.env.get('VITE_NOVU_API_URL') || 'https://api.novu.co',
}); });
const { subscriberId, email, firstName, lastName, phone, avatar, data } = await req.json(); const { subscriberId, email, firstName, lastName, phone, avatar, data } = await req.json();