express

PassportJS Custom Authenticate Callback Not Called

北城余情 提交于 2020-01-01 05:19:11
问题 Update: The below error was fixed by a commit. I've marked the first answer as 'correct', though the commit was brought to my attention in one of its comments I was hoping to utilize the custom callback to handle both successes and failures for logins in Passport's authenticate local strategy, but it looks like it's only called on success. Here is a snippet of what I'm talking about: passport.use(new LocalStrategy( {usernameField: 'email', passwordField: 'password'}, function(email, password,

What are everyauth promises?

混江龙づ霸主 提交于 2020-01-01 04:09:29
问题 I don't understand what everyauth promises are. I see that I need to return a promise object or user, but what is an everyauth promise? 回答1: It's useful when you have a function that performs authentication, but which does so asynchronously. You can't directly return user information from the function (because you have to wait for the callback to fire), so instead you return a promise . This is a special object that acts as a "placeholder" for what will eventually be filled with user

Socket.IO error 'listen()' method expects an 'http.Server' instance after moving to Express 3.0

梦想的初衷 提交于 2020-01-01 04:03:47
问题 I began learning Node.js today and I'm a little stuck. Following this example, I get the following error when I try executing the js file: Warning: express.createServer() is deprecated, express applications no longer inherit from http.Server, please use: var express = require("express"); var app = express(); Socket.IO's `listen()` method expects an `http.Server` instance as its first parameter. Are you migrating from Express 2.x to 3.x? If so, check out the "Socket.IO compatibility" section

Socket.IO error 'listen()' method expects an 'http.Server' instance after moving to Express 3.0

£可爱£侵袭症+ 提交于 2020-01-01 04:03:28
问题 I began learning Node.js today and I'm a little stuck. Following this example, I get the following error when I try executing the js file: Warning: express.createServer() is deprecated, express applications no longer inherit from http.Server, please use: var express = require("express"); var app = express(); Socket.IO's `listen()` method expects an `http.Server` instance as its first parameter. Are you migrating from Express 2.x to 3.x? If so, check out the "Socket.IO compatibility" section

Node.js, PostgreSQL error: no pg_hba.conf entry for host

孤人 提交于 2020-01-01 03:56:19
问题 I am following this article ((http://nodeexamples.com/2012/09/21/connecting-to-a-postgresql-database-from-node-js-using-the-pg-module/). I have already deployed my app to heroku and currently using express, node.js, to try and connect to a PostgresSQL database in Heroku that I just installed. I get to the very end of the article and I use the command node myfile.js I get this error error: no pg_hba.conf entry for host "...", user "...", database "...", ... How do I go about creating one and

Node.js and Forever “exited with code: 0”

时间秒杀一切 提交于 2020-01-01 03:43:27
问题 CentOs 6.5 using root acount, I have a working Node.js Express app: root@vps [/home/test/node]# npm start app.js > test@0.0.1 start /home/test/node > node ./bin/www app.js The app can be seen working on the internet browser. I stop the app and try to run it with forever: root@vps [/home/test/node]# forever start app.js warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms info: Forever processing file:

Mongoose getter / setters for normalizing data

巧了我就是萌 提交于 2020-01-01 03:33:10
问题 I have User schema which has a username field. I would like this field to be case sensitive, so that users may register names such as BobDylan . However, I need my schema to validate new entries to check there are no duplicates, incase sensitive, such as bobdylan . My research has taught me that I should create an additional field in the schema for storing a lower case / upper case version, so that I can easily check if it is unique. My question is, how would I achieve this with the Mongoose

Dynamically load routes with express.js

陌路散爱 提交于 2020-01-01 03:14:09
问题 I am using express.js as a webserver and would like an easy way to separate all the "app.get" and "app.post" functions to separate files. For example, if I would like to specify get and post functions for a login page, I would like to have a login.js file in a routes folder that is dynamically loaded (will automatically add all of the files without having to specify each one) when I run node app.js I have tried this this solution!, but it isn't working for me. 回答1: app.js var express=require(

Uploading large file to NodeJS webserver

五迷三道 提交于 2020-01-01 03:13:06
问题 I am serving up my web application using NodeJS server (ExpressJS) currently. One of the new requirements is for the users to be able to upload large videos (potentially in gigs) to the server. They will later then be able to download them again. Could I achieve this with the current stack? I came across tutorials using Multer JS with "multipart/form-data" specified by the front-end. If I use this, would my Express be able to serve up other HTTP requests while writing a giant single video

How to create a handshake between PHP web server and Socket.io on node.js server?

♀尐吖头ヾ 提交于 2020-01-01 03:12:31
问题 I have a websocket running on node.js 4.0 on server 10.0.4.18 at port 8020. I implemented my websocket using socket.io v1.3, express, and express-session. Project Definition I need to be able to create a session in socket.io for every user that connects to it from a PHP application. After the user send the first HTTP request, I will authenticate them using a token that will be passed from PHP to socket.io along with the HTTP request. After the user is authenticated, I need to save some