Skip to content

Refactor: Simplified Action Template #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/get-reddit-posts/action-definition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// See README.MD for an in-depth explanation of each parameter.
module.exports = {
name: "get-top-reddit-posts",
function: require('./get-top-reddit-posts.js'),
documentationUri: "https://github.com/clay-run/action-template-nodejs/blob/master/README.md",
iconUri: "https://logo.clearbit.com/reddit.com?size=80",
displayName: "Get Top Reddit Posts",
description: "This action allows to get the top posts of a sub-reddit",
inputParameterSchema: [
{
name: "subredditName",
type: "text",
optional: false,
displayName: "SubReddit Name",
description: "The sub-reddit name to get posts from"
},
{
name: "numberOfPosts",
type: "number",
displayName: "# of posts",
description: "The number of posts to fetch"
}
],
outputParameterSchema: require('./output-schema.js'),
inputSample: require('./test-inputs').goodSample,
outputSample: require('./output-sample.js'),
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = [ // the action function must return an object with the following parameters
// These are used to help Clay's interface provide ways to extract data from the output of this action into the table

module.exports = [
{
name: "arrayOfPosts",
type: "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ module.exports = {
anotherSample: {
subredditName: "dogs"
}
}
}
64 changes: 0 additions & 64 deletions src/get_top_reddit_posts/definition.js

This file was deleted.

26 changes: 8 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
/*
*
* This is where you define your Action Package.
*
* An Action Package contains one or more Action Definitions.
*
* Be sure to add any actions you want included in your Action Package to the `actionDefinitions` array.
*
*/
This is an Action Package. It consists of one more Actions.
Add an Action by importing it's action-definition.js and adding it to the actionDefinitions array
*/

const getTopRedditPostsActionDefinition = require("./get_top_reddit_posts/definition.js")
const getTopRedditPosts = require("./get-reddit-posts/action-definition.js")

/*
* The Action Package definition
*/
const RedditActionPackage = {
name: "redditactionpackage", // a globally unique name to identify the package
description: "Actions to help search and read posts on Reddit", // a description of the package's purpose or content
actionDefinitions: [getTopRedditPostsActionDefinition], // the actions included in the action package
module.exports = {
name: "Reddit-Action-Package",
description: "Actions to search and get posts from Reddit",
actionDefinitions: [getTopRedditPosts],
}

module.exports = RedditActionPackage