Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a clean architecture for RestAPI on NodeJs

I'm thinking to move some REST Services to NodeJS. The only thing I'm worry about is the architecture of this kind of solution.

Do it exist somewhere some guideline? Of course, I saw some library like restify. It's a good start but not enough.

I'm looking to layer's separation, dependency injection, unit tests, csrf and more.

like image 580
Yohann Avatar asked Dec 20 '13 14:12

Yohann


1 Answers

Take a look here: http://nodeframework.com/

This is a list of Nodejs frameworks for a variety of uses. Will you displaying web pages? You'll likely choose one of the MVC models. Just creating an API? You'll just need one of the REST API frameworks.

The choice for logging, unit tests, documentation style, etc. isn't specific to Node (even though it is relatively new). There are multiple Unit Test frameworks, logging frameworks, documentation styles/frameworks, etc. This is true for Node as well as Java, C++, and other popular languages. Developers of these frameworks try to make using their software "easy" - in that you're not tied into multiple dependencies, can swap out other parts, integrate it easily and so on.

If you're looking for an all-in-one solution, I doubt you'll find it. Because everyone has different tastes, there are a few options for each part of the solution, and you're able to choose the pieces that work for you (and your requirements/customer). What works this time may not be the best choice the next time.

I'd suggest looking for an example on-line that comes close to what you're trying to do, and then follow their example or build from their demo, using the same modules.

Edit: Following the first link, there is a deprecated list of frameworks from Joyent here.

Edit2: This particular part of the Joyent list maybe useful to you. Perhaps that "Boilerplate" style of module will help your searching.

like image 185
clay Avatar answered Oct 05 '22 04:10

clay