node.js

Why is passport.deserializeUser called after req.user has been restored?

痞子三分冷 提交于 2021-02-11 16:37:13
问题 According to the Passport Documentation on Sessions ...only the user ID is serialized to the session, keeping the amount of data stored within the session small. When subsequent requests are received, this ID is used to find the user, which will be restored to req.user. However my test SPA which is based on Passport form-based authentication sample with debug messages added indicates req.user has already been restored before the app.get route handler is triggered. Here is the output from an

Why is passport.deserializeUser called after req.user has been restored?

两盒软妹~` 提交于 2021-02-11 16:37:06
问题 According to the Passport Documentation on Sessions ...only the user ID is serialized to the session, keeping the amount of data stored within the session small. When subsequent requests are received, this ID is used to find the user, which will be restored to req.user. However my test SPA which is based on Passport form-based authentication sample with debug messages added indicates req.user has already been restored before the app.get route handler is triggered. Here is the output from an

Promise within while loop won't run - causing infinite loop

为君一笑 提交于 2021-02-11 15:56:20
问题 I am trying to run a Promise within a while loop. The code after the promise (in the .then) will eventually break the while loop. However, the promise never runs. The while loop just keeps running infinitely without triggering the promise. Why is this? Is it impossible to use a promise in a while loop? A simplified version of code is below while(relevantRefundRequests.length >= waitList[0].quantity){ stripe.paymentIntents.create({ }) .then(data => { ***code that will break while loop }) } 回答1

Promise within while loop won't run - causing infinite loop

北战南征 提交于 2021-02-11 15:55:53
问题 I am trying to run a Promise within a while loop. The code after the promise (in the .then) will eventually break the while loop. However, the promise never runs. The while loop just keeps running infinitely without triggering the promise. Why is this? Is it impossible to use a promise in a while loop? A simplified version of code is below while(relevantRefundRequests.length >= waitList[0].quantity){ stripe.paymentIntents.create({ }) .then(data => { ***code that will break while loop }) } 回答1

Running cron jobs for node.js in EBS worker environment via cron.yaml file

孤街浪徒 提交于 2021-02-11 15:54:54
问题 I am trying to configure cron jobs for a node project and uploading on a ebs worker environment. Here is my cron.yaml file when i upload this worker tier project to worker tier environment on ebs, i get the following error, [Instance: i-02c855ffd34efcc26] Command failed on instance. Return code: 1 Output: Failed of parsing file 'cron.yaml', because: key not found: "cron" - (AWS::EB::SQSD::ScheduleParser::ScheduleFileError). Hook /opt/elasticbeanstalk/addons/sqsd/hooks/start/02-start-sqsd.sh

NodeJS and react app deployment on AWS: not rendering react UI

独自空忆成欢 提交于 2021-02-11 15:54:54
问题 I've deployed a nodejs and react app to AWS EC2 following this tutorial. I can see the static html title but react views are not rendering. Looking at the network tab I notice some 404 for the get request but I'm not sure where the issue is. Here is my nginx setup: server { listen 80; location / { proxy_pass http://{{my ec2 ip}}:{{5000}}; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http

Sequelize hasMany is working fine but the inverse relation is not working

六月ゝ 毕业季﹏ 提交于 2021-02-11 15:54:00
问题 I am trying to work with mysql relations in Node Js(express Js) using Sequelize. User.hasMany(Post); work just fine, but when i try to inverse it in Post model like: Post.belongsTo(User); got this error: throw new Error(${source.name}.${_.lowerFirst(Type.name)} called with something that's not a subclass of Sequelize.Model); Error: post.belongsTo called with something that's not a subclass of Sequelize.Model User model like: const Sequelize = require('sequelize'); const db = require('..

Sequelize hasMany is working fine but the inverse relation is not working

血红的双手。 提交于 2021-02-11 15:52:48
问题 I am trying to work with mysql relations in Node Js(express Js) using Sequelize. User.hasMany(Post); work just fine, but when i try to inverse it in Post model like: Post.belongsTo(User); got this error: throw new Error(${source.name}.${_.lowerFirst(Type.name)} called with something that's not a subclass of Sequelize.Model); Error: post.belongsTo called with something that's not a subclass of Sequelize.Model User model like: const Sequelize = require('sequelize'); const db = require('..

Can't pass header with token for redirect NodeJS

你离开我真会死。 提交于 2021-02-11 15:49:58
问题 I've got big problem with my login system in NodeJS. I created login site, when i'm logging in. When i check if login and password is correct i make jwt token. Then i would like to pass it into header and redirect to my user page by get method. I searched a lot of sites and I' cant solve this problem. This is what I try to do: const token = jwt.sign({_id: id}, process.env.TOKEN); res.header('auth-token', token); res.redirect('/admin/admin_panel'); I would like to this work like Postman. I set

run pm2 logs error SyntaxError: Unexpected token

别等时光非礼了梦想. 提交于 2021-02-11 15:49:54
问题 I want to see logs of my project Steps : I clone a socket app. Then I run npm install pm2 -g to install pm2 I run pm2 start It works. It display a table of my socket app But if I run pm2 logs to see logs, there exist error like this : 1|mycompany | C:\PROGRAM FILES\NODEJS\NPM.CMD:1 1|mycompany | (function (exports, require, module, __filename, __dirname) { :: Created by npm, please don't edit manually. 1|mycompany | ^ 1|mycompany | 1|mycompany | SyntaxError: Unexpected token : 1|mycompany |