How to use built-in node.js as an API server?


Given that ember is built on top of node.js, how does one add express in order to develop the restful services required by ember data into the same server instance?


Ember uses npm as a package manager, but it doesn’t get executed by a node process, it actually gets executed entirely on the client in the browser.

Ember CLI uses a node server to serve static Ember files during development via ember server, but it’s not advisable to re-use that server for your API. While it’s possible to serve your static Ember files (index.html, webapp.js, webapp.css, etc.) via the same node process as your API, but it’s more common to run a separate server for each, even during development.

Take a look at this tutorial that covers how to set up a node server as an API for Ember Data to communicate with.


Thank you very much for your reply. This makes a lot of sense now after reading your explanation of how node is used. I definitely didn’t gather this from the documentation, and I appreciate your explanation.

With Ember fastboot coming soon I hope we’re about to get some enhancements to more directly connect the ember side with the node side.


If you wanted an opinionated framework to work within, check out Designed from the ground up to be a backend API framework.


Sorry, no - that’s not what I’m looking for (an opinionated api framework). I’m very comfortable with node/express for what we need to do.


There does seem to be a method built in to EmberJS for setting up a proxy server. I’m still trying to find the official documentation but this seems to be exactly what I’m looking for. Although my original question was looking for a way to load the API into the same server I’m happy to run it separately but at the same time I want all traffic to go through a single port in order to avoid JSONP/CORS on the client side (among other reasons).

ember generate http-proxy [local path] [remote URL]


Here are some Node.js tutorials that might help you out.