import { NextApiRequest , NextApiResponse } from 'next' ; import { PasteType } from 'types' ; import supabaseClient from 'utils/supabase' ; const handler = async ( req , res ) => { if ( req . method !== 'POST' ) { res . status ( 400 ) . json ( { message : 'Only POST requests allowed.' } ) ; return ; } const { pasteId , userId } = req . body ; if ( ! userId ) { return res . status ( 400 ) . json ( { message : 'Cannot delete anyonymous paste' } ) ; } const { data , error } = await supabaseClient . from < PasteType > ( 'Pastes' ) . delete ( ) . eq ( 'pasteId' , pasteId ) ; console . log ( data ) ; console . log ( error ) ; res . json ( { data , error } ) ; } ; export default handler ;