Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Kikobeats/count

counting things, as microservice
https://github.com/Kikobeats/count

analytics microservice pageviews self-hosted

Last synced: 3 months ago
JSON representation

counting things, as microservice

Awesome Lists containing this project

README

        





A simple microservice for counting things.




Deploy with Vercel





# 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) · Twitter [@Kikobeats](https://twitter.com/Kikobeats)