add isController/ isService check util
See original GitHub issueI’m submitting a…
[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
I didn’t find any way to check if a class is controller/service without referring to Nest internal values.
Expected behavior
I’d like Nest to provide exported functions to check if a class is decorated with Controller
/Injectable
.
Minimal reproduction of the problem with instructions
N/A
What is the motivation / use case for changing the behavior?
I am writing a tool to automatically load controllers& services from project directory. However, as Nest throws when loading non-Controller classes as controller, it requires to check if a class is Controller
before gathering them into an array and pass to Module
decorator.
Environment
Nest version: 5.4.0
For Tooling issues:
- Node version: v10.13.0
- Platform: macOS
Others:
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Rails Service Objects: A Comprehensive Guide - Toptal
A controller in Rails is the layer responsible for understanding, processing, and responding to your request. It uses the model layer to fetch...
Read more >Service layer and controller: who takes care of what?
I try to restrict controllers to doing work related to validating http parameters, deciding what service method to call with what parameters, ...
Read more >ARCCONF Command Line Utility User Guide for Adaptec ...
This guide explains how your Microchip Smart Storage controller supports the use of the ARCCONF command line utility. This utility allows you to:....
Read more >Setting Up Enterprise Manager Plug-In for Oracle GoldenGate
Optional: Run the utility to create the Oracle GoldenGate Monitoring ... Click Add to open the Search and Add: Targets page appears in...
Read more >HPE MSA 1060/2060/2062 Storage Management Guide
Disk groups are used in virtual storage environments and are added to pools to ... To run the verify utility, see "Verifying a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Unless you’re creating a 3rd party library, you could just proxy/wrap the decorators and add metadata to them yourself to determine whether or not its a controller or service.
Anyhow you’re wrong, the
@Controller()
decorator does define metadata on the metatype.https://github.com/nestjs/nest/blob/385071ba6dd3b98f91edfca0ed5aadb611bb678f/packages/common/decorators/core/controller.decorator.ts#L4-L13
I still don’t get what you want. Basically what you’re trying to accomplish is the exact opposite of what module architecture frameworks are here for. If you just glob through your entire project to put controllers and providers into the module decorator, then what’s the point of even using Nest?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.