How Would I Break Out the Controllers into Individual Files?

61 views
Skip to first unread message

pnewhook

unread,
Jul 24, 2010, 8:01:31 PM7/24/10
to Express
It's been touched on in other threads, but I can't find a solid answer
or an example. How would I break out controllers into separate files?
App.js would get pretty unruly without that.

Kadir Pekel

unread,
Jul 25, 2010, 5:20:09 AM7/25/10
to expre...@googlegroups.com
Hi pnewhook,

I'm not the expert but there is a blog example on express repo. On app.js file there is a comment how to separate your app into several files.

http://github.com/visionmedia/express/blob/master/examples/blog/app.js

Probably you refer the root application instance by simply typing

var app = module.parent.exports;


best regards.


--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.




--
Kadir Pekel

vision media [ Tj Holowaychuk ]

unread,
Jul 26, 2010, 12:01:31 PM7/26/10
to expre...@googlegroups.com
Yup thats right. since we export our parent app, when require()ing another file
you can refer to the parent module as module.parent.exports;
Tj Holowaychuk
Vision Media
President & Creative Lead
Reply all
Reply to author
Forward
0 new messages