Rls ts
Helps you write Supabase Row Level Security (RLS) in Typescript.
> ๐ Helps you write Supabase Row Level Security (RLS) in Typescript. (\* plv8) The project is written primarily in TypeScript, distributed under the MIT License license, first published in 2023. Key topics include: rbac, rls, role-based-access-control, row-level-security, supabase.
๐งถ Supabase RLS in Typescript
<br />๐ Helps you write Supabase Row Level Security (RLS) in Typescript. (* plv8)
๐ Usage
New website opned!!: https://supabase-rls.up.railway.app (Web Source)
1. Clone And Install
bashgit clone https://github.com/hmmhmmhm/rls-ts.git cd ./rls-ts npm install
2. Update Project Types
Please read the guide and follow it to read the type of Supabase project.
Generating Supabase Types
3. Create or Modify File
Create or modify the
example.tsfile in the./srcdirectory.
tsexport default createPolicy<TABLE_NAME>((context) => { // TODO: Your policy logic return true; });
Below is an example of use.
tsexport default createPolicy<"channels">((context) => { // * Allow only creators to update their own channels return context.row.created_by === context.auth.uid(); });
4. Build
After entering the command below, a file is created, such as
build/example.plv8.sql.
bashnpm run build
Copying the translated script and pasting it into the desired policy within Supabase takes effect. (Below is an example of sql file.)
sql-- example.ts.plv8.sql boolean as $$ function createPolicy(cb) { cb({ row: globalThis, function: globalThis, auth: globalThis.auth, plv8: globalThis.plv8 }); } return createPolicy(function(context) { // Allow only creators to update their own channels if (context.row.created_by === context.auth.uid()) return true; }); $$ language plv8;
โ License
MIT Licensed.
Contributors
Showing top 2 contributors by commit count.


