npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

strapi-plugin-route-permission

v2.0.1

Published

A strapi plugin that make use of routes to set the users permissions config, preventing yours route permissions to loss state from database.

Downloads

46

Readme

strapi-plugin-route-permission

🚀   Overview

This plugin implements a simple way to seed strapi permission::users-permissions table from routes configuration. It means that you can define your routes permissions direcly on yours routes.json files. So every time your server ups, it will recreate yours routes permissions from routes.json file, allowing you to migrate your application without worrying about redefine your routes permissions over strapi panel.


⏳   Installation

With npm:

npm install strapi-plugin-route-permission

With yarn:

yarn add strapi-plugin-route-permission

✨   Getting Started

In many cases, you will lost your database data while your application is in development, but strapi has a tiny problem, for each route action you want to get permission for a role, you need to configure it over strapi panel, and if you reset your database for any reason, every configuration is lost, and after some time, you can forgot about what route needs to target some specific role, broking your logic application and taking your time to reconfigure everything again.

Because this little detail, this plugin implements a simple route config rule, the roles, that can receive the default strapi roles (public, authenticated or both) or any other role that you should want to create. With that, every time yours server startup, it read all your routes and recreate the permissions for target roles on database, keeping your application always updated.

Example:

See the property on routes.*.config.roles parameter.

{
  "routes": [
    {
      "method": "GET",
      "path": "/plans",
      "handler": "plan.find",
      "config": {
        "roles": "authenticated",
        "policies": []
      }
    }
  ]
}

You can also, set more then one role to be target by your route permission:

{
  "routes": [
    {
      "method": "GET",
      "path": "/plans",
      "handler": "plan.find",
      "config": {
        "roles": ["authenticated", "public"],
        "policies": []
      }
    }
  ]
}

Result:

* If the specified role does not exists on database, it will be created automatically.

On strapi startup it reconfigure your permission table

On strapi permission panel, you can see the result applyed for the specified route.


🎉   Congradulations, You're done.

I hope this plugin helps you in your strapi projects and save a lot of time and code.


📜   License

This project is under the MIT license. See the LICENSE for details.


💻   Developed by André Ciornavei - Get in touch!