A Cloudflare Workers script to display last.fm most recently played track in a shields.io compatible endpoint.json schema.
├──── 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
I use this service for my profile at github.com. Currently, the service is hosted on a free tier of Cloudflare Workers and limited at 100K requests per day. Make sure to make the appropriate changes in wrangler.toml first.
In order to run the project locally you need node>=14
and npm>=6
.
Make sure you have the latest version of wrangler
as described in the wrangler docs.
npm uninstall -g @cloudflare/wrangler &&
npm install -g @cloudflare/wrangler
cargo install wrangler --force
Make sure you have a valid deployment token by doing:
wrangler login
or:
wrangler config
Create a new GitHub repository with the green button or clone:
# with git
git clone https://github.com/0-vortex/workers-lastfm-shields.git
or with github-cli:
# with github-cli
gh repo clone 0-vortex/workers-lastfm-shields
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.
- Steps for creating a secret is available at developers.cloudflare.com.
To develop locally just run:
npm start
To deploy to dev
just run:
npm run deploy
To monitor any of the deployed environments run:
wrangler tail
Without modifying the worker it should look like this:
![](http://img.shields.io/endpoint?url=https://workers.vortex.name/lastfm/endpoint.json)
Additional query parameters can be appliedas follows.
![](http://img.shields.io/endpoint?url=https://workers.vortex.name/lastfm/endpoint.json&style=flat)
![](http://img.shields.io/endpoint?url=https://workers.vortex.name/lastfm/endpoint.json&color=green)
![](http://img.shields.io/endpoint?url=https://workers.vortex.name/lastfm/endpoint.json&label=Recently%20Played)
![](http://img.shields.io/endpoint?url=https://workers.vortex.name/lastfm/endpoint.json&logoColor=green)
This library is released under BSD-3 license clause.