gpt4 book ai didi

javascript - flatiron.js/union - 在哪里放置 app.use() 配置?

转载 作者:行者123 更新时间:2023-11-30 13:22:23 25 4
gpt4 key购买 nike

simple example来自 Union,我想知道在哪里可以放置通常在 app.configure 中的配置代码,例如 passport.js :

app.configure(function() {
// Initialize Passport! Also use passport.session() middleware, to support
// persistent login sessions (recommended).
app.use(passport.initialize());
app.use(passport.session());
});

有什么想法吗?服务器和路由器不接受 use()。

最佳答案

Union 似乎为此使用了 before 集合:

var server = union.createServer({
before: [
connect.session({ secret: 'keyboard cat' }), // for `passport.session()`
passport.initialize(),
passport.session(),

// etc.
]
});

来自"API" documentation :

@option before {Array} 
The `before` value is an array of middlewares, which are used to route and serve incoming
requests. For instance, in the example, `favicon` is a middleware which handles requests
for `/favicon.ico`.

关于javascript - flatiron.js/union - 在哪里放置 app.use() 配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9777355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com