@Shogun very nice! I thought global was some evil thing.. @Mundi, yes, I came from PHP and I really miss this folder pattern...
Em domingo, 27 de maio de 2012, C. Mundi escreveu: > Amen. I went through the same thing. I wish this had been a higher > design priority for node, but I think I see why it wasn't. Moving > JavaScript out of the browser and onto the server comes with some > challenges. > On May 27, 2012 9:00 AM, "Alan Hoffmeister" <[email protected]> > wrote: > > Yup, I could do this, but I'm writting a MVC framework and splitting > routes, views, rpc, models, configs, validations, translations an other > things between multiple folders, that's because I really don't like to have > my huge app inside one big js. > > My main idea is to maintain a simple module that could load this parts > from everywhere, I mean that I can use: > > var mvc = require('mvc'); > users = mvc.model('User'); > conf = mvc.conf(); > > Inside myapp/controller/index.js, inside myapp/rpc/user.js or whatever, > without worrying how far I'm from my user model schema or my config files... > > This way I just need to configure my MVC main module to look inside the > right places and forget ugly relative paths like > require('../../config/database/production') and etc. > > I don't know if I could express myself the way that I intended, but that's > my idea :) > > Em domingo, 27 de maio de 2012, Anand George escreveu: > > Hope you don't mind my asking... but do you really need a parser for a > config file. Couldn't it just be required as below: > > config.js > > module.exports = { > host: "localhost", > port: 8000 > } > > app.js > > var c = require('./config') > console.log(c.host + c.port); > > On Sun, May 27, 2012 at 7:18 PM, Alan Hoffmeister < > [email protected]> wrote: > > @Anand, yep, but you can use `npm link mymodule` > > -- > Att, > Alan Hoffmeister > > > 2012/5/27 Anand George <[email protected]> > > Coming back to your question > > npm install -g mymodule will not be available when you require it using > > mymodule = require('mymodule') > > See > http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/ > > On Sun, May 27, 2012 at 5:14 PM, Alan Hoffmeister < > [email protected]> wrote: > > @mscdex that's it. > > I need this to parse config files, and now I can require() my parser from > everywhere without the need to send the app path :) > > -- > Att, > Alan Hoffmeister > > > > 2012/5/27 Anand George <[email protected]> > > Ok. I get it now. And thanks for both solutions offered. Guess it's useful > in cases like the socket.io implementation where you wish to link some > client-side libraries in the path. > > > On Sun, May 27, 2012 at 11:10 AM, mscdex <[email protected]> wrote: > > On May 26, 11:33 pm, Anand George <[email protected]> wrote: > > Next run app.js and the console logs > > > > /home/anand/node/Testing/dirpath > > I think he wants the path of app.js from the module, so: '/home/anand/ > node/Testing/pathtest' is what he is expecting. > > -- > 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> > > http://groups.google.com/group/nodejs?hl=en?hl=en > -- -- Att, Alan Hoffmeister -- 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
