Giter Club home page Giter Club logo

koa-2-acl's Issues

Integrate with Koach

Hello, i've been trying to integrate this package with Koach with no success. i added koa-2-acl on the router.js but it could not working. can you pls take a look at it

// user model
const User = new mongoose.Schema({
  type: { type: String, default: 'User' },
  role: { type: String, default: 'User' },
  name: { type: String },
  username: { type: String, required: true, unique: true },
  password: { type: String, required: true }
})

import glob from 'glob'
import acl from 'koa-2-acl'
import Router from 'koa-router'

exports = module.exports = function initModules (app) {
  glob(`${__dirname}/*`, { ignore: '**/index.js' }, (err, matches) => {
    if (err) { throw err }

    matches.forEach((mod) => {
      const router = require(`${mod}/router`)

      const routes = router.default
      const baseUrl = router.baseUrl
      const instance = new Router({ prefix: baseUrl })

      routes.forEach((config) => {
        const {
          method = '',
          route = '',
          handlers = []
        } = config

        const lastHandler = handlers.pop()

        instance[method.toLowerCase()](route, ...handlers, async function (ctx) {
          await lastHandler(ctx)
        })

        app
          .use(instance.routes())
          .use(instance.allowedMethods())
          .use(acl.authorize)
      })
    })
  })
}

role does not exist on the ctx.request.decoded (jsonwebtoken) or ctx.request.session. it exist on ctx.state.user

ENOENT: no such file or directory Error during installation

Here is the command and its result. Module is not getting installed but throwing weird errors like this.

npm i koa-2-acl
npm WARN ********* No repository field.

npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /*********/node_modules/koa-2-acl/node_modules/.bin/eslint
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/*********/node_modules/koa-2-acl/node_modules/.bin/eslint'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /*********/.npm/_logs/2020-02-06T11_54_34_041Z-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.