UNPKG

restframework-express

Version:

ES6新特性,使用class来定义API接口,集成认证,权限,序列化,版本,视图,频率,过滤等公共能,插拔式设计模式

18 lines (16 loc) 509 B
const {NotImplementedError} = require("../exceptions"); class BasePermission { /** * 校验本次请求有没有权限 * @param req {Request} * @returns {boolean} */ hasPermission(req) { // 如果权限允许,return true // 如果不允许 抛出异常 throw new PermissionDenied("权限校验失败的信息") throw new NotImplementedError(`${this.constructor.name}.hasPermission()方法必须被重写`) } } module.exports = { BasePermission }