Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@zenstackhq/redwood
Advanced tools
CLI and runtime for integrating ZenStack with RedwoodJS projects.
This package provides the CLI and runtime APIs for integrating ZenStack into a RedwoodJS project. You can use ZenStack as a drop-in replacement to Prisma and define flexible access control policies declaratively inside the database schema. It's especially useful for building multi-tenant applications which tend to have complex authorization requirements beyond RBAC.
ZenStack is a full-stack toolkit built above Prisma ORM. It extends Prisma at the schema and the runtime level for adding the following capabilities:
You can find a more detailed integration guide here.
Run the following package setup command:
yarn rw setup package @zenstackhq/redwood
The setup command will:
context.db
(ZenStack-enhanced PrismaClient
) instead of db
for data access.ZenStack's ZModel language is a superset of Prisma schema language. You should use it to define both the data schema and access policies. The Complete Guide of ZenStack is the best way to learn how to author ZModel schemas.
You should run the following command after updating "schema.zmodel":
yarn rw @zenstackhq generate
The command does the following things:
prisma generate
to regenerate PrismaClientThe workflow of using ZenStack is very similar to using Prisma in RedwoodJS projects. The two main differences are:
Generation
You should run yarn rw @zenstackhq generate
in place of yarn rw prisma generate
. The ZenStack's generate command internally regenerates the Prisma schema from the ZModel schema, runs prisma generate
automatically, and also generates other modules for supporting access policy enforcement at the runtime.
Database access in services
In your service code, you should use context.db
instead of db
for accessing the database. The context.db
is an enhanced Prisma client that enforces access policies.
The "setup" command prepared a customized service code template. When you run yarn rw g service
, the generated code will already use context.db
.
Other Prisma-related workflows like generation migration or pushing schema to the database stay unchanged.
You should run the "generate" command in your deployment script before yarn rw deploy
. For example, to deploy to Vercel, the command can be:
yarn rw @zenstackhq generate && yarn rw deploy vercel
@zenstackhq
CLI pluginThe @zenstackhq/redwood
package registers a set of custom commands to the RedwoodJS CLI under the @zenstackhq
namespace. You can run it with:
yarn rw @zenstackhq <cmd> [options]
The plugin is a simple wrapper of the standard zenstack
CLI, similar to how RedwoodJS wraps the standard prisma
CLI. It's equivalent to running npx zenstack ...
inside the "api" directory.
See the CLI references for the full list of commands.
You can find a complete multi-tenant Todo application built with RedwoodJS and ZenStack at: https://github.com/zenstackhq/sample-todo-redwood.
The best way to get help and updates about ZenStack is by joining our Discord server.
FAQs
CLI and runtime for integrating ZenStack with RedwoodJS projects.
The npm package @zenstackhq/redwood receives a total of 269 weekly downloads. As such, @zenstackhq/redwood popularity was classified as not popular.
We found that @zenstackhq/redwood demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.