Hello,
\n' + 'A new movie was just added to the library.
\n' + 'Go discover it now !
\n' + ' Discover new movie\n' + 'Happy exploring!
\n' + ''use strict'; const Joi = require('joi'); const Jwt = require('@hapi/jwt'); module.exports = [ { method: 'POST', path: '/movie', options: { auth: { scope : 'admin' }, tags: ['api'], validate: { payload: Joi.object({ title: Joi.string().required().min(3).example('The Matrix').description('Title of the movie'), description: Joi.string().required().min(3).example('A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers.').description('Description of the movie'), director: Joi.string().required().min(3).example('Lana Wachowski').description('Director of the movie'), releaseDate: Joi.date().required().example('1999-03-31').description('Release date of the movie'), }) } }, handler: async (request, h) => { const { User } = request.models(); const { movieService } = request.services(); const { title, description, director, releaseDate } = request.payload; //send email to all users const { emailService } = request.services(); const users = await User.query(); for (const user of users) { await emailService.sendEmail( user.email, user.firstName, user.lastName, 'New movie added', '\n' + '\n' + '\n' + '
\n' + ' \n' + ' \n' + 'Hello,
\n' + 'A new movie was just added to the library.
\n' + 'Go discover it now !
\n' + ' Discover new movie\n' + 'Happy exploring!
\n' + 'Hello,
\n' + 'The movie ' + request.payload.title + ' was just updated in the library.
\n' + 'Go check it out now !
\n' + ' Discover updated movie\n' + 'Happy exploring!
\n' + '