Files
documenso/packages/lib/server-only/public-api/test-credentials.ts
2025-02-13 14:10:38 +11:00

25 lines
607 B
TypeScript

import { validateApiToken } from '@documenso/lib/server-only/webhooks/zapier/validateApiToken';
export const testCredentialsHandler = async (req: Request) => {
try {
const authorization = req.headers.get('authorization');
if (!authorization) {
throw new Error('Missing authorization header');
}
const result = await validateApiToken({ authorization });
return Response.json({
name: result.team?.name ?? result.user.name,
});
} catch (err) {
return Response.json(
{
message: 'Internal Server Error',
},
{ status: 500 },
);
}
};