koa-otp
1.0.0 • Public • Published
$ npm i -S koa-otp
const Koa = require('koa')
const compose = require('koa-compose')
const app = new Koa()
var otp = require('koa-opt')("jkjldsfsfsdf")
var _token;
app.use((ctx, next) => {
switch (ctx.path) {
case '/encode':
return otp.encode(function (ctx, next) {
ctx.body = {
token: ctx.otp_token,
valid: ctx.otp_valid
}
})(ctx, next)
case '/decode':
return compose([otp.encode(function (ctx, next) {
_token = ctx.otp_token
return next()
}),
otp.decode(_token, function (ctx, next) {
ctx.body = {
token: ctx.otp_token,
valid: ctx.otp_valid
}
})
])(ctx, next)
break
}
})
app.listen(3004)
Versions
Version | Downloads (Last 7 Days) | Tag |
---|
1.0.0 | 2 | latest |
Version History
Version | Downloads (Last 7 Days) | Published |
---|
1.0.0 | 2 | |
Package Sidebar
Install
Weekly Downloads