Skip to content

Instantly share code, notes, and snippets.

@xtina-starr
Last active February 14, 2017 04:12
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xtina-starr/8ccc2825c5b279f5914a to your computer and use it in GitHub Desktop.
Save xtina-starr/8ccc2825c5b279f5914a to your computer and use it in GitHub Desktop.
Framework options for creating a REST API with node.

Frameworks

Framework options for creating a REST API with node:

  • Hapi
  • Restify
  • Connect
  • Loopback
  • Actionhero.js (?)

Things to consider when selecting a framework:

  • The Community: Who’s using it?
  • Is there adaquate documentation?
  • Customizable?
  • Is it easy to integrate and use? * setup, error handling, testing, available plugins
  • Licensing?
  • Bugs/Issues

Hapi

Hapi is a configuration-centric framework for building web applications and APIs which makes building a REST API easy. Hapi was created by WalmartLabs.

-Community - who's using Hapi?
Beats Music, PayPal, OpenTable, Mozilla, Walmart, Yahoo!, NPM, Hoodie, etc.

View a complete list here: http://hapijs.com/community

-Documentation - clear and thorough.
http://hapijs.com/api

Hapi even provides a self-guided workshops to teach you about Hapi https://github.com/spumko/makemehapi

-Overview - Hapi makes creating routes clear and simple. It appears to be pretty easy to get up in running with Hapi and comes with some nice out of the box features like configuration for validation, authentications, payload processing, and caching options. It also supports some neat plugins (good: process monitoring, joi: validator for JS objects, lout: API documentation generator, bass master: batch request plugin).

-Highlights:

  1. Hapi makes creating routes clear and simple.

  2. Nice out of the box features like configuration, authentication, payload processing, and caching options.

  3. It supports some neat plugins (good: process moonitoring, joi: validator for JS objects, lout: API documentation generator, bass master: batch request plugin).

  4. It has a strong community of users and is well maintained (by WalmartLabs)

Restify

A node framework that borrows heavily from Express, but specifically used for building REST web services/APIs.

-Community - not sure who's using it. It does seem to be pretty popular as there are a singificant amounts of downloads for this module on npmjs.com. This may be due to it's closeness and Express like characteristics.

-Documentation - the documentation looks decent and walks you through creating basic routes. http://mcavage.me/node-restify/

-Overview - Restify seems pretty basic and standard. There is a plugin available for restify that implements OAuth 2.
https://www.npmjs.org/package/restify-oauth2

-Tutorials
Tutorial from synthmedia

Tutorial from openshift

LoopBack

Backend framework that adopts the convention over configuration approach. Built on top of Express.

  • Creates models based on your schema if you have one and creates dynamic models if you don’t
  • Connects to backend data stores (MySQL), run ad-hoc queries

-Community: - not sure who's using it. A Google forum of people talking about what they are using loopback for:
https://groups.google.com/forum/#!topic/loopbackjs/UuwMhIYGDz8

-Documentation - Good doucmentation. step-by-step instructions.
http://docs.strongloop.com/display/LB/LoopBack+2.0

-Overview/Features:
http://loopback.io
Setting up is a bit of a process, but once up and running you immediately get to leverage the explorer interface to make calls and see what request and responses look like. While loopback does provide a lot of neat tools, it seems kind of heavy and requires strongloop in order to use it.

With loopback requiring strongloop and strongloop being installed globally, would configuration and deployment be painful?

The perks:

  • Built in generator (LoopBack Yeaoman generator) for creating models (done through the CLI)
  • Built in API Explorer - allows you to exercise all the generated API endpoints.
  • Comes with a driver to connect to the datastore
  • incorporate model relationships

It comes with a lot...too much?

creating a simple api: http://docs.strongloop.com/display/LB/Create+a+simple+API

Connect

Connect is an extensible HTTP server framework for node, providing high performance “plugins” known as middleware. Connect wraps the Server, ServerRequest, and ServerResponse object of node.js standard http module.

http://stephensugden.com/middleware_guide/
http://howtonode.org/connect-it

-Community: ?

-Documentation: Doesn't seem as clear and intuitive as other documentation.
https://github.com/senchalabs/connect

-Overview: - Connect is a middleware and doesn’t seem to have anything built-in to handle routes which would require more setup than other frameworks.

Tutorial from Tuts+

Actionhero

actionhero.js is a multi-transport API Server with integrated cluster capabilities and delayed tasks.

-Community: Who's using it?
TaskRabit, Delicious Hat, Madglory, Roam, Yvolver, Dopamine API, Bluesunrise

Actionhero is maintained by one person. Risky business. http://actionherojs.com/#community

-Documentation: - is a bit weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment