feat: add trpc route to send emails

This commit is contained in:
Ephraim Atta-Duncan
2023-06-19 16:33:30 +00:00
parent aa740864b8
commit bc11abda08
11 changed files with 1095 additions and 4 deletions

View File

@ -0,0 +1,26 @@
import { TRPCError } from '@trpc/server';
import { sendMail } from '@documenso/lib/server-only/document/send-document';
import { authenticatedProcedure, router } from '../trpc';
import { ZSendMailMutationSchema } from './schema';
export const documentRouter = router({
sendEmail: authenticatedProcedure
.input(ZSendMailMutationSchema)
.mutation(async ({ input, ctx }) => {
try {
const { email } = input;
console.log('Send Mail Context', ctx);
return await sendMail({ email });
} catch (err) {
console.error(err);
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'We were unable to send an email.',
});
}
}),
});