-2

I know there are alternatives such as restify but would like to stick with the more familiar express. Does anyone have examples (and or experience/tips to share) of successful implementations of a web api with Express 4.x, such that I could forgo having to go down an alternative route?

Nikos
  • 7,295
  • 7
  • 52
  • 88
  • 1
    its funny how the useful sorts of stuff (we really care what other professionals in industry are using) to everyday developers are shut down on SO these days. – Nikos May 08 '14 at 08:48

1 Answers1

2

restify uses very similar patterns to express for routing, etc., so if you plan on doing any fancy API stuff you might as well just npm install restify and use it in place of express. Here's a minimal example of a restify application from its homepage:

var restify = require('restify');

function respond(req, res, next) {
  res.send('hello ' + req.params.name);
  next();
}

var server = restify.createServer();
server.get('/hello/:name', respond);
server.head('/hello/:name', respond);

server.listen(8080, function() {
  console.log('%s listening at %s', server.name, server.url);
});

On the flipside, it's not like express has any specific disadvantages in terms of usage for APIs (and performance may actually be better, looking around at other StackOverflow questions). If you don't need any of the features that restify provides and express doesn't, and you have no plans for using them in the future, then you may as well just stick with express. It's all a matter of your needs for your API, really; there are plenty of other questions on StackOverflow regarding restify vs. express for specific cases, so take a look around at what information is already available.

JAB
  • 20,783
  • 6
  • 71
  • 80