Hacker News new | past | comments | ask | show | jobs | submit login

This project looks really nice, though I really wish there was an easy way to segment routes into multiple files since it seems like an application w/ any kind of complexity would get out of hand quickly.

I didn't see a way by just skimming the docs - is there an easy way?




Yes, the 'app' global will be available in every file you require in.


Here's an example of my usual pattern, using express: https://github.com/ryancole/node-simple-upload/tree/master/n...

The routes are not namespaced like you'd see with something like Python's Flask does, but it still allows me to group all my similar routes.


this works for me:

include it in routes/index.js, and everything in your routes dir will be exposed if you do var routes = require('./routes')

var files = fs.readdirSync('./routes') files.forEach(function(file){ if(file != 'index.js'){ var exp = require('./'+file); _.extend(exports, exp); } });


just write a library that traverses a directory and include the files...




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: