https://github.com/brianmitchl/lastfm-proxy
🎵 A Cloudflare Worker acting as a proxy for the LastFM API in order to expose endpoints.
https://github.com/brianmitchl/lastfm-proxy
cloudflare-worker lastfm
Last synced: about 1 month ago
JSON representation
🎵 A Cloudflare Worker acting as a proxy for the LastFM API in order to expose endpoints.
- Host: GitHub
- URL: https://github.com/brianmitchl/lastfm-proxy
- Owner: BrianMitchL
- License: mit
- Created: 2020-08-29T04:04:42.000Z (over 4 years ago)
- Default Branch: dev
- Last Pushed: 2022-12-04T20:58:50.000Z (over 2 years ago)
- Last Synced: 2025-01-31T11:50:05.502Z (3 months ago)
- Topics: cloudflare-worker, lastfm
- Language: TypeScript
- Homepage:
- Size: 196 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lastfm-proxy
A Cloudflare Worker acting as a proxy for the LastFM API in order to expose endpoints.
The dev and prod versions I built this for are deployed to the following, targeting my last.fm user account, [BrianMitchL](https://www.last.fm/user/BrianMitchL).
| Environment | URL |
| ----------- | ---------------------------------- |
| Dev | https://lastfm-proxy-dev.brianm.me |
| Prod | https://lastfm-proxy.brianm.me |## Use
There are two routes, `/tracks` and `/artists`, each can be supplied with the optional `period` search parameter with one of the following options: `overall | 7day | 1month | 3month | 6month | 12month`. If none is specified, we default to `overall`.
Example: https://lastfm-proxy-dev.brianm.me/tracks?period=7day
## Getting Started
This worker is meant to be used with [Wrangler](https://github.com/cloudflare/wrangler). Documentation can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler/).
### Developing
[`src/index.js`](./src/index.ts) calls the request handler in [`src/handler.ts`](./src/handler.ts), and will return the [request method](https://developer.mozilla.org/en-US/docs/Web/API/Request/method) for the given request.
#### Configuration
There are two environment variables used to configure the worker.
| Variable | Use |
| ----------------- | ----------------------------------------------------------------------------------------------------------------- |
| `LASTFM_USERNAME` | The LastFM username to source the data from. |
| `LASTFM_API_KEY` | The LastFM API key used to authorize the request. This is configured as a secret variable in Cloudflare/Wrangler. |#### Testing
`npm run test` will run the tests.
### Previewing and Publishing
Run `npm run start` to run a test version of the worker.
Run `wrangler publish --env=dev` or `wrangler publish` to publish the dev or prod versions.
The GitHub Actions should do this automatically when merging into the `dev` or `main` branches.