24 lines
748 B
TypeScript
24 lines
748 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { doMySQL } from '@/lib/mysqlinterface';
|
|
|
|
export async function GET(request: NextRequest) {
|
|
const searchParams = request.nextUrl.searchParams;
|
|
const options = {
|
|
curdate: searchParams.get('curdate') ?? undefined,
|
|
testing: searchParams.get('test') ?? undefined,
|
|
};
|
|
const erg = await doMySQL('getlastdata', options);
|
|
return NextResponse.json(erg);
|
|
}
|
|
|
|
export async function POST(request: NextRequest) {
|
|
const searchParams = request.nextUrl.searchParams;
|
|
const body = await request.json();
|
|
const options = {
|
|
data: body,
|
|
testing: searchParams.get('test') ?? undefined,
|
|
};
|
|
const erg = await doMySQL('putdata', options);
|
|
return NextResponse.json(erg);
|
|
}
|