npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sylphx/cat-http

v0.1.0

Published

HTTP request/response serializers for @sylphx/cat logger

Downloads

4

Readme

@sylphx/cat-http

HTTP request/response serializers for @sylphx/cat logger

npm version License: MIT

0.75 KBExpress/Fastify compatibleAutomatic header redaction

Installation

npm install @sylphx/cat @sylphx/cat-http

Description

Provides standardized serializers for HTTP requests and responses in @sylphx/cat. Automatically extracts relevant information from request/response objects while redacting sensitive headers (authorization, cookies, API keys). Compatible with Express, Fastify, Koa, Next.js, and standard Node.js HTTP objects.

Usage Examples

Express Middleware

import { createLogger } from '@sylphx/cat'
import { httpSerializers } from '@sylphx/cat-http'
import express from 'express'

const logger = createLogger({
  serializers: httpSerializers
})

const app = express()

app.use((req, res, next) => {
  logger.info({ req }, 'Incoming request')
  next()
})

app.get('/users/:id', (req, res) => {
  res.json({ id: req.params.id })
  logger.info({ req, res }, 'Request completed')
})

Output:

{
  "level": "info",
  "message": "Incoming request",
  "req": {
    "method": "GET",
    "url": "/users/123",
    "headers": { "user-agent": "...", "authorization": "[REDACTED]" },
    "params": { "id": "123" },
    "remoteAddress": "::1"
  }
}

Standalone Request Serialization

import { createLogger } from '@sylphx/cat'
import { requestSerializer, responseSerializer } from '@sylphx/cat-http'

const logger = createLogger({
  serializers: {
    req: requestSerializer,
    res: responseSerializer
  }
})

// In your HTTP handler
logger.info({ req, res }, 'HTTP request processed')

Next.js API Route

import { createLogger } from '@sylphx/cat'
import { httpSerializers } from '@sylphx/cat-http'
import type { NextApiRequest, NextApiResponse } from 'next'

const logger = createLogger({
  serializers: httpSerializers
})

export default function handler(req: NextApiRequest, res: NextApiResponse) {
  logger.info({ req }, 'API request received')

  res.status(200).json({ message: 'Success' })

  logger.info({ req, res }, 'API request completed')
}

API Reference

httpSerializers

Combined serializers object containing both request and response serializers.

import { httpSerializers } from '@sylphx/cat-http'

const logger = createLogger({
  serializers: httpSerializers
})

Includes:

  • req - Request serializer
  • request - Alias for req
  • res - Response serializer
  • response - Alias for res

requestSerializer(req: any): SerializedRequest

Serializes HTTP request objects.

Extracts:

  • method - HTTP method (GET, POST, etc.)
  • url - Request URL
  • headers - HTTP headers (sensitive headers redacted)
  • query - Query parameters (if available)
  • params - Route parameters (if available)
  • remoteAddress - Client IP address
  • remotePort - Client port
  • protocol - HTTP/HTTPS
  • httpVersion - HTTP version

Sensitive headers redacted:

  • authorization
  • cookie
  • x-api-key
  • x-auth-token
  • x-csrf-token
  • x-session-id

responseSerializer(res: any): SerializedResponse

Serializes HTTP response objects.

Extracts:

  • statusCode - HTTP status code
  • statusMessage - Status message
  • headers - Response headers (sensitive headers redacted)

Sensitive headers redacted:

  • set-cookie
  • authorization
  • x-api-key

Framework Compatibility

Express

app.use((req, res, next) => {
  logger.info({ req }, 'Request received')
  res.on('finish', () => {
    logger.info({ req, res }, 'Request completed')
  })
  next()
})

Fastify

fastify.addHook('onRequest', (request, reply, done) => {
  logger.info({ req: request.raw }, 'Request received')
  done()
})

Koa

app.use(async (ctx, next) => {
  logger.info({ req: ctx.request }, 'Request received')
  await next()
  logger.info({ req: ctx.request, res: ctx.response }, 'Request completed')
})

Node.js HTTP

import { createServer } from 'http'

const server = createServer((req, res) => {
  logger.info({ req }, 'Request received')
  res.writeHead(200)
  res.end('Hello')
  logger.info({ req, res }, 'Request completed')
})

Package Size

  • Minified: ~2.2 KB
  • Minified + Gzipped: 0.75 KB
  • No additional dependencies

Links

Related Packages

License

MIT © Kyle Zhu