import { NextRequest, NextResponse } from "next/server";
import { Pool } from "pg"

const db = new Pool({
  connectionString: process.env.DB_STRING
})


export async function GET(req: NextRequest){
  try{

    const result = await db.query("SELECT * from products");
    return NextResponse.json(result.rows ?? []);
  } catch(error){

    return NextResponse.json({ message: "Serverside eception occurred" }, { status: 500 })
  }
}
