CodeGenieApp / CodeGenieApp/serverless-express
Dependencies not being injected on NestJS with Serverless stack and AWS
- Lingua principale
- JavaScript
- Stelle
- 5.3k
- Fork
- 676
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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();
`
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia confrontando la configurazione delle dipendenze in app.module.ts e i percorsi di bootstrap in lambda.ts e main.ts. Riproduci l’istanza del service non definita con l’integrazione NestJS, Serverless, AWS ed Express indicata, quindi determina se il comportamento è specifico dell’entry point Lambda. Il lavoro sarebbe completo una volta confermata la causa e ottenuta una correzione riproducibile, ma l’issue non indica alcun test del repository né un’implementazione target.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- aws, express, node.js, typescript
- Ambito
- api, backend, cloud
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 15/100