Tripwire is a Prisma extension designed to simplify the implementation of application roles and permissions, drawing inspiration from the functionality provided by Spatie Laravel. The extension is available on NPM as @ilovehanekawa/tripwire
.
To get started, install Tripwire using the following command:
npm install @ilovehanekawa/tripwire
Once installed, you can use Tripwire to generate the necessary files, migrations, and client for implementing roles and permissions in your Prisma model. Follow these simple steps:
- Run the Tripwire CLI with the model name you want to extend with roles and permissions:
npx tripwire init --model=<model_name>
Replace <model_name>
with the name of your Prisma model.
-
Tripwire will generate the required migrations, client, and files for your specified model.
-
A seeder file will also be created, providing handy helper functions such as
hasRole()
,assignRole()
, andremoveRole()
to facilitate role-related operations on your selected Prisma model.
npx tripwire init --model=User
This command will extend the "User" model with roles and permissions, creating the necessary files and migrations.
If you encounter any issues or have suggestions for improvements, feel free to contribute by opening issues or submitting pull requests on the Tripwire GitHub repository.
Tripwire is open-source software licensed under the GNU General Public License v3.0.