Can i use nestjs services in expressjs ?
- User
Can i use nestjs services in expressjs ?
Assistant
Yes, it is possible to use NestJS services in an Express.js application. Here are a few ways you could accomplish this:
-
Export the NestJS service and import it into Express. In your NestJS module, export the service class. Then in your Express app, import that service class and instantiate it. You can then use the methods on the service instance in your Express routes/controllers.
-
Build the NestJS application first, then import and mount it in Express. Build out the NestJS application normally, including controllers. Then in your Express app, import the NestJS app instance using
app.init()or . Mount the NestJS app router middleware into the Express app to route requests to the NestJS controllers.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.