https://github.com/0-vortex/cf-workers-lastfm-shields
Generate last.fm most recently played shields endpoint configuration with Cloudflare Workers in 200+ edge locations.
https://github.com/0-vortex/cf-workers-lastfm-shields
badges badges-markdown cloudflare cloudflare-workers github lastfm lastfm-api markdown markdown-badges readme shieldsio shieldsio-endpoint
Last synced: 10 months ago
JSON representation
Generate last.fm most recently played shields endpoint configuration with Cloudflare Workers in 200+ edge locations.
- Host: GitHub
- URL: https://github.com/0-vortex/cf-workers-lastfm-shields
- Owner: 0-vortex
- License: bsd-3-clause
- Created: 2020-11-23T05:28:19.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-03T02:23:56.000Z (over 5 years ago)
- Last Synced: 2025-03-27T12:39:12.158Z (about 1 year ago)
- Topics: badges, badges-markdown, cloudflare, cloudflare-workers, github, lastfm, lastfm-api, markdown, markdown-badges, readme, shieldsio, shieldsio-endpoint
- Language: JavaScript
- Homepage: https://workers.vortex.name/lastfm/endpoint.json
- Size: 104 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# workers-lastfm-shields
[](https://github.com/0-vortex/workers-lastfm-shields/actions?query=workflow%3A%22Deploy+to+CF+Workers%22)
[](https://app.fossa.com/projects/git%2Bgithub.com%2F0-vortex%2Fworkers-lastfm-shields?ref=badge_shield)
[](http://commitizen.github.io/cz-cli/)
[](./LICENSE)
[](https://codeclimate.com/github/0-vortex/workers-lastfm-shields/maintainability)
[](https://depfu.com/github/0-vortex/workers-lastfm-shields?project_id=17814)
[](https://snyk.io/test/github/0-vortex/workers-lastfm-shields?targetFile=package.json)
## Overview
A Cloudflare Workers script to display [last.fm](https://www.last.fm/user/zero-vortex) most recently played track in a [shields.io](https://shields.io/endpoint) compatible [endpoint.json](https://workers.vortex.name/lastfm/endpoint.json) schema.
## Folder structure
```
├──── workers-lastfm-shields
│ ├── .github/
│ ├── src/
│ ├── static/
│ ├── .editorconfig
│ ├── .eslintrc.js
│ ├── .gitattributes
│ ├── .gitignore
│ ├── .lintstagedrc.js
│ ├── .npmrc
│ ├── CODE_OF_CONDUCT.md
│ ├── LICENSE
│ ├── npm-shrinkwrap.json
│ ├── package.json
│ ├── README.md
│ └── wrangler.toml
```
## Deploy as Cloudflare Worker
I use this service for my profile at [github.com](https://github.com/0-vortex). Currently, the service is hosted on a free tier of [Cloudflare Workers](https://workers.cloudflare.com/) and limited at 100K requests per day.
Make sure to make the appropriate changes in [wrangler.toml](./wrangler.toml) first.
[](https://deploy.workers.cloudflare.com/?url=https://github.com/abskmj/badges-lastfm)
## Requirements
In order to run the project locally you need ``node>=14`` and ``npm>=6``.
### Install ``@cloudflare/wrangler``
Make sure you have the latest version of ``wrangler`` as described in [the wrangler docs](https://developers.cloudflare.com/workers/cli-wrangler/install-update).
#### Updating Wrangler with NPM:
```shell
npm uninstall -g @cloudflare/wrangler &&
npm install -g @cloudflare/wrangler
```
#### Install with cargo
```shell
cargo install wrangler --force
```
### Get a valid ``CF_API_TOKEN``
Make sure you have a valid deployment token by doing:
```shell
wrangler login
```
or:
```shell
wrangler config
```
### Generate a new repository
Create a new GitHub repository with the green button or clone:
```shell
# with git
git clone https://github.com/0-vortex/workers-lastfm-shields.git
```
or with [github-cli](https://cli.github.com):
```shell
# with github-cli
gh repo clone 0-vortex/workers-lastfm-shields
```
### Get a LastFM ``API_KEY``
Create a secret ``API_KEY`` for the Cloudflare Worker to use the LastFM APIs.
- Steps for getting an API key is available at [last.fm](https://www.last.fm/api/account/create).
- Steps for creating a secret is available at [developers.cloudflare.com](https://developers.cloudflare.com/workers/platform/environments#environment-variables).
## Usage
### Local development
To develop locally just run:
```shell
npm start
```
To deploy to ``dev`` just run:
```shell
npm run deploy
```
### Monitoring
To monitor any of the deployed environments run:
```shell
wrangler tail
```
### Customised markdown badges
Without modifying [the worker](./src/index.js) it should look like this:
```markdown

```

Additional query parameters can be appliedas follows.
#### Style
```markdown

```

#### Color
```markdown

```

#### Label
```markdown

```

#### Logo color
```markdown

```

## License
This library is released under BSD-3 license clause.
[](https://app.fossa.com/projects/git%2Bgithub.com%2F0-vortex%2Fworkers-lastfm-shields?ref=badge_large)