sparkline-test
@shaiss
code:
data:privatelast updated:3 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 1,000,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.
nodejs
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 executions with$checkpoint.
async (event, steps) => {
1
2
3
4
}
5
const fs = require("fs");

fs.writeFileSync(`/tmp/myfile`, Buffer.from("hello, world"));
steps.
generate_sparkline
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 executions 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
}
209
const sparkline = require('node-sparkline');
const fs = require('fs');
const path = require('path');
//const { promisify } = require('util');
//const writeFile = promisify(fs.writeFile);
const values = [
  7.45162149487362,
  7.465136012334006,
  7.461519350494333,
  7.465413133687816,
  7.511812989297731,
  7.8776700262848705,
  8.032346630203442,
  8.16774825735731,
  8.229668975583916,
  8.238856463169155,
  8.257030953739477,
  8.236774822602545,
  8.190300721027079,
  8.13603900682545,
  7.93046805606676,
  7.873374158326343,
  7.744961642971777,
  7.81594453373647,
  7.8637008039663385,
  7.8509859843825485,
  7.774829877417928,
  7.7928900555733325,
  7.802988598458197,
  7.811829326761041,
  7.809513333293174,
  7.755694552580595,
  7.740737298560772,
  7.74028834115583,
  7.736695879281692,
  7.8722879337259215,
  7.983071455545634,
  8.058338236458502,
  8.083090572680065,
  8.245677151169778,
  8.422209847286164,
  8.360618922692863,
  8.377466223406124,
  8.410567947020702,
  8.203756986058428,
  8.138869751165217,
  8.150320536729287,
  8.255427190765817,
  8.234015221444672,
  8.32323859535365,
  8.399964490840985,
  8.369376812486951,
  8.396646528694426,
  8.476018970266116,
  8.601040094779913,
  8.653684187748134,
  8.669531929002035,
  8.75787394946614,
  8.610224379717435,
  8.826478684824501,
  9.254604630288334,
  9.4425084451639,
  9.655424003726568,
  9.514980168649606,
  9.50452321495158,
  9.34102252811664,
  9.504210992279024,
  9.584058247196362,
  9.62409466404434,
  9.58620251496069,
  9.556253532418923,
  9.551316876883936,
  9.629350226102432,
  9.630441160758757,
  9.423599458967375,
  9.631422356177499,
  9.564332486800726,
  9.692641605412843,
  9.620514058161152,
  9.711097505491407,
  9.790968990509276,
  9.795394005541661,
  9.805505507268508,
  9.755163114125788,
  9.786393756280214,
  9.65383194888734,
  9.371223163817163,
  9.333064636470029,
  9.392793265218367,
  9.42918366346151,
  9.378188776334413,
  9.161911971095552,
  8.908976735168041,
  8.998591205295943,
  8.86119804919629,
  8.705310429352274,
  8.672491467964697,
  8.66018442224833,
  8.697003863890908,
  8.658116987717094,
  8.81197229728009,
  9.080238887017112,
  8.996947622581692,
  8.828905538101615,
  8.854916765407182,
  8.617945648751684,
  8.63866319409813,
  8.643344601216542,
  8.521692192951871,
  8.539957442721386,
  8.515027737186955,
  8.587694622710071,
  8.65752808321314,
  8.609443552098547,
  8.57258413338731,
  8.5544728042285,
  8.590224962764903,
  8.614407107056692,
  8.593195877435297,
  8.525904837005037,
  8.43499770655282,
  8.484828598550685,
  8.657854167302537,
  8.764298684103162,
  9.257060172600116,
  9.23601646121829,
  9.344144079057996,
  9.164669885696714,
  9.10033926934154,
  9.110017066872873,
  9.070139694356872,
  9.156952150982484,
  9.984874475898685,
  9.570086144819529,
  9.693334058951839,
  9.38151954184341,
  9.514025707420691,
  9.507324295116355,
  9.608760727642208,
  9.517461749024964,
  9.514193077146198,
  9.863268401452943,
  9.912986379354715,
  9.998331791015696,
  10.094629517602177,
  10.245244210395791,
  10.240302967862881,
  10.223367528548648,
  10.261645687066025,
  11.800825676399295,
  12.052693548659365,
  11.904241306948931,
  11.822314657602474,
  12.230277585232571,
  13.512054848486294,
  12.675104774147874,
  12.705815289569507,
  12.564530849193703,
  12.61735682536595,
  12.518586670949885,
  12.689352790506367,
  13.11039983067567,
  13.407938392152904,
  13.949617785120928,
  13.467738708696,
  13.899645824427985,
  15.637331996606186,
  15.337937695286223,
  14.816581598662703,
  14.48289778320874,
  14.5241804340251,
  13.97155114023251,
  13.671995384944877,
  13.82464643312032,
];

 
try {
  const svg = sparkline({
    values,
    width: 250,
    height: 150,
    stroke: '#57bd0f',
    strokeWidth: 2,
    strokeOpacity: 1,
  });
    
  fs.writeFileSync(`/tmp/line.svg`, (svg));
  //fs.writeFile('/tmp/sparkline.svg', svg);
  // svg is a string with SVG + polyline tags
  // ...
/*
  'use strict';

  let data = svg;
  let buff = new Buffer.from(data);
  let base64data = buff.toString('base64');

  return base64data
console.log('"' + data + '" converted to Base64 is "' + base64data + '"');
*/

} catch (e) {
  console.error(e.toString());
}

steps.
nodejs_4
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 executions 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
var axios = require('axios');
var FormData = require('form-data');
var fs = require('fs');
var data = new FormData();
data.append('File', fs.createReadStream('/tmp/line.svg'));

var config = {
  method: 'post',
  url: 'https://v2.convertapi.com/convert/svg/to/png?Secret=UvuFEy9Yj4MRKRza&StoreFile=true',
  headers: { 
    ...data.getHeaders()
  },
  data : data
};

await axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
steps.
send_http_request_1
Make an HTTP or webhook request and return the response as a step export.
auth
(auths.http)
params
URL
 
string ·params.url
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
}
12
const config = {
  method: params.method,
  url: params.url,
  params: params.query,
  headers: params.headers,
  responseType: params.responseType,
  data: params.data,
}
if (params.auth) config.auth = params.auth
return await require("@pipedreamhq/platform").axios(this, config)
steps.
convertio
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 executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
}
8
const convertapi = await require('convertapi')('UvuFEy9Yj4MRKRza');
convertapi.convert('png', {
    File: '/tmp/line.svg'
}, 'svg').then(function(result) {
    result.saveFiles('/tmp/');
});
steps.
svg2png
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 executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
}
16
const sharp = require("sharp")
 
sharp("/tmp/line.svg")
  .jpeg({
    quality: 100,
    chromaSubsampling: '4:4:4'
  })
  .toFile("/tmp/line.jpeg")
  .then(function(info) {
    console.log(info)
  })
  .catch(function(err) {
    console.log(err)
  })
steps.
nodejs_3
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 executions 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
const imgbbUploader = require("imgbb-uploader");

// Some promise of base64 data
const base64str = () =>
  new Promise((resolve) => {
    return setTimeout(() => {
      resolve(
        "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAEklEQVR42mNcLVNbzwAEjDAGACcSA4kB6ARiAAAAAElFTkSuQmCC",
      );
    }, 1000);
  });

// Your barebone async function
const myUrl = async (name) => {
  return await imgbbUploader({
    apiKey: "feab72e4191fe07369393c701af07f7e",
    base64string: await base64str(),
    name: name,
  })
    .then((res) => {
      console.log(`Handle success: ${res.url}`);
      return res.url;
    })
    .catch((e) => {
      console.error(`Handle error: ${e}`);
      return "http://placekitten.com/300/300";
    });
};

myUrl("Dolunay_Obruk-Sama_<3");
console.log(myUrl)
steps.
uploadfile
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 executions 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
var axios = require('axios');
var FormData = require('form-data');
var fs = require('fs');
var data = new FormData();
data.append('image', fs.createReadStream('/tmp/line.jpeg'));
data.append('expiration', '600');

var config = {
  method: 'post',
  url: 'https://api.imgbb.com/1/upload?key=feab72e4191fe07369393c701af07f7e',
  headers: { 
    ...data.getHeaders()
  },
  data : data
};

await axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
steps.
upload_picture
auth
(auths.imgbb)
params
Image

A binary file, base64 data, or a URL for an image. (up to 16MB)

 
R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
string ·params.image
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
}
15
const data = {
  image: params.image,
  name: params.name,
}
const config = {
  method: "post",
  url: `https://api.imgbb.com/1/upload?key=${auths.imgbb.api_key}`,
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
  },
  data: require("qs").stringify(data),
}
return await require("@pipedreamhq/platform").axios(this, config)
steps.
nodejs_2
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 executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
}
7
const imgbbUploader = require("imgbb-uploader");

await imgbbUploader("feab72e4191fe07369393c701af07f7e", "/tmp/line.svg")
  .then((response) => console.log(response))
  .catch((error) => console.error(error));
steps.
send_http_request
Make an HTTP or webhook request and return the response as a step export.
auth
(auths.http)
params
URL
 
string ·params.url
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
}
12
const config = {
  method: params.method,
  url: params.url,
  params: params.query,
  headers: params.headers,
  responseType: params.responseType,
  data: params.data,
}
if (params.auth) config.auth = params.auth
return await require("@pipedreamhq/platform").axios(this, config)
steps.
nodejs_1
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 executions with$checkpoint.
async (event, steps) => {
1
2
3
4
}
5
const fs = require("fs");

this.fileData = fs.readFileSync(`/tmp/line.svg`).toString();