npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

trello-helper

v3.0.7

Published

Simpler interface for setting and retrieving data using the Trello API

Downloads

84

Readme

Trello Helper - Simplifying the Trello API

This project is designed to make using the Trello API easier and it provides several dozen higher level functions to perform common tasks. Most of the functions take a single parameter with object property names that help describe the function. This means you can't get the parameters in the wrong order. If you don't need the options or body properties, you can leave the property off. Declaration files have been created so you should get full code assistance if your editor supports it and full type safety if you use it from TypeScript.

NPM version BuildStatus Maintainability Test Coverage Inline docs

Example call to get cards on list with and without option property specified

getCardsOnlist({ listId: "123", options: { limit: 10 } });
// or
getCardsOnList({ listId: "123" });

gif showing simple demo

Additionally, this package wraps the get, put, post, and delete commands to the Trello API to take card of the authorization elements. But, it also exposes many higher-level commands needed for working with boards, lists, cards, actions, and custom fields. The wrappers all use Promises (no callback syntax support), and the code uses async/await syntax.

Table of Contents


Installation

npm install trello-helper


Cheat Sheet

const { Trello } = require("trello-helper");
const trello = new Trello({ path: "/Users/ENV_VARS/trello.env.json" });
const demo = async () => {
  // get all the cards on the specified list
  const cardsOnList = await trello.getCardsOnList({
    listId: "5c9a9d8afcf46f3f1fdb6698"
  });
  // get all the actions on card 123 that are of type 'moveToBoard'
  const mtbActions = await trello.getActionsOnCard({
    cardId: "5c9a9d95f770d24919eb7edb",
    options: { filter: "moveToBoard" }
  });
  // get up to 1000 actions on a card
  const actions = await trello.getActionsOnCard({
    cardId: "5c9a9d95f770d24919eb7edb"
  });
  // get all the custom field data for a card
  const cf = await trello.getCustomFieldItemsOnCard({
    cardId: "5c9a9d95f770d24919eb7edb"
  });
  // set the value of a custom field
  await trello.setCustomFieldValueOnCard({
    cardFieldObj: {
      cardId: "5c9a9d95f770d24919eb7edb",
      fieldId: "5c9e45e513d1db64b50fdca2"
    },
    type: "text",
    value: "some data"
  });
};

If you pass an empty string to the Trello constructor, it will look for your credentials in the root folder of the project in a file named .env.json. If you don't want to store your credentials there, pass the path to where they are. The credentials JSON file needs to have the following form:

{
  "trelloHelper": {
    "appKey": "your app key",
    "token": "your token value"
  }
}

You can have other items in this file, but trelloHelper must be a top-level object in the file with the 'appKey' and 'token' property names. Of course, you must put in a valid app key and token strings for both properties.

If you want to create an environment variable with the proper string and don't want to use any file you can do that with two steps.

STEP 1: You need to create an environment variable named trelloHelper and then store a string in it that looks like this:
{"appKey":"your app key","token":"your token value"}
NOTE: Don't create a JSON object, you want a string. (The JSON.stringify() version of the JSON Object) The trello helper constructor will JSON.parse() the contents of that variable to create the needed JSON object.

STEP 2: Call the trello helper constructor and tell it the environment variable already exists

const trello = new Trello({ useExistingEnvVar: true });

Contributing

See the Contributing file.


Dependencies

winston logging tool
env-create reads a JSON file and turns top level elements into environment variables
moment flexible handling of JavaScript dates and times
request request-promise-native


Available Functions

See the GitHub documentation for the list of available functions and signatures.


back to top