I have following structure:
It's just beginning, and there will be more files. I just created an auth mechanism using passport and its working, but now I want to move it outside
, and move my 'login' route to routes. When I do that I receive error
ReferenceError: app is not defined
How can I refer to app in file, which is required in app?
My other question is that I intend to use mongoose models which are now also defined in
but will be placed in
. Should I explicitly require necessary modules in each files, for example mongoose in
, then mongoose and model files in
or is there any magical way to just use all variables throughout whole app (not counting global variables)?
And my last question is, how can I import to
all other js files from
and its subdirectories? Maybe I should just do that manually, every file in separate require?