Skip to content
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

Commands Middlewares #1049

Open
1 task done
Avivbens opened this issue Sep 8, 2023 · 0 comments
Open
1 task done

Commands Middlewares #1049

Avivbens opened this issue Sep 8, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Avivbens
Copy link
Contributor

Avivbens commented Sep 8, 2023

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

I'd like to have the ability to apply some logic before a few commands, as well as to have the current context & user input

Describe the solution you'd like

Apply Middlewares by a decorator, which could be the Command decorator as an option OR a decorator that would be placed over the Command.
It will allow us to apply middlewares just like NestJS guards.

@Command({
    name: 'install',
    description: 'Install MacOS setup with Multi-Selection',
    options: { isDefault: false },
    middlewares: [CheckUpdatesMiddleware, IsAuthorized],
})

OR

@Middleware([CheckUpdatesMiddleware, IsAuthorized])
@Command({
    name: 'install',
    description: 'Install MacOS setup with Multi-Selection',
    options: { isDefault: false },
})

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

Reduce painful logics that injects services & applies the logic over the run function,
as well as the need to create a context out of the run function.

@Avivbens Avivbens added the enhancement New feature or request label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant