0

I would just like to set up a template engine locally, as my workflow now is rendering the tempalte and having to go to my aws-s3 bucket to see the results.

In the NestJS docs the hace an example using:

import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(
    AppModule,
  );

  app.useStaticAssets(join(__dirname, '..', 'public'));
  app.setBaseViewsDir(join(__dirname, '..', 'views'));
  app.setViewEngine('hbs');

  await app.listen(process.env.PORT ?? 3000);
}
bootstrap();

By creating this instance const app = await NestFactory.create<NestExpressApplication>(AppModule);

But I am using INestApplication and when check the instance none of those methods exist? Isn't NestJS built on top of Express? How would you use templates locally so I can do logs in my templates etc, so I don't have to go to my aws-bucket after every save.

Thanks!

4
  • Can you explain the question in more robust way, as i cannot even comprehend what you want to know? Commented Oct 31, 2024 at 21:13
  • @Seti I think my question should be how do you use the expressAdapter in a INestApplication app. Commented Oct 31, 2024 at 21:31
  • returned app being INestApplication is already connected with expressAdapter, i mean - app.use will be directly using .use from express and so on. Commented Oct 31, 2024 at 21:36
  • 1
    But thats because you used .create<NestExpressApplication> which tells nest to use express underneath. If you want to use some direct methods from express, you can use (app as NestExpressApplication) [example: (app as NestExpressApplication).disable('x-powered-by)` that disables express ,,x-powered-by'' header for responses. Commented Oct 31, 2024 at 21:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.