11 lines
519 B
TypeScript
11 lines
519 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { getSessionBoundaries } from '@/lib/sessions';
|
|
import { withAuth } from '@/lib/apiHelpers';
|
|
|
|
export const GET = withAuth(async (req: NextRequest) => {
|
|
const p = req.nextUrl.searchParams;
|
|
const from = p.get('from') ? new Date(p.get('from')!) : new Date(Date.now() - 86_400_000);
|
|
const to = p.get('to') ? new Date(p.get('to')!) : new Date();
|
|
const boundaries = await getSessionBoundaries(from, to);
|
|
return NextResponse.json(boundaries);
|
|
}); |