#Generate endpoints in runtime

3 messages · Page 1 of 1 (latest)

regal dove
#

I have created dynamic controllers with services and entities. I have a JSON with a model and I want to generate an example controller (InvoiceController) at runtime with a method to get invoiceModel.findAll(). I tried to write this code with ChatGPT but without success. Is this possible in NestJS? Algoritm createDatabaseStructure -> createEndpoint -> publishSwagger.

regal dove
#

When i write this code in main.ts before await app1.listen(3000);

app1 = await NestFactory.create(AppModule);

const expressApp = app1.getHttpAdapter().getInstance();

expressApp.get('/zhas4', (req, res) => {
res.json({ message: 'Dynamic module' });
});

its workking.

But when i write this code in contoller:const app1 = await NestFactory.create(AppModule);

  const expressApp2 = app1.getHttpAdapter().getInstance();

  expressApp2.get('/zhas41', (req, res) => {
    res.json({ message: 'Dynamic module 41' });
  });

not workking.

oak prairie