Socket
Socket
Sign inDemoInstall

@mgcrea/fastify-request-logger

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mgcrea/fastify-request-logger - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

dist/index.d.ts

@@ -6,3 +6,3 @@ import * as fastify from 'fastify';

logBody?: boolean;
logDuration?: boolean;
logResponseTime?: boolean;
logBindings?: Record<string, unknown>;

@@ -9,0 +9,0 @@ ignoredPaths?: Array<string | RegExp>;

@@ -5,7 +5,9 @@ // src/index.ts

// src/plugin.ts
import chalk from "chalk";
var plugin = async (fastify, options = {}) => {
import * as color from "kolorist";
var plugin = async (fastify, options2 = {}) => {
const supportsArt = false;
const icons = { req: supportsArt ? "\u2190" : "<", res: supportsArt ? "\u2192" : ">" };
const {
logBody = true,
logDuration = true,
logResponseTime = true,
logBindings = { plugin: "fastify-request-logger" },

@@ -15,3 +17,3 @@ ignoredPaths = [],

ignoredBindings
} = options;
} = options2;
const isIgnoredRequest = (request) => {

@@ -42,5 +44,5 @@ const { routerPath } = request;

logBindings,
`${chalk.bold.yellow("\u2190")}${chalk.yellow(request.method)}:${chalk.green(
`${color.bold(color.yellow(icons.req))}${color.yellow(request.method)}:${color.green(
request.url
)} request from ip ${chalk.blue(request.ip)}${contentLength ? ` with a ${chalk.yellow(contentLength)}-length body` : ""}`
)} request from ip ${color.blue(request.ip)}${contentLength ? ` with a ${color.yellow(contentLength)}-length body` : ""}`
);

@@ -63,5 +65,5 @@ request.log.trace({ ...logBindings, req: request }, `Request trace`);

logBindings,
`${chalk.bold.yellow("\u2192")}${chalk.yellow(request.method)}:${chalk.green(
`${color.bold(color.yellow(icons.res))}${color.yellow(request.method)}:${color.green(
request.url
)} response with a ${chalk.magenta(reply.statusCode)}-status${logDuration ? ` took ${chalk.magenta(reply.getResponseTime().toFixed(3))}ms` : ""}`
)} response with a ${color.magenta(reply.statusCode)}-status${logResponseTime ? ` took ${color.magenta(reply.getResponseTime().toFixed(3))}ms` : ""}`
);

@@ -68,0 +70,0 @@ });

{
"name": "@mgcrea/fastify-request-logger",
"version": "1.0.0",
"version": "1.1.0",
"description": "Compact request logger plugin for fastify written in TypeScript",

@@ -25,8 +25,8 @@ "author": "Olivier Louvignes <olivier@mgcrea.io>",

"start": "npm run spec -- --watch",
"build": "tsup src/index.ts --format cjs,esm --sourcemap --dts --clean",
"build": "rimraf dist/*; tsup src/index.ts --format cjs,esm --sourcemap --dts",
"lint": "eslint src/ test/",
"prettycheck": "prettier --check src/ test/",
"prettyfix": "prettier --write src/ test/",
"prettify": "prettier --write src/ test/",
"typecheck": "tsc --noEmit",
"spec": "DEBUG=fastify-session*,prisma-query jest --runInBand",
"spec": "rimraf node_modules/.vitest; vitest --run --no-threads --no-isolate",
"test": "npm run lint && npm run prettycheck && npm run typecheck && npm run spec",

@@ -42,3 +42,2 @@ "prepublishOnly": "npm run build"

"@tsconfig/node-lts-strictest-esm": "^18.12.1",
"@types/jest": "^29.2.5",
"@types/node": "^18.11.18",

@@ -52,14 +51,15 @@ "@typescript-eslint/eslint-plugin": "^5.48.1",

"fastify": "^4.11.0",
"jest": "^29.3.1",
"pino": "^8.8.0",
"pino-pretty": "^9.1.1",
"prettier": "^2.8.2",
"ts-jest": "^29.0.3",
"prettier-plugin-organize-imports": "^3.2.1",
"rimraf": "^3.0.2",
"tsup": "^6.5.0",
"typescript": "^4.9.4"
"typescript": "^4.9.4",
"vitest": "^0.27.0"
},
"dependencies": {
"chalk": "^4",
"fastify-plugin": "^4.4.0"
"fastify-plugin": "^4.4.0",
"kolorist": "^1.6.0"
}
}
# FastifyRequestLogger
[![npm version](https://img.shields.io/npm/v/@mgcrea/fastify-request-logger.svg)](https://github.com/mgcrea/fastify-request-logger/releases)
[![license](https://img.shields.io/npm/l/@mgcrea/fastify-request-logger)](https://tldrlegal.com/license/mit-license)
[![build status](https://img.shields.io/github/actions/workflow/status/mgcrea/fastify-request-logger/main.yml?branch=master)](https://github.com/mgcrea/fastify-request-logger/actions)
[![dependencies status](https://img.shields.io/depfu/dependencies/github/mgcrea/fastify-request-logger)](https://depfu.com/github/mgcrea/fastify-request-logger)
<!-- markdownlint-disable MD033 -->
<p align="center">
<a href="https://www.npmjs.com/package/@mgcrea/fastify-request-logger">
<img src="https://img.shields.io/npm/v/@mgcrea/fastify-request-logger.svg?style=for-the-badge" alt="npm version" />
</a>
<a href="https://www.npmjs.com/package/@mgcrea/fastify-request-logger">
<img src="https://img.shields.io/npm/dt/@mgcrea/fastify-request-logger.svg?style=for-the-badge" alt="npm total downloads" />
</a>
<a href="https://www.npmjs.com/package/@mgcrea/fastify-request-logger">
<img src="https://img.shields.io/npm/dm/@mgcrea/fastify-request-logger.svg?style=for-the-badge" alt="npm monthly downloads" />
</a>
<a href="https://www.npmjs.com/package/@mgcrea/fastify-request-logger">
<img src="https://img.shields.io/npm/l/@mgcrea/fastify-request-logger.svg?style=for-the-badge" alt="npm license" />
</a>
<br />
<a href="https://github.com/mgcrea/fastify-request-logger/actions/workflows/main.yml">
<img src="https://img.shields.io/github/actions/workflow/status/mgcrea/fastify-request-logger/main.yml?style=for-the-badge&branch=master" alt="build status" />
</a>
<a href="https://depfu.com/github/mgcrea/fastify-request-logger">
<img src="https://img.shields.io/depfu/dependencies/github/mgcrea/fastify-request-logger?style=for-the-badge" alt="dependencies status" />
</a>
</p>
<!-- markdownlint-enable MD037 -->
## Features
Compact request logger plugin for [fastify](https://github.com/fastify/fastify).

@@ -34,5 +55,5 @@

```ts
import createFastify, { FastifyInstance, FastifyServerOptions } from 'fastify';
import fastifyRequestLogger from '@mgcrea/fastify-request-logger';
import prettifier from '@mgcrea/pino-pretty-compact';
import createFastify, { FastifyInstance, FastifyServerOptions } from "fastify";
import fastifyRequestLogger from "@mgcrea/fastify-request-logger";
import prettifier from "@mgcrea/pino-pretty-compact";

@@ -42,6 +63,6 @@ export const buildFastify = (options: FastifyServerOptions = {}): FastifyInstance => {

logger: {
level: 'debug',
level: "debug",
transport: {
target: '@mgcrea/pino-pretty-compact',
options: { translateTime: 'HH:MM:ss Z', ignore: 'pid,hostname' },
target: "@mgcrea/pino-pretty-compact",
options: { translateTime: "HH:MM:ss Z", ignore: "pid,hostname" },
},

@@ -48,0 +69,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc