@radrat-nest/bootstrap
v0.0.14
Published
## Features
Downloads
25
Readme
@radrat-nest/bootstrap
Features
- Auto-configuration of common packages - @radrat-nest/logger, class-transformer, class-validator, cookie-parser, csurf, express-rate-limit, helmet, winston. It fixes https://docs.nestjs.com/recipes/prisma#issues-with-enableshutdownhooks if it detects @radrat-nest/prisma library. You just need to install them and @radrat-nest/bootstrap will detect and integrate them into app with reasonable defaults.
- Unified configuration - loads and validates configuration from dotenv and CLI in unified format and exposes that in staticConfig variable. CLI arguments override
.env
variables. - Fully customizable - via hooks, middleware and providers you can turn off or replace with custom almost any behavior.
Usage
Bootstrapping application
./src/main.ts
import { Config, validationSchema, staticConfig } from './config.schema';
import { AppModule } from './app/app.module';
import { bootstrap } from '@radrat-nest/bootstrap';
void bootstrap<Config>({
module: AppModule,
bootstrap: {
staticConfig,
},
joiValidation: {
schema: validationSchema,
},
}).catch((err: Error) => {
console.error(err);
process.exit(1);
});
Accessing global configuration
import { staticConfig } from './config.schema';
const { config } = staticConfig;