restframework-express
Version:
ES6新特性,使用class来定义API接口,集成认证,权限,序列化,版本,视图,频率,过滤等公共能,插拔式设计模式
21 lines (19 loc) • 566 B
JavaScript
const {NotImplementedError} = require("../exceptions");
class BaseAuthentication {
/**
* 认证方法
* @param req {Request} express.Request
*/
authenticate(req) {
/**
* Authenticate方法 返回两个值得元组(数组)
* return [user, token]
*/
// throw new Error(".authenticate() 方法必须被重写")
// return ["user", "token"]
throw new NotImplementedError(`${this.constructor.name}.hasPermission()方法必须被重写`)
}
}
module.exports = {
BaseAuthentication
}