Closed lottamus closed 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
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.
I resolved the conflicts and addressed @omar-dulaimi comments here: https://github.com/omar-dulaimi/prisma-trpc-generator/pull/78
Tysm 🙏🏽
Closing in favor of https://github.com/omar-dulaimi/prisma-trpc-generator/pull/78
Thank you for your work regardless though :)
Description
Currently
withShield
generates a boilerplate configuration usingallow
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 aboolean
(existing functionality) or astring
path. I decided onshieldPath
to be consistent with the other optionscontextPath
andtrpcOptionsPath
.References
Example input:
shieldPath
: https://github.com/lottamus/prisma-trpc-generator/blob/1c5695135815b904efe59d166e818e42d05d3a6e/prisma/schema.prisma#L11custom shield config
: https://github.com/lottamus/prisma-trpc-generator/blob/1c5695135815b904efe59d166e818e42d05d3a6e/prisma/shield.ts#L8Example output:
prisma/generated/routers/helpers/createRouter.ts