我有一个快递应用,其主服务器代码在 server.js 文件中。在 server.js 文件中,路由;with SourceTable as (
select *
from (values
(1, null)
,(2, 5)
,(3, null)
,(4, null)
,(5, 2)
,(6, 1)
) as T(OrderNo, Value)
)
select
*
,first_value(Value) over (
order by
case when Value is not null then 0 else 1 end
, OrderNo
rows between current row and unbounded following
) as X
from SourceTable
order by OrderNo
在 dashboard.js 文件中,我有很多路由,例如app.get('/dashboard',require('./dashboard/dashboard.js')
,/profile
等。现在,如果我实现{{ 1}}到每条路线?还是通过实现单个身份验证功能来保护我的所有/editProfile
路由的其他方法?
答案 0 :(得分:0)
创建一个中间件,并将其添加到您的/ dashboard中,如下所示: app.get('/ dashboard',checkAuthentication,require('./ dashboard / dashboard.js')
答案 1 :(得分:0)
您可以在到达仪表板路线之前通过中间件功能。
app.get('/dashboard',
(req, res, next) => {
// Run passport isAuthenticated() here.
// If true, next();
// If false, throw
},
require('./dashboard/dashboard.js');