Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@minddoc/nest-express-winston
Advanced tools
Implementation of a nestjs logger using winston and express-winston
Implementation of a NestJS logger using winston
and express-winston
. It replaces the default
NestJS logger with winston
, and optionally also adds express logs using express-winston
.
yarn add @minddoc/nest-express-winston
import {
createExpressWinstonHandler,
createNestWinstonLogger,
httpContextMiddleware,
requestIdHandler,
} from '@minddoc/nest-express-winston';
Add the following to your index.ts
/ main.ts
:
import 'dotenv/config';
import 'module-alias/register';
import 'reflect-metadata';
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import {
createExpressWinstonHandler,
createNestWinstonLogger,
httpContextMiddleware,
requestIdHandler,
} from '@minddoc/nest-express-winston';
import { AppModule } from './app.module';
import { EnvService } from './env';
async function bootstrap() {
const nestWinstonLogger = createNestWinstonLogger('app');
const app = await NestFactory.create(AppModule, { logger: nestWinstonLogger });
// Use express-winston for logging request information
const expressWinstonHandler = createExpressWinstonHandler(nestWinstonLogger.logger);
app.use(expressWinstonHandler);
// Use express-http-context for context injection (request id)
app.use(httpContextMiddleware);
app.use(requestIdHandler);
app.useGlobalPipes(new ValidationPipe());
app.setGlobalPrefix(EnvService.get().API_BASE_PATH);
const options = new DocumentBuilder()
.setTitle('API')
.setDescription('Logging API Example')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
await app.listen(EnvService.get().API_PORT, EnvService.get().API_HOST);
}
bootstrap();
Never commit directly to master, create a new branch and submit a pull request.
FAQs
Implementation of a nestjs logger using winston and express-winston
We found that @minddoc/nest-express-winston demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.