express icon indicating copy to clipboard operation
express copied to clipboard

Possible to use with NestJS ?

Open Suedo opened this issue 5 years ago • 2 comments

Since NestJS is a framework built on express, and this project uses aws-serverless-express which is supposed to work with any express framework, I was hoping there would be a way to use this plugin for NestJS projects.

Any ideas ?

Suedo avatar Jun 14 '20 12:06 Suedo

You should be able to as express is a valid HTTP transport for nest js. See https://github.com/serverless-components/express/issues/12 as to how you would make it work with TS.

germangamboa95 avatar Aug 23 '20 07:08 germangamboa95

I am currently in the same situation and I must state, this will not be an answer for you, unfortunately.

Judging from the current state of the Express component for Serverless, there is an inherent "clash" between the asynchronous nature of bootstrapping a NestJS application instance and the synchronous handler code implemented within the Express component.

In essence, for the Express Component to work, you need to export your Express application instance from your app.js. The Express Component Lambda handler will require() your app.js (hence get your Express application instance) and handle the incoming Lambda event. In a NestJS environment though, you would need to create your Nest application first, which is an asynchronous operation through NestFactory.create().

Although it should not be really difficult to create a custom component for Express-backed NestJS based off of the Express one.

attilagyongyosi avatar Jan 13 '21 22:01 attilagyongyosi