CodeGenieApp / CodeGenieApp/serverless-express
Dependencies not being injected on NestJS with Serverless stack and AWS
- Vorherrschende Sprache
- JavaScript
- Sterne
- 5.3k
- Forks
- 676
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
We are trying to integrate the NestJs with serverless stack and AWS . We have simple Controller that has a Service as a dependency.
when we make request to the controller the serviceObject that should contain the Service instance instead gives us undefined .
Below is our app.module.ts file contain
`
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
controllers: [AppController],
providers: [AppService,
],
})
export class AppModule {}
`
Lambda.ts contain
`
import { NestFactory } from '@nestjs/core';
import { ExpressAdapter } from '@nestjs/platform-express';
import serverlessExpress from '@vendia/serverless-express';
import { Context, Handler } from 'aws-lambda';
import express from 'express';
import { AppModule } from './app.module';
let cachedServer: Handler;
async function bootstrap() {
if (!cachedServer) {
const expressApp = express();
const nestApp = await NestFactory.create(
AppModule,
new ExpressAdapter(expressApp),
);
nestApp.enableCors();
await nestApp.init();
cachedServer = serverlessExpress({ app: expressApp });
}
return cachedServer;
}
export const handler = async (event: any, context: Context, callback: any) => {
const server = await bootstrap();
return server(event, context, callback);
};
`
Main.ts
`
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
`
Beitragsleitfaden
Rechercherichtung
Beginne mit dem Vergleich des Dependency-Setups in app.module.ts und der Bootstrap-Pfade in lambda.ts und main.ts. Reproduziere die undefinierte Service-Instanz mit der gemeldeten NestJS-, Serverless-, AWS- und Express-Integration und ermittle anschließend, ob das Verhalten spezifisch für den Lambda-Einstiegspunkt ist. Die Aufgabe wäre abgeschlossen, wenn eine bestätigte Ursache und eine reproduzierbare Behebung vorliegen; das Issue nennt jedoch weder einen Repository-Test noch eine Zielimplementierung.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws, express, node.js, typescript
- Bereich
- api, backend, cloud
- Issue-Typ
- Bug
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 15/100