Skip to content

kerolloz/kounter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kounter 🧮 fastify Railway

Kounter is a simple counter service that can be used in a variety of ways.
Use cases include a profile views counter, repository visits counter, or just anything you want to count.

Docs

You need to set DETA_PROJECT_KEY environment variable to your Deta project key.

Kounter is built using Fastify.
It has a starightforward API with the following few endpoints.

Endpoints

Base URL: https://kounter.kerolloz.dev

GET /

Redirects to this repository.


GET /badge/:key

  • Increments the counter by 1 if :key exits; creates a new counter with count initialized to 1 otherwise.
  • Returns a shields.io badge (SVG image) for your counter.
Parameters
  • key - The key of the counter to increment.
Query Parameters
  • silent - Set to true to disable incrementing the counter. Defaults to false.
  • style - Set the style of the badge. Can be one of flat, flat-square, for-the-badge, or plastic. Defaults to flat.
  • label - Set the left-hand-side text. Defaults to :key.
  • color - Set background of the right part (hex, rgb, rgba, hsl, hsla and css named colors supported). Defaults to brightgreen.
  • labelColor - Set background of the left part (hex, rgb, rgba, hsl, hsla and css named colors supported). Defaults to grey.
  • cntPrefix - Set prefix to display before the counter value. Defaults to "" empty string.
  • cntSuffix - Set suffix to display after the counter value. Defaults to "" empty string.
Examples

![badge](https://kounter.kerolloz.dev/badge/kerolloz.kounter)
badge

![badge](https://kounter.kerolloz.dev/badge/kerolloz.kounter?style=flat-square&color=blue&silent=true)
badge

![badge](https://kounter.kerolloz.dev/badge/kerolloz.kounter?label=kerolloz/kounter&labelColor=white&cntPrefix=visits%20&silent=true)
badge

![badge](https://kounter.kerolloz.dev/badge/kerolloz.kounter?label=&color=333&style=for-the-badge&cntSuffix=%20Views&silent=true)
badge


GET /count/:key

Try it
  • Returns the current count for :key without incrementing it.
  • Returns { key: ":key", count: 0 } if the counter :key does not exist.
Parameters
  • key - The key of the counter to get count value for.
Example
$ curl -X GET https://kounter.kerolloz.dev/count/xyz

{
  "count": 1,
  "key": "xyz"
}