Skip to content

Commit

Permalink
refactor(api): streamline API routes and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
rifont committed Jun 30, 2024
1 parent e4273f7 commit 1edbede
Show file tree
Hide file tree
Showing 12 changed files with 4,736 additions and 4,296 deletions.
4 changes: 0 additions & 4 deletions app/api/echo/route.ts

This file was deleted.

10 changes: 3 additions & 7 deletions app/api/messages/route.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { SUBSCRIBER_ID } from '@/constants/subscriber';
import { Novu } from '@novu/node';

const novu = new Novu(process.env.NOVU_API_KEY as string);
import { aiDigest } from '@/lib/novu/workflows';

export async function POST(request: Request) {
const res = await request.json();

await novu.trigger('ai-digest', {
to: {
subscriberId: SUBSCRIBER_ID,
},
await aiDigest.trigger({
to: [SUBSCRIBER_ID],
payload: {
message: res.message,
digestDuration: res.digestDuration,
Expand Down
18 changes: 2 additions & 16 deletions app/api/notifications/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { notificationSchemaJson } from '@/lib/novu/workflows';
import { OpenAI } from 'openai';

const openai = new OpenAI({
Expand All @@ -22,22 +23,7 @@ export async function GET(request: Request) {
{
name: "create_sample_notification",
description: "A sample notification for a user.",
parameters: {
type: "object",
properties: {
message: {
type: "string",
description: "The message to be sent."
},
category: {
type: "string",
enum: ["Urgent", "Important", "Normal", "Low"],
description: "The priority of the message."
}
},
required: ["message", "category"],
additionalProperties: false,
}
parameters: notificationSchemaJson
}
],
});
Expand Down
4 changes: 4 additions & 0 deletions app/api/novu/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { serve } from "@novu/framework/next";
import { aiDigest } from "@/lib/novu/workflows";

export const { GET, POST, OPTIONS } = serve({ workflows: [aiDigest] });
155 changes: 0 additions & 155 deletions app/echo/client.ts

This file was deleted.

184 changes: 0 additions & 184 deletions app/echo/emails/vercel.tsx

This file was deleted.

Loading

0 comments on commit 1edbede

Please sign in to comment.