4 ms·
Building REST APIs with Node.js
- byoung2 14y agoI'd also recommend Restify http://mcavage.github.com/node-restify/ http://mcavage.github.com/node-restify/ for writing API's on Node.
- jawerty 14y agoI understand that restify has faster responses, but what else can put it on par with express?
- general_failure 14y agoI recommend express simply because more people know about it. This really matters in an ecosystem so young as node. Information is very hard to get. Hint : compare the number of express and restify blog posts. Note : I do use testify and its great. In addition, if you want to take you rest a pi server to also provide web pages, express is more suitable.
- helper 14y agoI second this recommendation. Restify is targeted at APIs so it has built in support for things like API versioning, auto content negotiation and observability (via DTrace). This is not to say that express is bad or that you can't build APIs using express but rather that I find restify more enjoyable to use for APIs.
- qdnguyen 14y agoAnd lighter!
- chrisennis 14y agoAs someone who has built APIs on node+express, I love it for small lightweight API's that require very little processing beyond getting data from a database and returning it. I have gone through much frustration though when I needed to use it for an API that required processing that only made sense to handle synchronously. At that point, it becomes less practical.
- general_failure 14y agoFor sync processing just use node modules - step or async. After all sync processing is a subset of async processing.
- ishbits 14y agoWhy would one use Express to a purely services based app instead of just using straight up node?
- nateweiss 14y agoAlso consider using Connect (on which Express is built) as an in-between point. You get stuff like the Sinatra-style routing, but without the presentation-tier stuff like template support, etc. I've had good luck with it, FWIW.
- cmwelsh 14y agoIt would be a nicer example to use "pretty SEO URLs" for the individual post resources instead of a GET variable. I know even the Hacker News website goes against this, but it just looks more professional/polished to me, i.e. /posts/mytitle
- jawerty 14y agoI thought it would be better to have querying in the example to make it simpler to understand.
- shtylman 14y agoYou should not use '*' in dependencies ever! As history changes your app WILL break. app.configure is also no longer needed. Just configure everything at the top level. If you have different config based on environment, use an if statement or some flag off the process.env
- dxchester 14y agoIf you're building REST APIs with Express and MySQL, check out this project I'm working on called Epilogue: https://github.com/dchester/epilogue https://github.com/dchester/epilogue With Epilogue, once you define your models (with Sequelize), from there it's easy to get basic CRUD functionality and endpoints in a few lines of code.
- baugarten 14y agoI am also working on a framework for quickly building REST APIs in node. The project is currently at https://github.com/baugarten/node-restful https://github.com/baugarten/node-restful and under development