Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Visitor Counter

A persistent and robust visitor counter for web pages.

Features

  • Persistent storage - Uses SQLite database to persist visitor counts across restarts
  • Atomic operations - Uses database transactions to prevent race conditions
  • Visit logging - Records IP addresses and timestamps for analytics
  • Embeddable badge - SVG badge you can embed in READMEs or other pages
  • Graceful shutdown - Properly closes database connections on shutdown
  • Request logging - Logs all requests with timing information

Quick Start

# Install dependencies
npm install

# Start the server
npm start

# Or run in development mode with auto-reload
npm run dev

The server runs on port 3000 by default. Open http://localhost:3000 to see the counter.

API Endpoints

Endpoint Method Description
/api/visit GET Increment counter and return new value
/api/count GET Get current count without incrementing
/api/count POST Increment counter
/api/stats GET Get visitor statistics
/api/badge GET Get SVG badge image
/health GET Health check endpoint

Configuration

Environment variables:

Variable Default Description
PORT 3000 Server port
COUNTER_NAME default Name of the counter (for multiple counters)
LOG_LEVEL info Logging level (error, warn, info, debug)

Embedding the Badge

Add this to your README or HTML:

<img src="https://your-domain.com/api/badge" alt="Visitors">

Data Storage

Data is stored in data/visitors.db (SQLite). The database uses WAL mode for better concurrent performance.

To backup your data, copy the data/ directory.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages