Skip to content

Commit

Permalink
Merge pull request #38 from buildable/development
Browse files Browse the repository at this point in the history
Development -> Main
  • Loading branch information
moekatib authored May 26, 2022
2 parents 72587db + 8cac70a commit 4c082ae
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Update the sample `CHANGELOG.md` file to reflect the appropriate information abo

### 8. Create a pull request ✅

Once you've tested and finished your template, create a pull request on this repository. Once approved, your template will be live on Buildable, for the entire community!
Once you've tested and finished your template, create a pull request on the `development` branch of this repository. Once approved and merged to main, your template will be live on Buildable, for the entire community!

---

Expand Down
12 changes: 12 additions & 0 deletions templates/utilities/encode-base64/CHANGELOG.md
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!

---
17 changes: 17 additions & 0 deletions templates/utilities/encode-base64/config.json
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"
}
27 changes: 27 additions & 0 deletions templates/utilities/encode-base64/input.js
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
};
};
36 changes: 36 additions & 0 deletions templates/utilities/encode-base64/run.js
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,
}
}
};

0 comments on commit 4c082ae

Please sign in to comment.