Initial commit: Angular frontend and Expressjs backend
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import {NextFunction} from "express";
|
||||
|
||||
import {IWorkLenzRequest} from "../../interfaces/worklenz-request";
|
||||
import {IWorkLenzResponse} from "../../interfaces/worklenz-response";
|
||||
import {ServerResponse} from "../../models/server-response";
|
||||
import {isValidateEmail} from "../../shared/utils";
|
||||
|
||||
export default function (req: IWorkLenzRequest, res: IWorkLenzResponse, next: NextFunction): IWorkLenzResponse | void {
|
||||
const {emails} = req.body;
|
||||
|
||||
if (!Array.isArray(emails) || !emails.length)
|
||||
return res.status(200).send(new ServerResponse(false, null, "Email addresses cannot be empty"));
|
||||
|
||||
for (const email of emails) {
|
||||
if (!isValidateEmail(email))
|
||||
return res.status(200).send(new ServerResponse(false, null, "Invalid email address"));
|
||||
}
|
||||
|
||||
return next();
|
||||
}
|
||||
Reference in New Issue
Block a user