feat: Implement full type safety plan

This commit is contained in:
gpt-engineer-app[bot]
2025-10-20 00:40:47 +00:00
parent d9a912f443
commit db60759b9b
11 changed files with 271 additions and 23 deletions

View File

@@ -22,7 +22,13 @@ serve(async (req) => {
secretKey: novuApiKey
});
const { workflowId, subscriberId, topicKey, payload, overrides } = await req.json();
const { workflowId, subscriberId, topicKey, payload, overrides } = await req.json() as {
workflowId: string;
subscriberId?: string;
topicKey?: string;
payload: Record<string, unknown>;
overrides?: Record<string, unknown>;
};
// Support both individual subscribers and topics
if (!subscriberId && !topicKey) {
@@ -31,7 +37,7 @@ serve(async (req) => {
const recipient = subscriberId
? { subscriberId }
: { topicKey };
: { topicKey: topicKey! };
console.log('Triggering notification:', { workflowId, recipient });
@@ -54,13 +60,14 @@ serve(async (req) => {
status: 200,
}
);
} catch (error: any) {
console.error('Error triggering notification:', error);
} catch (error: unknown) {
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
console.error('Error triggering notification:', errorMessage);
return new Response(
JSON.stringify({
success: false,
error: error.message,
error: errorMessage,
}),
{
headers: { ...corsHeaders, 'Content-Type': 'application/json' },