2014-05-02 30 views
0

我在結合不同的模塊中的NodeJS

的NodeJS
  • 登錄
  • 聊天
  • 文件共享設置了獨立的工作模塊。

我想將它們全部結合起來。就像獲得成功登錄後,我希望它重定向到聊天模塊。現在我可以在登錄後重定向到靜態html頁面。

app.post('/login', passport.authenticate('local-login', { 
     successRedirect : '/profile', // redirect to the secure profile section 
     failureRedirect : '/login', // redirect back to the signup page if there is an error 
     failureFlash : true // allow flash messages 
    })); 

注:現在,如果我要運行任何模塊,我必須單獨編譯並在本地主機上運行它。

回答

1

假設您正在使用Express Framework for successRedirect,而不是將用戶重定向到「/ profile」路徑,請將其重定向到(可以說)'/ chat'並定義app.get('/ chat,回叫)路由,或導出您的聊天模塊並在您用於驗證/登錄的文件中要求它