Étape 3: La demande de Node.js (config.js)
Tout d’abord, j’ai créé un fichier de config (config.js) avec le contenu suivant :
module.exports = { // number of minutes between calls to get the public IP getServerInterval: function(){ return 180; }, // SMTP server options getServerOptions: function(){ return { host : 'smtp.your_isp.com', port : 465, secure : true, ignoreTLS : true, debug : true, auth: { user : 'youra_account pass : 'your_password' } } }, getMailOptions: function(){ return { from: '???? to: '???? // the email address where you want to receive the notification // the next parameters can be specified later subject: 'IP has changed', text: 'Hello world', html: '<strong>Hello world</strong>' // html body } } }
L’application principale va importer ce fichier de config dans les lignes suivantes :
var intervalMinutes = require('./config.js').getServerInterval();var serverOptions = require('./config.js').getServerOptions();var mailOptions = require('./config.js').getMailOptions();