Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is what I do. Please comment if you need more help tailoring it to your code.</p> <p><strong>First Step</strong></p> <p>Put your passport code in a separate file. e.g. pass.js. (I see you have already done that) Then, in that file, put all the code inside this:</p> <pre><code>module.exports = function(passport, LocalStrategy){ }; </code></pre> <p>Remember to add to the function input anything else that you are using. In your case, besides passport and LocalStrategy, you will probably need to add mongoDbConnection as an input too.</p> <p><strong>Second Step</strong></p> <p>In your app.js, include this line. Just before "app.listen" if possible to ensure that everything has been properly defined/declared/included.</p> <pre><code>require('./pass.js')(passport, LocalStrategy); </code></pre> <p><strong>Explanation</strong></p> <p>The "wrapper" in step one defines the chunk of code you will be including into your app. The "require" in step two is the code that actually includes it. You are basically defining the entire "pass.js" file as a function and passing it the tools it needs to carry out the code (passport, LocalStrategy etc)</p> <p>In your case, you will probably need to modify my code to:</p> <pre><code>module.exports = function(passport, LocalStrategy, mongoDbConnection){ }; require('./pass.js')(passport, LocalStrategy, mongoDbConnection); </code></pre> <p>This should works. I googled about this a while ago and this appears to be the "correct" way to break up your app.js (I say this with great trepidation though :) ). Feel free to comment if you need anymore help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload