Wednesday 18 November 2015

Node.js Beginner Question: How to properly organize api code?

Hi everyone, Java developer here who wants to get into nodejs development. My goal is to create an Restful API which accesses a MySql database and returns values. I have made it work, but all of my code is in server.js currently.How I understand it server.js should only start the server and initialize the application. Is it the right way to encapsulate funcionality in modules?If I think in an object oriented way I would make at least one module which provides the database access and reads the data from the database. Another module which sets the REST routes and handles the requests.Does anybody have a simple example which shows that? All tutorials I find seem to be "How to create a Restful API the quick and dirty way".

Submitted November 18, 2015 at 05:10PM by mikugo

No comments:

Post a Comment