← back to StudentLoanTracker
src/app/api/calculators/route.ts
31 lines
import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
return NextResponse.json({
success: true,
message: 'Calculators API - returns available repayment plan calculators',
plans: ['SAVE', 'IBR', 'PAYE', 'ICR', 'Standard', 'Graduated', 'Extended'],
});
}
export async function POST(request: NextRequest) {
try {
const body = await request.json();
// TODO: Validate input (loan balance, interest rate, income, family size, plan type)
// TODO: Run calculation using pure functions from src/lib/calculators/
// TODO: Return monthly payment, total cost, forgiveness amount, timeline
return NextResponse.json({
success: true,
message: 'Calculator endpoint - POST with loan and income data to get repayment estimates',
receivedFields: Object.keys(body),
});
} catch {
return NextResponse.json(
{ success: false, error: 'Invalid request body' },
{ status: 400 }
);
}
}