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

anyok

v1.1.1

Published

HTTP service that accepts any request and responds with 'ok' while logging requests with pretty formatting

Downloads

19

Readme

http-anyok

HTTP service that accepts any request and responds with customizable messages while logging requests with pretty formatting.

Features

  • ✅ Accepts any HTTP method (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD)
  • ✅ Customizable response messages (text or JSON)
  • ✅ Default "ok" response when no custom response is set
  • ✅ Pretty formatted request logging to console
  • Real-time statistics web interface with request monitoring
  • Advanced filtering with regex support and exclude functionality
  • Server-Sent Events for live request updates
  • ✅ Configurable server port and timeout
  • ✅ CORS enabled for cross-origin requests
  • ✅ Graceful shutdown handling
  • ✅ Clean, modular architecture
  • ✅ Comprehensive test coverage
  • ✅ TypeScript definitions included

Installation

Global Installation

npm install -g http-anyok

Local Installation

npm install http-anyok

Usage

Command Line Interface

# Start server on default port (3000)
http-anyok

# Start server on specific port
http-anyok --port 8080
http-anyok -p 8080

# Start server with custom text response
http-anyok --response "Hello World"
http-anyok -r "Custom message"

# Start server with JSON response
http-anyok --responseJson '{"status":"success","message":"API is running"}'

# Combine options
http-anyok --port 8080 --response "Server running on port 8080"
http-anyok -p 3001 --responseJson '{"port":3001,"status":"online"}'

# Set request timeout (in seconds)
http-anyok --timeout 30
http-anyok -t 30

# Enable statistics server (default port 9989)
http-anyok --stats

# Enable statistics server with custom port
http-anyok --stats --stats-port 8081

# Combine with other options
http-anyok --port 3000 --stats --stats-port 9989 --response "API Server"

# Show help
http-anyok --help

Programmatic Usage

import { ServerController, StatisticsServer } from 'http-anyok';

// Create and start server with default response
const server = new ServerController(3000);
server.start();

// Create server with custom text response
const serverWithText = new ServerController(3000, 0, null, 'Hello from API');
serverWithText.start();

// Create server with JSON response
const jsonResponse = '{"status":"success","message":"API ready"}';
const serverWithJson = new ServerController(3000, 0, jsonResponse, null);
serverWithJson.start();

// Create server with statistics monitoring
const statsServer = new StatisticsServer(9989);
statsServer.start();

const serverWithStats = new ServerController(3000, 0, null, null, statsServer);
serverWithStats.start();

// Graceful shutdown
process.on('SIGINT', () => {
  server.shutdown();
  statsServer?.stop();
});

API

ServerController

Main server class that handles HTTP requests.

import { ServerController } from 'http-anyok';

// Constructor parameters:
// ServerController(port, timeout, responseJson, response)
const server = new ServerController(3000, 30, null, 'Custom response');
server.start();

Parameters:

  • port (number, default: 3000) - Server port
  • timeout (number, default: 0) - Request timeout in seconds
  • responseJson (string, default: null) - JSON string to parse and send as JSON response
  • response (string, default: null) - Plain text response message
  • statisticsServer (StatisticsServer, default: null) - Optional statistics server instance for request monitoring

StatisticsServer

Statistics server for monitoring HTTP requests with web interface.

import { StatisticsServer } from 'http-anyok';

// Constructor parameters:
// StatisticsServer(port)
const statsServer = new StatisticsServer(9989);
statsServer.start();

Parameters:

  • port (number, default: 9989) - Statistics server port

RequestModel

Data model for HTTP requests used in logging.

import { RequestModel } from 'http-anyok';

// Automatically created from incoming requests
const requestModel = new RequestModel(req);
console.log(requestModel.toJSON());

Logger

Pretty request logger with colored output.

import { Logger } from 'http-anyok';

const logger = new Logger();
logger.logRequest(requestModel);
logger.logServerStart(port, responseJson, response);

Server Startup

The server displays a colorful startup message showing configuration:

✓ HTTP AnyOK Server Started
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Port:     3000
URL:      http://localhost:3000
Status:   Accepting all requests
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Stats:    Enabled
Stats Port: 9989
Stats URL:  http://localhost:9989
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Response: JSON {"status":"success","message":"API ready"}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Press Ctrl+C to stop the server

Request Logging

All requests are logged with pretty formatting including:

  • Request timestamp
  • HTTP method (color-coded)
  • Request URL
  • User Agent
  • Remote IP address
  • Content type and length
  • Important headers (authorization, cookies, etc.)

Example log output:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Request #1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Time:     2024-01-15T10:30:45.123Z
Method:   GET
URL:      /api/test
From:     127.0.0.1
Agent:    Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
Content:  application/json (150 bytes)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Response Customization

Command Line Options

| Option | Short | Description | Example | | ---------------- | ----- | ------------------------- | ---------------------------------- | | --response | -r | Plain text response | --response "Hello World" | | --responseJson | | JSON response (parsed) | --responseJson '{"status":"ok"}' | | --port | -p | Server port | --port 8080 | | --timeout | -t | Request timeout (seconds) | --timeout 30 | | --stats | | Enable statistics server | --stats | | --stats-port | | Statistics server port | --stats-port 9989 |

Response Priority

  1. JSON Response: If --responseJson is provided, it takes priority
  2. Text Response: If --response is provided (and no JSON), uses text
  3. Default: If neither is provided, responds with "ok"

Statistics Server

When enabled with --stats, the statistics server provides a real-time web interface to monitor HTTP requests.

Features

  • Real-time Request Monitoring: See requests as they arrive via Server-Sent Events
  • Request Details: View headers, body, response time, and metadata
  • Advanced Filtering: Filter by path, HTTP method with regex and exclude support
  • Collapsible Interface: Click to expand/collapse request details
  • Live Statistics: Total requests, average response time, last request time

Usage

# Enable statistics server
http-anyok --stats

# Statistics will be available at http://localhost:9989

Filter Examples

Basic Filtering:

  • Path: /api - Show only requests containing "/api"
  • Method: GET - Show only GET requests

Regex Filtering:

  • Enable "Regex" checkbox and use patterns like:
    • ^/api/.* - All URLs starting with /api/
    • /users/\d+$ - User URLs with numeric IDs
    • \.(css|js|png)$ - Static files
    • /v[1-3]/.* - API versions 1, 2, or 3

Exclude Filtering:

  • Enable "Exclude" checkbox to hide matching requests:
    • Exclude path /health - Hide health check requests
    • Exclude method OPTIONS - Hide preflight requests

Combined Filtering:

  • Path: /api + Method: POST - Only API POST requests
  • Regex: ^/api/.* + Exclude method: GET - API requests except GET
  • Exclude path: /static + Exclude method: OPTIONS - Hide static files and preflight

Development

Setup

git clone <repository-url>
cd http-anyok
npm install

Testing

npm test
npm run test:watch
npm run test:coverage

Linting

npm run lint

Development Mode

npm run dev

License

MIT

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request