-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from buildable/development
Development -> Main
- Loading branch information
Showing
5 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 📣 Change Log | ||
All notable changes to the `encode-base64` template will be documented in this file. | ||
|
||
The format followed is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
--- | ||
|
||
## [1.0.0] - 2022-05-24 | ||
|
||
🚀 First template release! | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "encodeBase64", | ||
"title": "Encode in Base64", | ||
"description": "Encode plain text in Base64", | ||
"type": "js-function", | ||
"envVars": {}, | ||
"fee": 0, | ||
"image": "https://assets.buildable.dev/catalog/node-templates/utilities.svg", | ||
"category": "utilities", | ||
"accessType": "open", | ||
"language": "javascript", | ||
"price": "free", | ||
"platform": "", | ||
"tags": ["base64", "encode"], | ||
"stateType": "stateless", | ||
"__version": "1.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* ---------------------------------------------------------------------------------------------------- | ||
* EncodeBase64 [Input] | ||
* | ||
* @author Giosuè Sulipano | ||
* @access open | ||
* @license MIT | ||
* | ||
* ---------------------------------------------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* Lets you select the input for your Node's run function | ||
* | ||
* @param {Params} params | ||
* @param {Object} $trigger - This Flow's request object | ||
* @param {Object} $nodes - Data from above Nodes | ||
*/ | ||
const nodeInput = ({ $trigger, $nodes }) => { | ||
const { | ||
plainText = "Hello world!" | ||
} = $trigger.body; | ||
|
||
return { | ||
plainText | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* ---------------------------------------------------------------------------------------------------- | ||
* EncodeBase64 [Run] | ||
* | ||
* @description - Encode a given string into Base64 | ||
* | ||
* @author Giosuè Sulipano | ||
* @access open | ||
* @license MIT | ||
* | ||
* ---------------------------------------------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* The Node’s executable function | ||
* | ||
* @param {Run} input - Data passed to your Node from the input function | ||
*/ | ||
const run = (input) => { | ||
const { plainText } = input; | ||
|
||
try { | ||
if (typeof plainText !== "string") { | ||
throw new Error("The input provided is not a string"); | ||
} else if (plainText === "") { | ||
throw new Error("Plain text cannot be empty") | ||
} | ||
const encoded = Buffer.from(plainText).toString('base64'); | ||
return encoded; | ||
} catch (error) { | ||
return { | ||
failed: true, | ||
message: error.message, | ||
} | ||
} | ||
}; |