diff --git a/README.md b/README.md index ef667e3..17c9a35 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,8 @@ class Post extends authorize(Model) { } ``` +(Again, for now the only supported `library` value is `casl`) + ### Options You can pass an _optional_ options object as the third parameter during initialization. The default values are as follows: diff --git a/src/index.js b/src/index.js index 165fef1..9af0e6c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ const pick = require('lodash/pick') const merge = require('lodash/merge') +const isString = require('lodash/isString') // TODO: @sssss465 I mean like this kind of shit async function fillResourceContext(args) { @@ -11,8 +12,8 @@ async function fillResourceContext(args) { args.context._authorize = OGValue } -module.exports = (acl, library = 'role-acl', opts) => { - if (!acl || typeof library === 'object') { +module.exports = (acl, library, opts) => { + if (!acl || !isString(library)) { throw new Error( "usage: require('objection-authorize')(acl, library: String[, opts: Object])(Model)" )