https://github.com/choewy/nestjs-bootstrap
NestJS Bootstrap
https://github.com/choewy/nestjs-bootstrap
bootstrap nestjs
Last synced: 7 days ago
JSON representation
NestJS Bootstrap
- Host: GitHub
- URL: https://github.com/choewy/nestjs-bootstrap
- Owner: choewy
- License: mit
- Created: 2024-03-20T09:55:06.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-28T11:44:49.000Z (over 2 years ago)
- Last Synced: 2025-08-24T23:38:02.016Z (10 months ago)
- Topics: bootstrap, nestjs
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@choewy/nestjs-bootstrap
- Size: 755 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NestJS Bootstrap
## Installing
```bash
npm i @choewy/nestjs-bootstrap
```
## Uses
### createBootstrapOptions
```ts
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
```ts
@Module({
controllers: [AppController],
providers: [AppService],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(HttpLogMiddleware).forRoutes('*');
}
}
```
#### Functional middleware
```ts
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use(HttpLogMiddleware.use);
await app.listen(3000);
}
```
### HttpLogInterceptor
```ts
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use(HttpLogMiddleware.use);
app.useGlobalInterceptors(new HttpLoggingInterceptor());
await app.listen(3000);
}
```