Code Monkey home page Code Monkey logo

fastify-guard's People

Contributors

diginomicon avatar francisdaigle avatar hsynlms avatar jtsamper avatar leandroandrade avatar vasilianeugen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fastify-guard's Issues

update fastify 4.x

FastifyError [Error]: fastify-plugin: fastify-guard - expected '3.x' fastify version, '4.2.0' is installed

Wrong documentation

In the README.md

This code doesn't work:

{ preHandler: [fastify.guard.role(['cto', 'admin'])] },

Instead it should be without []

{ preHandler: [fastify.guard.role('cto', 'admin')] },

setup github workflow

When new PRs are sent, there is no CI mechanism to check changes and linter errors.

Cannot read property 'role' of undefined

preHandler: [fastify.guard.role(['admin'])] -> In this way, preHandler is already called upon startup. And not on the route call.

image

Inside the preHandler function... fastify.guard.role(['admin']) don't work.

If you can correct me if I did something wrong.

"fastify": "^3.8.0"

revise gitignore file

We do not need environment-specific ignored files. Instead, only ignore project-specific things. Contributors need to ignore environment-specific things like .vscode, .DS_STORE etc, in their global gitignore file.

TS declaration is wrong

With the update of 1.3.0 my project has been broken.

With this declaration

role(roles: string | string[]): preHandlerHookHandler

Only allow

role('ADMIN') or role(['ADMIN','USER']);

Therefore this would not work

// this route can only be called by users who has 'admin' or 'editor' role
fastify.get(
  '/',
  { preHandler: [fastify.guard.role('admin', 'editor')] },
  (req, reply) => {
    // 'user' should already be defined in req object
    reply.send(req.user)
  }
)

To enable this functionality it should be:

role(...roles: string[]): preHandlerHookHandler
role(roles: string[]): preHandlerHookHandler

The same happens with the scope function

scope(scopes: string | string[]): preHandlerHookHandler

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.