Move the api_application_node code out of API.cpp

This also makes sure that the node doesn't immediately exit.