Use EJS and REST with express

I am creating a Nodejs app with expressjs. For client side I want to do :

  1. One mobile app (android or ios)
  2. One web app (using navigator like chrome)

For the web app I am using EJS template and it's work fine but now I want to begin Mobile APP. For this, I created on my server side a REST API which send JSON data.

Is this the best solution ? Is EJS can use json data instead of passing directly object to the ejs page ?

You can send data to your iOS or Android app any way you want, it doesn't have to be REST... but it makes things a lot easier to understand and manage, both yourself and for others.

Generally, I see no advantage of using templates to serve up json data on a REST interface. You just want to serve out the raw data as is. You can wire it up yourself

app.get('/user',listUsersHandler);
app.get('/user/:user,listOneUserHandler);

etc.

Personally, I got fed up doing that and built my own library https://github.com/deitch/booster for it.

Any decent REST library should serve you up JSON without running it through your EJS templates.

A separate question is if you want to be efficient and run both the Web UI and the mobile app through the same REST API, which means moving towards an SPA/SOFEA/SOUI design, and using Backbone or Angular or similar in the Web UI.