mirror of
https://github.com/documenso/documenso.git
synced 2025-11-25 06:01:35 +10:00
feat: refactor og image generation (#639)
This commit is contained in:
23
apps/web/src/pages/api/share/index.ts
Normal file
23
apps/web/src/pages/api/share/index.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
import { getRecipientOrSenderByShareLinkSlug } from '@documenso/lib/server-only/share/get-recipient-or-sender-by-share-link-slug';
|
||||
|
||||
export type ShareHandlerAPIResponse =
|
||||
| Awaited<ReturnType<typeof getRecipientOrSenderByShareLinkSlug>>
|
||||
| { error: string };
|
||||
|
||||
export default async function shareHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
if (typeof req.query.slug !== 'string') {
|
||||
throw new Error('Invalid slug');
|
||||
}
|
||||
|
||||
const data = await getRecipientOrSenderByShareLinkSlug({
|
||||
slug: req.query.slug,
|
||||
});
|
||||
|
||||
return res.json(data);
|
||||
} catch (error) {
|
||||
return res.status(404).json({ error: 'Not found' });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user