mailer/src/controllers/MailController.ts

30 lines
860 B
TypeScript
Raw Normal View History

2021-03-01 16:44:24 +00:00
import { Authorized, JsonController, Post, QueryParam } from 'routing-controllers';
import { OpenAPI } from 'routing-controllers-openapi';
import { Mailer } from '../Mailer';
/**
* The mail controller handels all endpoints concerning Mail sending.
*/
@JsonController()
@Authorized()
@OpenAPI({ security: [{ "AuthToken": [] }] })
export class MailController {
private mailer: Mailer = new Mailer();
private initialized: boolean = false;
@Post('/reset')
@OpenAPI({ description: "Sends reset mails" })
async sendReset(@QueryParam("locale") locale: string) {
if (!this.initialized) {
await this.mailer.init();
this.initialized = true;
}
try {
this.mailer.sendResetMail("todo", "lelele", locale)
} catch (error) {
throw error;
}
return;
}
}