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

Percolator

v1.0.16

Published

Percolator is a framework for quickly and easily building quality HTTP APIs in Node.js

Downloads

6

Readme

Percolator

Build
Status

Percolator is a framework for quickly and easily building quality web APIs with node.js.

It is intended for developers who want to build great APIs, but don't want to have to write tedious boiler plate code over-and-over to achieve it.

It aims to be a great tool for building public-quality APIs, as well as being better suited for apps that perform all of their view logic on the client-side, like mobile apps and single-page apps.

Quick Examples:

Hello World

To create a simple read-only /helloworld resource that responds with "Hello World!", create a file in the root resources directory called "helloworld.js" and put this in it:

  exports.handler = {
    GET : function(req, res){
      res.send('Hello World!');
    }
  }

"req" and "res" are simply express's request and response objects.

Collections

To create a "/rockband" collection resource based on a "rockband" Mongo collection, create a file called "rockband.js" and put this in it:

  const MongoResource = require('../lib/resourceTypes/MongoResource').MongoResource;
  exports.handler = new MongoResource('rockbands', {
    'name' : { type: String, match: /[a-zA-z0-9\.]/, required : true },
    'created' : { type: Date, default: Date.now, required : true }
  })

You'll automatically get a "rockband" collection that you can GET and POST to (with validations), that stores in Mongo. Every rockband that you add via POST will be available at its own URL afterward, for GETting, updating via PUT and deleting via DELETE. Here's how a GET on /rockband looks when it has one rock band:

  {
    items: [
      {
        created: "2012-03-17T19:39:28.200Z",
        name: "The Clash",
        _id: "1234",
        links: {
          parent: {
            href: "/api/artist/"
          },
          self: {
            href: "/api/artist/1234"
          }
        }
      }
    ],
    links: {
      parent: {
        href: "/api"
      },
      self: {
        href: "/api/artist/"
      }
    }
  }

Here's how a GET on /rockband/1234 looks:

  {
      created: "2012-03-17T19:39:28.200Z",
      name: "The Clash",
      _id: "1234",
      links: {
        parent: {
          href: "/api/artist/"
        },
        self: {
          href: "/api/artist/1234"
        }
      }
    }

Here's how a GET on /rockband/4567 (which doesn't exist!) looks (with a 404 status):

  {
    error: {
      type: "RecordNotFoundError",
      message: "A record with the given id could not be found.",
      detail: "4567"
    }
  }

Values

Make the hard stuff simple

  • Get the HTTP/REST-Nerd stuff (serialization, authentication, hypermedia, status codes) right so that the developer doesn't have to. See http://wiki.basho.com/Webmachine-Diagram.html to see what a full featured server should be doing on each request.

Make the tedious stuff less tedious

  • Implicit / Automatic Routing. Each resource is in its own file (which is just a node.js module) and is routed automatically without you having to route explicitly.
  • Automatic resource linking where possible, if desired.
  • Make creating collections (especially based on databases) as easy as possible.

Keep the simple stuff simple

  • HTTP is simple. If you know HTTP, you know the names of the methods of a Percolator resource.
  • Can't do what you want within the framework? Percolator is built on express.js, so you can drop back to using that framework directly anytime you need to.
  • Continue to allow full control of request handling and response generation.
  • No magic, and no code generators.

Current State:

  • Percolator is in an experimental stage, but it's built on express.js, so you can always fall back to express if something doesn't work for you. I'd love to hear of other people using it and giving feedback/bug reports so I can iron out all the wrinkles.

Some glaring limitations being worked on:

  • Built-in (stateless) authentication methods so the user doesn't have to write her own.
  • Other data-store helpers than just mongo, so the user doesn't have to write her own.
  • Other representation formats than just "application/json", and a better factoring to allow custom media-types (per resource, even) if the user wishes.
  • better support for other cross-cutting "aspects" like logging and throttling

Automated Tests:

npm test