
import { NextRequest, NextResponse } from 'next/server';
import { RowDataPacket } from 'mysql2';
import pool from "../../../../../lib/db/db"

export async function POST(req: NextRequest) {
  try {
    
    const [rows] = await pool.query<RowDataPacket[]>(`SELECT c.id,c.slug, c.created_at, c.updated_at, ud.slug as university_slug 
      FROM courses c
      LEFT JOIN university_details ud ON c.university_id = ud.id
      LIMIT 80000 OFFSET 40000`)

    if(rows.length > 0)
    {
        return NextResponse.json(
            {
                success: true,
                data: rows
            },
            {
                status: 200
            }
        )
    }
    else{
        return NextResponse.json(
            {
                success: false,
                message: "No guide Found"
            },
            {
                status: 200
            }
        )
    }

  } catch (err: any) {
    return NextResponse.json(
      {
        success: false,
        message: err.message
      },
      {
        status: 500
      }
    )
  }
}