a tool for shared writing and social publishing
1import { NextRequest } from "next/server";
2import { drizzle } from "drizzle-orm/node-postgres";
3import { email_subscriptions_to_entity } from "drizzle/schema";
4import postgres from "postgres";
5import { eq } from "drizzle-orm";
6import { pool } from "supabase/pool";
7
8export async function POST(request: NextRequest) {
9 let sub_id = request.nextUrl.searchParams.get("sub_id");
10 if (!sub_id) return new Response(null, { status: 404 });
11 const client = await pool.connect();
12 const db = drizzle(client);
13
14 try {
15 await db
16 .delete(email_subscriptions_to_entity)
17 .where(eq(email_subscriptions_to_entity.id, sub_id));
18 } catch (error) {
19 console.log(error);
20 }
21 client.release();
22 return new Response(null, { status: 200 });
23}