mfrachet
mfrachet

Reputation: 8922

REST API Node.js, organization

I m actually developping a REST API using Node.js and Express 4.0 and I wanted to clarify something.

The service is actually working, but in a single javascript file, and I m looking for a good way to cut it into multiples parts.

I was thinking about MVC, but with the actual route system, what is the controller ? Is it the declaration function of the route ?

How can I separate the different route into multiple files ? (like user_routes, billing_routes) etc... I know how to export module etc... but having app = express() in multiple file seems to not work (different instanciation) And where to start to the listen the part ?

These are beginner questions, but please, but explicit :-)

Thanks for advance

Upvotes: 2

Views: 922

Answers (1)

Related Questions