Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kikobeats/count
counting things, as microservice
https://github.com/kikobeats/count
analytics microservice pageviews self-hosted
Last synced: about 1 month ago
JSON representation
counting things, as microservice
- Host: GitHub
- URL: https://github.com/kikobeats/count
- Owner: Kikobeats
- License: mit
- Created: 2019-07-28T09:58:20.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-08T08:44:51.000Z (about 2 months ago)
- Last Synced: 2024-12-24T17:50:59.626Z (about 1 month ago)
- Topics: analytics, microservice, pageviews, self-hosted
- Language: JavaScript
- Homepage: https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FKikobeats%2Fcount
- Size: 790 KB
- Stars: 34
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
A simple microservice for counting things.
# Usage
You can count whatever you want. It's inspired by [antirez.com](http://antirez.com) and [rauchg.com](https://rauchg.com/).
For seeing your counters, just perform a `GET` to `/:collection/:key`:
```
curl https://count.kikobeats.com/pageviews/culture-shipping
// => "204"
```You can also getting counters in a bulk using a comma as separator:
```
curl https://count.kikobeats.com/pageviews/culture-shipping,professional-career
// => "204,98"
```If you want to increment a counter, pass `incr` query parameter:
```
curl https://count.kikobeats.com/pageviews/culture-shipping?incr
// => "205"
```It doesn't matter if your `id` contains final slash; it will be sanitized.
For printing the value in your website, a representative code for doing that could be:
```html
fetch(`'https://count.kikobeats.com/pageviews/${window.location.pathname}?incr`)
.then(res => res.json())
.then(count => {
document.querySelector('.pageviews-container').classList.remove('display-none')
document.querySelector('.pageviews-count').textContent = count
})```
# Environment Variables
## Authentication
### DOMAINS
*Required*
Type: `string`|`string[]`The list of allowed domains authorized to consume your Microlink API credentials.
Note domains should be provided in the [URL.origin](https://developer.mozilla.org/en-US/docs/Web/API/URL/origin) format (e.g., `'https://example.com'`).
## Database
The service is backed at [Upstash](https://upstash.com).
You need to create an account (it's free!) and copy some relevant values specified below.
### UPSTASH_REDIS_REST_URL
Type: `string`
Your Upstash database URL to use.
### UPSTASH_REDIS_REST_TOKEN
Type: `string`
Your Upstash token authentication-
## License
**count** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/count/blob/master/LICENSE.md) License.
Authored and maintained by Kiko Beats with help from [contributors](https://github.com/Kikobeats/count/contributors).> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) · X [@Kikobeats](https://x.com/Kikobeats)