Website Monitor
@mjclemente
code:
data:privatelast updated:1 year ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 200,000+ developers using the Pipedream platform
steps.
trigger
Cron Scheduler
Deploy to configure a custom schedule
This workflow runs on Pipedream's servers and is triggered on a custom schedule.
steps.
GET_website
auth
to use OAuth tokens and API keys in code via theauths object
params
SiteUrl
string ·params.siteUrl
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across invocations with$checkpoint.
async (event, steps, params) => {
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
const axios = require('axios');
const url = require('url');
this.siteName = url.parse(params.siteUrl).hostname;
axios.interceptors.request.use((config) => {
  config.meta = config.meta || {}
  config.metadata = { startTime: new Date() }
  return config;
}, function (error) {
  return Promise.reject(error);
});

axios.interceptors.response.use((response) => {
  response.config.metadata.endTime = new Date()
  response.duration = response.config.metadata.endTime - response.config.metadata.startTime
  return response;
}, (error) => {
  error.config.metadata.endTime = new Date();
  error.duration = error.config.metadata.endTime - error.config.metadata.startTime;
  return Promise.reject(error);
});

// https://httpstat.us/400
// console.log(steps.query.$return_value.results);
let response = await axios.get(
  params.siteUrl)
  .then((result) => {
    const { status, statusText, duration } = result;
    return { status, statusText, duration };
  })
  .catch(function (error) {
    // console.log(error);
    if (error.response) {
      console.log(error.response);
      return error.response;
    } else {
      console.log('oops');
      // Something happened in setting up the request that triggered an Error
      console.log('Error', error.message);
    }
  });

// for( var row in steps.query.$return_value.results){
//   let [ name, url ] = steps.query.$return_value.results[row];

//   if( url && url.slice(0,5) == 'https' ){
//     // console.log(url);
    
//   }
  
// }
return response;
steps.
contains_error
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across invocations with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
}
7
if( steps.GET_website.$return_value.status === 200){
  return false;
} else {
  return true;
}
steps.
email_me
auth
to use OAuth tokens and API keys in code via theauths object
params
Subject
string ·params.subject
Text
string ·params.text
Html
string ·params.html
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across invocations with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
}
15
if( steps.contains_error.$return_value ){
  const options = {
    subject: params.subject,
    text: params.text,
  }
  if (params.html) {
    options.html = params.html
  }
  // if (params.include_collaborators) {
  //   options.include_collaborators = params.include_collaborators
  // }
  $send.email(options)
}
steps.
datawaves
auth
to use OAuth tokens and API keys in code via theauths object
(auths.datawaves)
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across invocations with$checkpoint.
async (event, steps, auths) => {
1
2
3
4
5
6
7
8
9
10
11
}
12
const data = steps.GET_website.$return_value;
const collection = steps.GET_website.siteName.replace(/\./g, "_");;
return await require("@pipedreamhq/platform").axios(this, {
  method: "post",
  url: `https://datawaves.io/api/v1.0/projects/${auths.datawaves.project_id}/events/${collection}`,
  headers: {
    "Authorization": `${auths.datawaves.secret_key}`,
  },
  data,
})