omar-dulaimi / prisma-trpc-generator

Prisma 2+ generator to emit fully implemented tRPC routers
MIT License
665 stars 31 forks source link

feat: optional shieldPath #65

Closed lottamus closed 1 year ago

lottamus commented 1 year ago

Description

Currently withShield generates a boilerplate configuration using allow for all procedures, and overwrites it on each generation.

This PR adds a new option shieldPath that allows your to provide a path to your own tRPC Shield to use as the permission layer.

Alternatively, we could extend withShield to allow either a boolean (existing functionality) or a string path. I decided on shieldPath to be consistent with the other options contextPath and trpcOptionsPath.

References

Example input:

Example output:

prisma/generated/routers/helpers/createRouter.ts

image
omar-dulaimi commented 1 year ago

When I set these options:

  withShield        = true
  shieldPath        = "./shield/my-shield"

The outputted shield is not in the correct path, nor the import is correct inside createRouter

omar-dulaimi commented 1 year ago

Hey, can we merge the options instead?

Same field withShield. This will make it accept either a boolean to enable/disable generation or a string path, to use an existing shield.

imsanchez commented 1 year ago

I resolved the conflicts and addressed @omar-dulaimi comments here: https://github.com/omar-dulaimi/prisma-trpc-generator/pull/78

Tysm 🙏🏽

omar-dulaimi commented 1 year ago

Closing in favor of https://github.com/omar-dulaimi/prisma-trpc-generator/pull/78

Thank you for your work regardless though :)