added API routers for locations
This commit is contained in:
14
app/api/all-locations/route.ts
Normal file
14
app/api/all-locations/route.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { fetchAllLocations } from '@/app/lib/actions/locationActions';
|
||||||
|
import type { NextApiRequest } from 'next'
|
||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
export const GET = async (
|
||||||
|
req: NextApiRequest,
|
||||||
|
) => {
|
||||||
|
// get year from query params
|
||||||
|
const url = new URL(req.url as string);
|
||||||
|
const year = parseInt(url.searchParams.get('year') as string, 10);
|
||||||
|
const locations = await fetchAllLocations(year);
|
||||||
|
|
||||||
|
return NextResponse.json({ locations });
|
||||||
|
}
|
||||||
9
app/api/available-years/route.ts
Normal file
9
app/api/available-years/route.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { fetchAvailableYears } from '@/app/lib/actions/monthActions';
|
||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
export async function GET(request: Request) {
|
||||||
|
|
||||||
|
const availableYears = await fetchAvailableYears();
|
||||||
|
|
||||||
|
return NextResponse.json({ availableYears });
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user