-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor authority check functions in API #180
Comments
Hi, 1 - Trying to run the application [17:10:45] Starting compilation in watch mode... -Sentry env variables are said to be unnecessary 2 - Trying to run the Unit Tests warn Versions of [email protected] and @prisma/[email protected] don't match. -tried installing both versions using pnpm, keeps throwing the same error 3 - Trying to run the Integration Tests docker compose up -d docker : The term 'docker' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
-Installed docker as per instructions, no further necessity was mentinoed |
Hey @szabodaniel995, thanks for trying to attempt this! I will try to address your issues based on the info you shared.
I hope this helps to solve some aspects of your issues. Please feel free to reach out to us over Discord or over here in case you find any more issues |
Thank you for the quick reply. /attempt |
Glad to hear that! |
One thing that I forgot to mention in the issue, you would have to change the file names aswell! Something similar to how the file names and function names are now. |
🎉 This issue has been resolved in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
We use a set of functions to determine whether a user has authority over a certain entity or not. Currently, we are having a few difficulties in extending the functionality of the function which is bad DevEx. Here are the issues:
Solution
Firstly, we would like to change the names of the functions. Here's what the new names will look like:
getWorkspaceWithAuthority
→checkAuthorityOverWorkspace
getProjectWithAuthority
→checkAuthorityOverProject
getEnvironmentWithAuthority
→checkAuthorityOverEnvironment
getVariableWithAuthority
→checkAuthorityOverEnvironment
getSecretWithAuthority
→checkAuthorityOverSecret
Note that the return type shouldn't change
Second, we would want to change the entity parameter that is passed down to the functions. Currently, we can only pass the id. For example,
workspaceId
,projectId
, etc. We would want to refactor it to have a structure like this:This will allow us to pass varying parameters to fetch the data. Note that, the implementation will also change. In the
try
block of every function, you will need to check the key that has been passed, and based upon that you will need to fetch the resource. Forid
, you will usefindUnique
and forname
, you will usefindFirst
.It goes without saying that the dependent code will also change, meaning you will need to update the existing code that uses these functions.
Additional context
The files can be found under the
apps/api/src/common
directory. These are the files:get-environment-with-authority.ts
get-project-with-authority.ts
get-secret-with-authority.ts
get-variable-with-authority.ts
get-workspace-with-authority.ts
The text was updated successfully, but these errors were encountered: