Skip to content

0-vortex/cf-workers-lastfm-shields

workers-lastfm-shields

Deploy to CF Workers FOSSA Status

Commitizen Friendly License

Maintainability Depfu Known Vulnerabilities

Overview

A Cloudflare Workers script to display last.fm most recently played track in a shields.io compatible 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. 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.

Deploy to Cloudflare Workers

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.

Updating Wrangler with NPM:

npm uninstall -g @cloudflare/wrangler && 
  npm install -g @cloudflare/wrangler 

Install with cargo

cargo install wrangler --force

Get a valid CF_API_TOKEN

Make sure you have a valid deployment token by doing:

wrangler login 

or:

wrangler config 

Generate a new repository

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

Get a LastFM API_KEY

Create a secret API_KEY for the Cloudflare Worker to use the LastFM APIs.

Usage

Local development

To develop locally just run:

npm start

To deploy to dev just run:

npm run deploy

Monitoring

To monitor any of the deployed environments run:

wrangler tail

Customised markdown badges

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.

Style

![](http://img.shields.io/endpoint?url=https://workers.vortex.name/lastfm/endpoint.json&style=flat)

Color

![](http://img.shields.io/endpoint?url=https://workers.vortex.name/lastfm/endpoint.json&color=green)

Label

![](http://img.shields.io/endpoint?url=https://workers.vortex.name/lastfm/endpoint.json&label=Recently%20Played)

Logo color

![](http://img.shields.io/endpoint?url=https://workers.vortex.name/lastfm/endpoint.json&logoColor=green)

License

This library is released under BSD-3 license clause.

FOSSA Status