1.0.16 • Published 11 years ago

Percolator v1.0.16

Weekly downloads
294
License
-
Repository
github
Last release
11 years ago

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

1.0.16

11 years ago

1.0.14

11 years ago

1.0.13

11 years ago

1.0.11

11 years ago

1.0.10

11 years ago

1.0.9

11 years ago

1.0.8

11 years ago

1.0.7

11 years ago

1.0.6

11 years ago

1.0.5

11 years ago

1.0.4

11 years ago

1.0.3

11 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago

0.11.7

11 years ago

0.11.6

11 years ago

0.11.5

11 years ago

0.11.4

11 years ago

0.11.3

11 years ago

0.11.2

11 years ago

0.11.1

11 years ago

0.11.0

11 years ago

0.10.9

11 years ago

0.10.8

11 years ago

0.10.7

11 years ago

0.10.6

11 years ago

0.10.5

11 years ago

0.10.4

11 years ago

0.10.3

11 years ago

0.10.2

11 years ago

0.10.1

11 years ago

0.10.0

11 years ago

0.9.1

11 years ago

0.9.0

12 years ago

0.8.2

12 years ago

0.8.1

12 years ago

0.8.0

12 years ago

0.7.2

12 years ago

0.7.1

12 years ago

0.7.0

12 years ago

0.6.0

12 years ago

0.5.4

12 years ago

0.5.3

12 years ago

0.5.2

12 years ago

0.5.1

12 years ago

0.5.0

12 years ago

0.4.1

12 years ago

0.4.0

12 years ago

0.3.7

12 years ago

0.3.6

12 years ago

0.3.5

12 years ago

0.3.4

12 years ago

0.3.3

12 years ago

0.3.2

12 years ago

0.3.1

12 years ago

0.3.0

12 years ago

0.2.7

12 years ago

0.2.6

12 years ago

0.2.5

12 years ago

0.2.4

12 years ago

0.2.3

12 years ago

0.2.2

12 years ago

0.2.1

12 years ago

0.1.10

12 years ago

0.1.9

12 years ago

0.1.8

12 years ago

0.1.7

12 years ago

0.1.6

12 years ago

0.1.5

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago

0.0.1

12 years ago