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

falcor-wordpress

v0.3.0

Published

A falcor server for consuming the wordpress API.

Downloads

4

Readme

Falcor Wordpress Router

npm version

This project provides a Falcor Router which acts as a middleman (in node.js) for consuming the Wordpress REST API. The goal is a more intelligible, data-centric API for the client with dramatically reduced client network requests.

Getting Started

Basic installation and usage

npm install falcor-wordpress --save

Use it within an express app:

... // basic express boilerplate, app = express();

var FalcorServer = require('falcor-express');
var wordpressRouter = require('falcor-wordpress');
var endpoint = 'http://demo.wp-api.org/wp-json/wp/v2';

app.use('/model.json', FalcorServer.dataSourceRoute(function (req, res) {
  // without authentication
  return wordpressRouter(endpoint);
}));

Included Demo

A demo running in express with a simple front-end is included.

# install library dependencies
npm install

# install demo dependencies and run
cd demo
npm install
npm start

# open your browser and visit http://localhost:9090

The demo page allows you to test live queries against the offical Wordpress Rest API demo site, including a number of examples to get you started. Watch the server console to see a list of REST endpoints that are being fetched on each flight.

Note: there are some differences betweeen the 1.0 and 2.0 branches of the WP API. This package targets 2.0, and uses a 2.0 endpoint for its demo.

Note 9-28-2015: the official Wordpress Rest API demo site has currently been taken offline; since its status is uncertain, the demo may require that you edit server.js to point to your own instance of a Wordpress site running the REST API version 2. I'll update with further instructions to that end if it becomes clear that their public demo is permanently offline.

Currently implemented top-level routes

Below are the top-level routes available, along with some example paths that might be requested (try these live on the included demo).

postsById

Basic example: postsById[171,131]["title","slug","link"]

{
   "postsById": {
      "131": {
         "title": "Ipsam mollitia eveniet hic",
         "slug": "ipsam-mollitia-eveniet-hic",
         "link": "http://demo.wp-api.org/2015/08/21/ipsam-mollitia-eveniet-hic/"
      },
      "171": {
         "title": "Sint aperiam autem molestiae debitis",
         "slug": "sint-aperiam-autem-molestiae-debitis",
         "link": "http://demo.wp-api.org/2015/08/12/sint-aperiam-autem-molestiae-debitis/"
      }
   }
}

Going deeper: postsById[131].terms.category[0].name

{
   "postsById": {
      "131": {
         "terms": {
            "category": {
               "0": {
                  "name": "Illum in fugit assumenda quo et reprehenderit maxime saepe"
               }
            }
         }
      }
   }
}

recentPosts

Basic example: recentPosts[0..2].title

{
   "recentPosts": {
      "0": {
         "title": "Repellat dolor architecto inventore"
      },
      "1": {
         "title": "Dolor adipisci soluta eum ipsam deserunt"
      },
      "2": {
         "title": "Ipsam mollitia eveniet hic"
      }
   }
}

Going deeper: recentPosts[5].terms.category[0].name

{
   "recentPosts": {
      "5": {
         "terms": {
            "category": {
               "0": {
                  "name": "In fugit quae libero a"
               }
            }
         }
      }
   }
}

postsByTerm[vocabulary][term-slug]

Example: postsByTerm.category.tool-kit[0..3]['title','id']

{
  "postsByTerm": {
    "category": {
       "tool-kit": {
          "0": {
             "title": "Writing Reports, Quick Guide",
             "id": 97
          },
          "1": {
             "title": "Analyzing Data, Quick Guide",
             "id": 95
          },
          "2": {
             "title": "Measuring Outcomes, Quick Guide",
             "id": 92
          },
          "3": {
             "title": "Creating Learning Outcomes, Quick Guide",
             "id": 90
          }
       }
    }
  }
}

termsById[vocabulary]

Categories example: termsById.category[4,70]['name','description']

{
   "termsById": {
      "category": {
         "4": {
            "name": "Ab iusto",
            "description": "Sunt distinctio asperiores dolores quae odit necessitatibus dolor dolore quo doloremque nam incidunt molestiae facilis quisquam voluptatem voluptas et voluptas sapiente laudantium fugiat"
         },
         "70": {
            "name": "Accusantium nulla omnis quos",
            "description": "Occaecati placeat et dolores tempore unde est laudantium ipsam tempora accusamus culpa sequi aut aut dolore minus pariatur fugit ut ipsa et distinctio minus amet ut id molestiae assumenda aliquam vel qui quibusdam"
         }
      }
   }
}

Tags example: termsById.tag[36]['slug','name']

{
   "termsById": {
      "tag": {
         "36": {
            "slug": "accusantium-dolore-porro-nihil-eveniet-dolores-impedit-quisquam",
            "name": "Accusantium dolore porro nihil eveniet dolores impedit quisquam"
         }
      }
   }
}

taxonomies

Metadata: taxonomies.category.meta['name','slug']

{
   "taxonomies": {
      "category": {
         "meta": {
            "name": "Categories",
            "slug": "category"
         }
      }
   }
}

Number of available terms: taxonomies.category.terms.length

{
   "taxonomies": {
      "category": {
         "terms": {
            "length": "52"
         }
      }
   }
}

Terms range: taxonomies.tag.terms[0..2]['name']

{
   "taxonomies": {
      "tag": {
         "terms": {
            "0": {
               "name": "Accusantium dolore porro nihil eveniet dolores impedit quisquam"
            },
            "1": {
               "name": "Ad et modi ipsam in iure"
            },
            "2": {
               "name": "Adipisci ut tempora quisquam"
            }
         }
      }
   }
}

Other routes

These are also available at root, though generally more useful where referenced elsewhere:

authorsById mediaById

Media linked as featured image: postsById[131].featured_image.media_details.sizes.thumbnail.file

{
   "postsById": {
      "131": {
         "featured_image": {
            "media_details": {
               "sizes": {
                  "thumbnail": {
                     "file": "fba2be87-deae-3077-96b4-d1754a1802ca-150x150.jpg"
                  }
               }
            }
         }
      }
   }
}

Author of a post: postsById[171].author.name

{
   "postsById": {
      "171": {
         "author": {
            "name": "Cassidy"
         }
      }
   }
}

Roadmap

  • [x] postsById
  • [x] recentPosts
  • [x] taxonomies (meta, terms list)
  • [x] termsById
  • [x] authorsById
  • [x] mediaById
  • [x] posts by term
  • [ ] more linked subqueries
  • [ ] additional listings by varied sorts