question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add isController/ isService check util

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
marcus-sacommented, Nov 19, 2018

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?

0reactions
lock[bot]commented, Sep 24, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found