PlacePlace
@raymondcamden
code:
data:privatelast updated:17 days 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
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
getargs
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
8
9
10
11
12
13
14
15
16
}
17

/*
do a quick abort for favicon
*/
if(steps.trigger.event.url.indexOf('favicon') >= 0) $end();

/*
I look for height and width (or h and w) in the URL parameters and copy them out for easier access
*/
if(steps.trigger.event.query.w) this.width = parseInt(steps.trigger.event.query.w,10);
if(steps.trigger.event.query.width) this.width = parseInt(steps.trigger.event.query.width,10);
if(steps.trigger.event.query.h) this.height = parseInt(steps.trigger.event.query.h,10);
if(steps.trigger.event.query.height) this.height = parseInt(steps.trigger.event.query.height,10);
if(!this.width) this.width = 350;
if(!this.height) this.height = 350;
steps.
defineservices
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
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
/*
I define my placeholder services
*/

this.services = [
  {
    name: 'placekitten',
    map: 'https://placekitten.com/${w}/${h}'
  },
  {
    name: 'placecage',
    map: 'https://www.placecage.com/${w}/${h}'
  },
  {
    name:'fillmurry',
    map: 'https://www.fillmurray.com/${w}/${h}'
  },
  {
    name:'placeholder',
    map: 'https://via.placeholder.com/${w}x${h}'
  },
  {
    name:'placedog',
    map: 'https://placedog.net/${w}/${h}'
  },
  {
    name:'placebear',
    map: 'https://placebear.com/${w}/${h}'
  },
  {
    name:'placebeard',
    map: 'https://placebeard.it/${w}x${h}'
  },
  {
    name: 'baconmockup',
    map: 'https://baconmockup.com/${w}/${h}'
  }
];
steps.
selectandgo
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
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
}
25

getRandomInt = function(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
}

makeTS = function(s) {
  return new Function("w","h","return `"+s+"`");

}

let service = steps.defineservices.services[getRandomInt(0, steps.defineservices.services.length)];
console.log(service);
let url = makeTS(service.map)(steps.getargs.width, steps.getargs.height);
console.log(service.name, url);

await $respond({
  status:302, 
  headers: {
    Location:url
  }
})