- Reorganize into apps/, packages/, docs/, e2e/, pocketbase/ directories - Add Dockerfiles for web, worker, and PocketBase services - Add docker-compose.yml for local orchestration - Add turbo.json for monorepo task management - Add Playwright e2e test infrastructure - Add PocketBase backend with migrations - Remove Vite/Next.js/ESLint/PostCSS config files - Update package.json with workspace dependencies - Add .env.example and .dockerignore
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { withAuth } from '@/lib/auth';
|
|
import { createPocketBaseClient } from '@/lib/pocketbase';
|
|
|
|
// GET /api/webhook-deliveries — List webhook deliveries with filtering
|
|
export const GET = withAuth(async (request: NextRequest, _user) => {
|
|
const { searchParams } = new URL(request.url);
|
|
const page = parseInt(searchParams.get('page') || '1');
|
|
const perPage = parseInt(searchParams.get('perPage') || '50');
|
|
const filter = searchParams.get('filter') || '';
|
|
const sort = searchParams.get('sort') || '-created';
|
|
const webhookId = searchParams.get('webhook_id') || '';
|
|
|
|
const pb = createPocketBaseClient();
|
|
|
|
let combinedFilter = filter;
|
|
if (webhookId) {
|
|
combinedFilter = combinedFilter
|
|
? `${combinedFilter} && webhook_id = "${webhookId}"`
|
|
: `webhook_id = "${webhookId}"`;
|
|
}
|
|
|
|
const result = await pb.collection('webhook_deliveries').getList(page, perPage, {
|
|
filter: combinedFilter,
|
|
sort,
|
|
});
|
|
|
|
return NextResponse.json({
|
|
items: result.items,
|
|
totalItems: result.totalItems,
|
|
totalPages: result.totalPages,
|
|
page: result.page,
|
|
perPage: result.perPage,
|
|
});
|
|
});
|