Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we use a common service without module into other module (specifically controller) in NestJs?

I am working on a NestJs project. There are different modules. I want to have a common service without module that can b used anywhere in the app. Is it possible to use a common service without module? If yes then how can i use it? Actually i want to use different functions from a service.

like image 316
Jawad Ali Avatar asked Sep 15 '25 05:09

Jawad Ali


1 Answers

if you want to use service term you need to register @Injectable() service to a module you can register it to app.module.ts, but it depends on what common.service.ts exactly do ?

if you want to use a dependency injection mechanism of Nestjs you should add @Injectable and a Scope then register it into whatever module do you want.

if you got the answer plz vote me up :), if not leave a comment with more details

like image 184
0xbeny Avatar answered Sep 17 '25 01:09

0xbeny