<commit_before>import express from 'express';
import MailService from '@/services/MailService';
import Mail from '@/interfaces/Mail';
import logger from '@/helper/logger';

const router = express.Router();
const mailService = new MailService();


router.post('/', (req, res) => {
	const mail: Mail = {
		to: req.body.to,
		replyTo: req.body.replyTo,
		subject: req.body.subject,
		text: req.body.text,
		html: req.body.html,
		attachments: req.body.attachments,
	};

	if (req.body.from) {
		mail.from = req.body.from;
	}
	mailService.send(req.body.platformId, mail, req.body.to)
		.then((response: any) => {
			logger.info(response);
		})
		.catch((error: Error) => {
			logger.error({ error, platformId: req.body.platformId, mail, to: req.body.to });
		});

	res.send('Mail queued.');
});

export default router;<commit_msg>return error if mailservice fails (#135)<commit_after>import express from 'express';
import MailService from '@/services/MailService';
import Mail from '@/interfaces/Mail';
import logger from '@/helper/logger';

const router = express.Router();
const mailService = new MailService();


router.post('/', (req, res) => {
	const mail: Mail = {
		to: req.body.to,
		replyTo: req.body.replyTo,
		subject: req.body.subject,
		text: req.body.text,
		html: req.body.html,
		attachments: req.body.attachments,
	};

	if (req.body.from) {
		mail.from = req.body.from;
	}

	mailService.send(req.body.platformId, mail, req.body.to)
		.then((response: any) => {
			res.send('Mail queued.');
			logger.info(response);
		})
		.catch((error: Error) => {
			logger.error({ error, platformId: req.body.platformId, mail, to: req.body.to });
			res.status(500).send('Request failed.');
		});
});

export default router;
{'fraction_non_alphanumeric': 0.1758560650029019, 'fraction_numerical': 0.003482298316889147, 'mean_word_length': 4.04093567251462, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2180271', 'n_tokens_mistral': 635, 'n_tokens_neox': 590, 'n_words': 136}