From f07937557202734af704da45931983c2da9f5267 Mon Sep 17 00:00:00 2001 From: wanhose Date: Tue, 17 May 2022 16:44:43 +0200 Subject: [PATCH] feat(report-service): add html option to report endpoint --- packages/report-service/src/routes/v1/report.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/report-service/src/routes/v1/report.ts b/packages/report-service/src/routes/v1/report.ts index 456ba98..efae54a 100644 --- a/packages/report-service/src/routes/v1/report.ts +++ b/packages/report-service/src/routes/v1/report.ts @@ -2,8 +2,9 @@ import { FastifyInstance, RouteShorthandOptions } from 'fastify'; import { sendMail } from 'services/mailing'; type PostReportBody = { + html?: string; subject: string; - text: string; + text?: string; to: string; }; @@ -14,6 +15,9 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: ( schema: { body: { properties: { + html: { + type: 'string', + }, subject: { type: 'string', }, @@ -24,15 +28,15 @@ export default (server: FastifyInstance, options: RouteShorthandOptions, done: ( type: 'string', }, }, - required: ['subject', 'text', 'to'], + required: ['subject', 'to'], type: 'object', }, }, }, async (request, reply) => { - const { subject, text, to } = request.body; + const { html, subject, text, to } = request.body; - sendMail({ text, to, subject }); + sendMail({ html, text, to, subject }); reply.send({ success: true }); } );