import { NextApiRequest , NextApiResponse } from 'next' ; import { PasteType } from 'types' ; import supabaseClient from 'utils/supabase' ; export default async function pasteId ( req , res ) { const { data : pastes , error } = await supabaseClient . from < PasteType > ( 'Pastes' ) . select ( '*' ) . eq ( 'public' , 'true' ) . order ( 'createdAt' , { ascending : false } ) . limit ( 8 ) ; if ( error || ! pastes ) { return res . status ( 400 ) . json ( { error } ) ; } res . json ( { pastes } ) ; }