36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { Response, Request } from "express";
|
|
import { Controller, Post } from "@ControllerPattern/index";
|
|
import ApiController from "@Common/system/controller-pattern/ApiController";
|
|
import { Service } from "typedi";
|
|
import authHandler from "@App/middlewares/AuthHandler";
|
|
import MailchimpService from "@Services/common/MailchimpService/MailchimpService";
|
|
|
|
|
|
@Controller()
|
|
@Service()
|
|
export default class MailchimpController extends ApiController {
|
|
constructor(private mailchimpService: MailchimpService) {
|
|
super();
|
|
}
|
|
|
|
/**
|
|
* @description Create a new customer
|
|
*/
|
|
@Post("/api/v1/notary/mailchimp", [authHandler])
|
|
protected async post(req: Request, response: Response) {
|
|
try {
|
|
//init IUser resource with request body values
|
|
const email = req.body.email;
|
|
|
|
//call service to get prisma entity
|
|
const responseCall = await this.mailchimpService.addToMailchimpList(email);
|
|
|
|
//success
|
|
this.httpCreated(response, responseCall);
|
|
} catch (error) {
|
|
this.httpInternalError(response, error);
|
|
return;
|
|
}
|
|
}
|
|
}
|