1.0.3 • Published 6 years ago
flightworker-atk-auth v1.0.3
flightworker-atk-auth
中间件部署
// API服务器
const auth = require('flightworker-atk-auth')
const middleware = config => (req, res, next) => {
const $auth = auth({...})
$auth.once('success', status => {
next()
})
$auth.on('error', e => next())
return auth.check(req, res)
}
// AMN or APN
const auth = require('flightworker-atk-auth')
const middleware = config => (req, res, next) => {
const $auth = auth({...})
$auth.once('token', token => {
// todo 请将token发送至API配置的获取token的地址上
next()
})
$auth.on('error', e => next())
return auth.middleware(req, res)
}