We have a popular web-app developed using CodeIgniter. Now we want to expose our data through a RESTful API.
Once we are done that we will rebuild the front end such that it merely acts as a client of our API.
People suggested that I should use NodeJS (or similar frameworks like SINATRA) for this API. I have few questions regarding this and I am sure experience devs can help.
If I chose NodeJS where do I put the business logic ? In the NodeJs code itself? Or does NodeJS code merely act like an interface between API clients and business logic implemented in more complicated framework ?
I am assuming here that the existing code is not much reusable.
I'm not sure if NodeJS is the right tool to use in this case (sure, it's cool to say "use nodejs" these days, but unless the tool fits the need, don't use it).
Have you looked at REST frameworks for PHP that are out there? e.g. FAPI
EDIT: You should also read: https://stackoverflow.com/questions/238125/best-framework-for-php-and-creation-of-restful-based-web-services
If I chose NodeJS where do I put the business logic ?
Is not a question of Node.js, it's a question of RESTful APIs. The shift from a regular browser-based web application to a pure RESTful web service will introduce some shifts right in your business logic (using a RESTful API, your clients and your service will exchange representations of resource, which will move parts of the business logic to the clients).
First of all, you should start transforming your application in to a set of (domain specific) resources, operations on these resources (based on HTTP verbs) and appropriate representations of these resources (i.e. JSON, XML). I'd recommed you read the original REST article first, and the consult eixisting API documentations on how to design such an API.
Next comes your implementation, where node.js can be one of multiple approaches. When choosing node.js, I'd recommed you to use existing modules for RESTful APIs in node.js, as the provide you interesting features, such as routing. Have a look at journey or restify