flightworker-atk-auth
Version:
## 中间件部署
27 lines (25 loc) • 670 B
Markdown
# flightworker-atk-auth
## 中间件部署
```js
// 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)
}
```