feat(*): Enable filtering to either do a forms dex or a regular dex

This commit is contained in:
Josh Creek
2024-07-14 17:47:16 +01:00
parent 7467a4425f
commit 0edc7f0974
6 changed files with 5111 additions and 5086 deletions
+3 -2
View File
@@ -5,16 +5,17 @@ import CombinedDataRepository from '$lib/repositories/CombinedDataRepository';
export const GET = async ({ url }) => {
const page = parseInt(url.searchParams.get('page') || '1', 10);
const limit = parseInt(url.searchParams.get('limit') || '20', 10);
const enableForms = url.searchParams.get('enableForms') === 'true';
try {
await dbConnect();
const repo = new CombinedDataRepository();
const combinedData = await repo.findCombinedData(page, limit);
const combinedData = await repo.findCombinedData(page, limit, enableForms);
if (combinedData.length === 0) {
return json({ error: 'No combined data found' }, { status: 404 });
}
const totalCount = await repo.countCombinedData();
const totalCount = await repo.countCombinedData(enableForms);
const totalPages = Math.ceil(totalCount / limit);
return json({ combinedData, totalPages });