Access Node application instance in Controller2019 Community Moderator ElectionHow do I debug Node.js applications?How to append to a file in Node?ExpressJS How to structure an application?How to uninstall npm modules in node js?Uncompress gzipped http request body to json in Node.jsNo 'Access-Control-Allow-Origin' - Node / Apache Port Issuenode how to create a directory if doesn't exist?Nest.js And Restful CRUD, Why Isn't This Posting?Select AuthGuard type on the flyHow to avoid singleton behavior with a node-gyp generated node module?

When do _WA_Sys_ statistics Get Updated?

PTIJ: Aharon, King of Egypt

Why do phishing e-mails use faked e-mail addresses instead of the real one?

What is better: yes / no radio, or simple checkbox?

School performs periodic password audits. Is my password compromised?

Draw bounding region by list of points

Why would the IRS ask for birth certificates or even audit a small tax return?

How to roleplay my character's ethics according to the DM when I don't understand those ethics?

Would the melodic leap of the opening phrase of Mozart's K545 be considered dissonant?

How to fix my table, centering of columns

PTIJ: What’s wrong with eating meat and couscous?

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?

Every subset equal to original set?

GPL code private and stolen

I can't die. Who am I?

Can I solder 12/2 Romex to extend wire 5 ft?

How do I deal with being envious of my own players?

Are there other characters in the Star Wars universe who had damaged bodies and needed to wear an outfit like Darth Vader?

Where is the fallacy here?

Why is my Contribution Detail Report (native CiviCRM Core report) not accurate?

When to use mean vs median

Is divide-by-zero a security vulnerability?

What is the meaning of "notice to quit at once" and "Lotty points”

Is every open circuit a capacitor?



Access Node application instance in Controller



2019 Community Moderator ElectionHow do I debug Node.js applications?How to append to a file in Node?ExpressJS How to structure an application?How to uninstall npm modules in node js?Uncompress gzipped http request body to json in Node.jsNo 'Access-Control-Allow-Origin' - Node / Apache Port Issuenode how to create a directory if doesn't exist?Nest.js And Restful CRUD, Why Isn't This Posting?Select AuthGuard type on the flyHow to avoid singleton behavior with a node-gyp generated node module?










0















I'd like to access my Nest instance I created in my main.ts within my Controller:



main.ts



async function bootstrap() 
const app = await NestFactory.create(AppModule);
await app.listen(3000);



My Controller



 private superlogin: Superlogin;

constructor(private sfMainDbService: SfMainDbService)
this.instantiateSuperLogin(app); // How can I access my Nest app instance here?


public instantiateSuperLogin(app: any)
this.superlogin = new Superlogin(superLoginUsersConfig);
app.use('/users/auth', this.superlogin.router);



What's the correct way to achieve this?










share|improve this question
























  • You shouldn't be accessing your app inside of a controller or provider like this. It's an anti-pattern called Service Locator that runs contrary to the good design principles that Nest helps you establish. If you explain a bit more what you're trying to actually accomplish here with the SuperLogin we can help you move the instantiation to the correct place so that it can be injected directly to the controller.

    – Jesse Carter
    10 hours ago















0















I'd like to access my Nest instance I created in my main.ts within my Controller:



main.ts



async function bootstrap() 
const app = await NestFactory.create(AppModule);
await app.listen(3000);



My Controller



 private superlogin: Superlogin;

constructor(private sfMainDbService: SfMainDbService)
this.instantiateSuperLogin(app); // How can I access my Nest app instance here?


public instantiateSuperLogin(app: any)
this.superlogin = new Superlogin(superLoginUsersConfig);
app.use('/users/auth', this.superlogin.router);



What's the correct way to achieve this?










share|improve this question
























  • You shouldn't be accessing your app inside of a controller or provider like this. It's an anti-pattern called Service Locator that runs contrary to the good design principles that Nest helps you establish. If you explain a bit more what you're trying to actually accomplish here with the SuperLogin we can help you move the instantiation to the correct place so that it can be injected directly to the controller.

    – Jesse Carter
    10 hours ago













0












0








0








I'd like to access my Nest instance I created in my main.ts within my Controller:



main.ts



async function bootstrap() 
const app = await NestFactory.create(AppModule);
await app.listen(3000);



My Controller



 private superlogin: Superlogin;

constructor(private sfMainDbService: SfMainDbService)
this.instantiateSuperLogin(app); // How can I access my Nest app instance here?


public instantiateSuperLogin(app: any)
this.superlogin = new Superlogin(superLoginUsersConfig);
app.use('/users/auth', this.superlogin.router);



What's the correct way to achieve this?










share|improve this question
















I'd like to access my Nest instance I created in my main.ts within my Controller:



main.ts



async function bootstrap() 
const app = await NestFactory.create(AppModule);
await app.listen(3000);



My Controller



 private superlogin: Superlogin;

constructor(private sfMainDbService: SfMainDbService)
this.instantiateSuperLogin(app); // How can I access my Nest app instance here?


public instantiateSuperLogin(app: any)
this.superlogin = new Superlogin(superLoginUsersConfig);
app.use('/users/auth', this.superlogin.router);



What's the correct way to achieve this?







node.js nestjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 hours ago







matthiasunt

















asked 12 hours ago









matthiasuntmatthiasunt

421822




421822












  • You shouldn't be accessing your app inside of a controller or provider like this. It's an anti-pattern called Service Locator that runs contrary to the good design principles that Nest helps you establish. If you explain a bit more what you're trying to actually accomplish here with the SuperLogin we can help you move the instantiation to the correct place so that it can be injected directly to the controller.

    – Jesse Carter
    10 hours ago

















  • You shouldn't be accessing your app inside of a controller or provider like this. It's an anti-pattern called Service Locator that runs contrary to the good design principles that Nest helps you establish. If you explain a bit more what you're trying to actually accomplish here with the SuperLogin we can help you move the instantiation to the correct place so that it can be injected directly to the controller.

    – Jesse Carter
    10 hours ago
















You shouldn't be accessing your app inside of a controller or provider like this. It's an anti-pattern called Service Locator that runs contrary to the good design principles that Nest helps you establish. If you explain a bit more what you're trying to actually accomplish here with the SuperLogin we can help you move the instantiation to the correct place so that it can be injected directly to the controller.

– Jesse Carter
10 hours ago





You shouldn't be accessing your app inside of a controller or provider like this. It's an anti-pattern called Service Locator that runs contrary to the good design principles that Nest helps you establish. If you explain a bit more what you're trying to actually accomplish here with the SuperLogin we can help you move the instantiation to the correct place so that it can be injected directly to the controller.

– Jesse Carter
10 hours ago












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021201%2faccess-node-application-instance-in-controller%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021201%2faccess-node-application-instance-in-controller%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович