Ditch all that GLOBAL stuff. If you need app
to be available in an inner closure (like configure
) just use it there, it will be available.
Make sure you have a good grasp of closures before continuing, this SO post will help: How do JavaScript closures work?.
If you want to know how to layout an Express app (as in where do the files go), take a look at this SO post: express.js sample apps.