express 4.0 ,带有奇怪警告消息的 express-session [英] express 4.0 , express-session with odd warning message

查看:32
本文介绍了express 4.0 ,带有奇怪警告消息的 express-session的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 express 4.x 设置 nodejs 应用程序.在解决了中间件删除问题后,我终于成功了.

I am trying to work through setting up a nodejs app using express 4.x. After stumbling through the middleware-removal issues, I finally got it working.

但是,在以下代码行中有几条警告消息:

however, there was a couple of warning messages in the following line of code :

app.use(session({secret: '<mysecret>'})

这些警告是:

Sun, 29 Jun 2014 12:45:10 GMT express-session deprecated pass resave option; default value will change at libconfigexpress.js:55:11

Sun, 29 Jun 2014 12:45:10 GMT express-session deprecated pass saveUninitialized option; default value will change at libconfigexpress.js:55:11

在文档中,resave 和 saveUninitialized 的默认值为 true.

in the documentation, the default values for resave and saveUninitialized are true.

因此,更改代码以读取

app.use(session({secret: '<mysecret>', 
                 saveUninitialized: true,
                 resave: true}));

摆脱了警告.

所以,进入问题的重点:

So, to get to the point of the question:

如果这些值是默认值,为什么我必须传入它们,为什么我不必传入其他选项?

why should I have to pass these values in if they are the default values, and why don't I have to pass in the other options ?

推荐答案

正如警告所说,默认值会更改,因此他们希望通过现在明确设置值来确保您不会遇到意外行为默认值确实会改变(在不久的将来).

As the warnings say, the default values will change so they want to ensure that by setting the values explicitly now, you won't run into unexpected behavior when the defaults do change (in the near future).

这篇关于express 4.0 ,带有奇怪警告消息的 express-session的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆