JSPM

  • Created
  • Published
  • Downloads 38
  • Score
    100M100P100Q53221F
  • License AGPL-3.0-only

✚ Easily persist your own Page View Counter completely for free (no VPS or database plans required).

Package Exports

  • countty
  • countty/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (countty) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Countty ✚

Easily persist your own Page View Counter completely for free.


  • Based on Durable Objects and ready for use via Cloudflare Workers ⛅️
  • No VPS or Database plans required ✨

WIP 🚧


Quick Test Locally

npm i countty

Worker

  • index.js
import { createCountty } from 'countty';

const { worker, Countty } = createCountty();

export default worker;

export { Countty };
  • wrangler.json
{
  "main": "index.js",
  "compatibility_date": "2025-09-24",
  "compatibility_flags": ["nodejs_compat"],
  "durable_objects": {
    "bindings": [
      {
        "name": "countty",
        "class_name": "Countty"
      }
    ]
  },
  "migrations": [
    {
      "tag": "v1",
      "new_sqlite_classes": ["Countty"]
    }
  ]
}

Then, run:

npx -y wrangler dev

API

  • localhost:8787/create
fetch('http://localhost:8787/create?slug=test', {
  headers: {
    Authorization: 'Bearer 123456',
  },
})
  .then((res) => res.json())
  .then(console.log);
  • localhost:8787/views
fetch('http://localhost:8787/views?slug=test')
  .then((res) => res.json())
  .then(console.log);
  • localhost:8787/backup
fetch('http://localhost:8787/backup', {
  headers: {
    Authorization: 'Bearer 123456',
  },
})
  .then((res) => res.text())
  .then(console.log);

Production Usage

Create your worker

npx wrangler deploy

Personal Token

🔐 To use in production, please modify your personal token:

npx wrangler secret put TOKEN # Then press `Enter` to insert your token