@choewy/nestjs-bootstrap
TypeScript icon, indicating that this package has built-in type declarations

0.0.14 • Public • Published

NestJS Bootstrap

Installing

npm i @choewy/nestjs-bootstrap

Uses

createBootstrapOptions

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const bootstrapOptions = createBootstrapOptions(app);

  app.useGlobalInterceptors(...bootstrapOptions.interceptors);
  app.useGlobalPipes(...bootstrapOptions.pipes);

  await app.listen(3000);
}

bootstrap();

HttpLogMiddleware

Applying middleware

@Module({
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(HttpLogMiddleware).forRoutes('*');
  }
}

Functional middleware

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.use(HttpLogMiddleware.use);

  await app.listen(3000);
}

HttpLogInterceptor

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.use(HttpLogMiddleware.use);
  app.useGlobalInterceptors(new HttpLoggingInterceptor());

  await app.listen(3000);
}

Package Sidebar

Install

npm i @choewy/nestjs-bootstrap

Weekly Downloads

5

Version

0.0.14

License

MIT

Unpacked Size

22.8 kB

Total Files

32

Last publish

Collaborators

  • choewy