Skip to content

๐Ÿ‘€ Views counter with badge maker. Nothing more, nothing less.

License

Notifications You must be signed in to change notification settings

somespecialone/views-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Views Counter

Views Made in Ukraine license Deploy Test codecov CodeFactor code style: prettier


Deta micro app that counts page hits(views). Can generate badge or json response with counter.

Badge need to be generated each time when page with link is loaded, so caching is omitted. Due to this, app NOT USE redirects to badgen.net, but instead create badge by herself.

โšก Single deta micro may have rate-limit, so if You want to heavily use counter, please, deploy it to Deta Space by yourself. โšก

Usage

Badge endpoint

url /:key/badge?label=...&labelColor=...&color=...&style =...&noIncrement=...

Param name Description Default value
key Required Unique key for this counter. Path param. -
label Optional badgen "views"
labelColor Optional badgen "#555"
color Optional badgen "blue"
style Optional badgen "classic"
icon Optional badgen -
iconWidth Optional badgen 13
scale Optional badgen 1
gradient Optional gradient-badge -
noIncrement Optional To not increment counter. false

JSON endpoint

url /:key?noIncrement=...

Have only two params: key and noIncrement.

Response:

{
  "counter": 123
}

Fetch counter

โš  noIncrement may be needed when You just want to fetch counter without incrementing it, so You can implement logic on front-end of your app to catch only unique visitors.

Testing ๐Ÿงช

  • NITRO_DETA_PROJECT_KEY/DETA_PROJECT_KEY - Your project from Deta web settings.
  • NITRO_DETA_BASE_NAME - Optional. Name of Deta Base.
  • NITRO_ALLOW_ORIGIN - Optional. Default *.

TODO ๐Ÿ“‘