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 🙏

© 2026 – Pkg Stats / Ryan Hefner

rbac-generator

v2.1.0

Published

CLI npm pour generer un squelette RBAC frontend/backend a partir d'un modele declaratif.

Readme

RBAC Generator CLI

rbac-generator est une CLI Node.js qui genere un squelette RBAC frontend/backend a partir d'un modele declaratif defini dans access-model.config.mjs.

Installation

Installation globale recommandee pour la commande de creation de projet :

npm install -g rbac-generator

Ou comme dependance de developpement dans un projet existant :

npm install -D rbac-generator

Ou sans installation globale :

npx rbac-generator generate

Quick Start

  1. Initialisez un projet RBAC minimal
  2. Completez access-model.config.mjs
  3. Lancez la generation
npx rbac-generator init mon-projet

Puis :

cd mon-projet
npx rbac-generator generate

Exemple de configuration

export default {
  appName: "SimpleApp",
  chemins: {
    backend: "backend",
    frontend: "frontend",
  },
  roles: {
    ETUDIANT: {
      label: "Etudiant",
      dbRole: "app_student",
      defaultFrontendRoute: "/student",
    },
    ENSEIGNANT: {
      label: "Enseignant",
      dbRole: "app_teacher",
      defaultFrontendRoute: "/teacher",
    },
  },
  frontend: {
    publicRoutes: ["/login"],
    routeRules: [
      {
        key: "studentHome",
        path: "/student",
        match: "prefix",
        allow: ["ETUDIANT"],
        description: "Espace etudiant",
      },
      {
        key: "teacherHome",
        path: "/teacher",
        match: "prefix",
        allow: ["ENSEIGNANT"],
        description: "Espace enseignant",
      },
    ],
  },
  backend: {
    resources: [
      {
        key: "grades",
        basePath: "/grades",
        description: "Gestion des notes",
        operations: [
          {
            key: "list",
            method: "get",
            path: "/",
            allow: ["ENSEIGNANT"],
            description: "Lister les notes",
          },
          {
            key: "readOwn",
            method: "get",
            path: "/me",
            allow: ["ETUDIANT"],
            description: "Lire ses propres notes",
          },
        ],
      },
    ],
  },
};

Commandes

Initialiser un projet RBAC avec un package.json minimal et un access-model.config.mjs :

rbac-generator init mon-projet

Cette commande cree implicitement la base du projet, comme un npm init non interactif, avec un package.json minimal adapte au generateur RBAC.

Alias court :

rbac-generator i mon-projet

Generer les fichiers :

rbac-generator generate

Si access-model.config.mjs n'existe pas encore, la commande cree automatiquement un fichier de configuration minimal. Completez-le puis relancez generate.

Verifier si les fichiers generes sont a jour :

rbac-generator generate --check

Voir les changements sans ecrire sur disque :

rbac-generator generate --dry-run

Supprimer les fichiers generes :

rbac-generator clean

Voir ce qui serait supprime :

rbac-generator clean --dry-run

Options

Par defaut, la CLI lit access-model.config.mjs dans le repertoire courant.

Vous pouvez cibler un autre projet ou un autre fichier de configuration :

rbac-generator generate --cwd ./mon-projet --config ./config/access-model.config.mjs

Vous pouvez aussi initialiser un autre dossier projet :

rbac-generator init --cwd ./mon-projet

Ou bien fournir directement le nom du projet :

rbac-generator init mon-projet

Fichiers generes

La CLI genere notamment :

  • access-scaffold.generated.md
  • backend/access/generated/rbac.generated.js
  • backend/scaffold/generated/...
  • frontend/lib/access.generated.ts
  • frontend/scaffold/generated/...

Les chemins backend/frontend dependent des valeurs definies dans chemins.

Lors de l'initialisation, la CLI peut aussi creer :

  • package.json
  • access-model.config.mjs
  • le dossier du projet cible s'il n'existe pas encore

Cas d'usage

Cette CLI est utile si vous voulez :

  • centraliser les roles et permissions dans un seul modele
  • generer une base coherente pour le backend et le frontend
  • eviter les ecarts entre permissions backend et affichage frontend
  • accelerer le scaffolding d'un systeme RBAC

Notes

  • Le fichier de configuration doit exporter un objet par defaut
  • Les roles references dans les routes et permissions doivent exister
  • Chaque role doit avoir une route frontend par defaut protegee par une regle compatible
  • init et i creent une base minimale pour commencer rapidement
  • init se comporte comme un bootstrap de projet et initialise implicitement le package.json
  • generate peut creer automatiquement la configuration si elle n'existe pas encore