-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.js
More file actions
76 lines (56 loc) · 1.4 KB
/
task.js
File metadata and controls
76 lines (56 loc) · 1.4 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const axios = require("axios");
// const express = require ('express');
// const app = express();
var nodemailer = require('nodemailer');
async function getUrl(){
try {
let config = {
method: "get",
url: `https://blocksscan.io`,
};
let data = await axios(config);
console.log(data.status)
// res.send(data);
//NodeMailer to send mail alert
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'kulkarnijay722@gmail.com',
pass: 'lrpyjhjdrxbhvpfp'
}
});
// var textBody = {
// text: "Testing Nodemailer",
// stat: `${data.statusText}`
// }
var mailOptions = {
from:'kulkarnijay722@gmail.com',
to:'kulkarnijay76@gmail.com',
subject: 'RPC Network Alert',
text: `Testing Nodemailer \n Status: ${data.status} \n StatusText: ${data.statusText}`
};
setInterval(function ()
{
transporter.sendMail(mailOptions, function(error , info){
// console.log(info)
// if else condition for status
if (data.status === 200) {
console.log('Email sent: ' + info.response);
} else {
console.log(error);
}
});
},
60000); //30 seconds
}
catch(error){
console.log(error)
}
}
getUrl()
// app.get("/",function(req,res){
// res.send(data)
// getUrl()
// })
// const port = process.env.PORT || 3000;
// app.listen(port, () => console.log(`listening on port ${port}...`));