-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (23 loc) · 788 Bytes
/
Copy pathapp.js
File metadata and controls
27 lines (23 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
'use latest';
const contact = require('./lib/contact');
function task(context, callback) {
return contact.validateParams(context)
.then(() => {
return contact.validateForm(context);
})
.then(() => {
return contact.sendMail(contact.createMessage(context), context);
})
.then((info) => {
console.info('Message sent: ' + info.response);
return callback(null, {
message: 'We\'ve received your message and we\'ll contact you very soon!'
});
})
.catch((err) => {
console.error(err);
return callback('There was a problem sending your message. Please try again in a few minutes');
});
}
module.exports = task;