mirror of https://github.com/boxyhq/jackson.git
32 lines
887 B
TypeScript
32 lines
887 B
TypeScript
import jackson from '@lib/jackson';
|
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
|
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
try {
|
|
switch (req.method) {
|
|
case 'GET':
|
|
await handleGET(req, res);
|
|
break;
|
|
default:
|
|
res.setHeader('Allow', 'GET');
|
|
res.status(405).json({ error: { message: `Method ${req.method} Not Allowed` } });
|
|
}
|
|
} catch (error: any) {
|
|
const { message, statusCode = 500 } = error;
|
|
res.status(statusCode).json({ error: { message } });
|
|
}
|
|
}
|
|
|
|
// Get the sso traces filtered by the product
|
|
const handleGET = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
const { adminController } = await jackson();
|
|
|
|
const { product } = req.query as {
|
|
product: string;
|
|
};
|
|
|
|
const count = await adminController.countByProduct(product);
|
|
|
|
res.json({ count });
|
|
};
|