Hi,

You can give https://www.npmjs.org/package/expressmvp a try. We found this 
approach useful in our last project, to have modular design.

Thanks,
Unmesh 

On Saturday, 8 March 2014 00:12:07 UTC+5:30, Louis-Philippe Laurin wrote:
>
> Hi all,
>
> I am pretty new to JavaScript. My background is mostly C#. From my 
> understanding, the app.js should only be an initialization module. Correct?
>
> What is the general rule of thumb or best pattern (If i can call it like 
> that) when segregating the routes in a NodeJS application?
>
>
> I have seen this pattern many times and some people seems to like it.
>
> [APP.JS FILE]
>> app.configure(
>> /*This will automatically grabs all the routes from the mentioned routes 
>> directory*/
>>     var files = fs.readdirSync(RouteDir);
>>     files.forEach(function (file) {
>>         var filePath = path.resolve('./', RouteDir, file);
>>         var route = require(filePath)(app);
>>         route(app);
>>         console.log("Route :" + file + " enabled");
>>     });
>> );
>
>
> But to be honest, I am really questioning this. Yes...it removes 
> completely the "coding" dependencies but it creates an even more dangerous 
> one which is the actual file structure of the directory since you have no 
> control on it in your code.
>
> [APP.JS FILE]
>> /**********************************************
>>  * Services Init
>>  **********************************************/
>> var someService = require("./services/userService.js");
>>
>> /**********************************************
>>  * Routes Init
>>  **********************************************/
>> require('./routes/someRoute').addRoutes(app, someService);
>
>
> This one keeps a dependency (but at least you have control on it) and you 
> pretty much know WHAT is injected and WHERE it is.
>
> Is it me who is just being wrong?
>
> Thanks in advance for your advices,
> LP
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to