diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..578b5597 --- /dev/null +++ b/.env.example @@ -0,0 +1,43 @@ +# Copy to `.env` and fill in. Never commit `.env`. + +# --- TIDAL (required) ------------------------------------------------------- +# From your app at https://developer.tidal.com/dashboard +TIDAL_CLIENT_ID= +TIDAL_CLIENT_SECRET= + +# Your TIDAL user ID — the playlists owned by this user are shown. +# `npm run tidal:login` prints it for you. +TIDAL_USER_ID= + +# Only needed if TIDAL rejects client-credentials access to your playlists. +# Run `npm run tidal:login` once to obtain it. Treat it like a password. +TIDAL_REFRESH_TOKEN= + +# Redirect URI registered in the TIDAL dashboard, used by `npm run tidal:login`. +# TIDAL_REDIRECT_URI=http://localhost:3000/callback + +# ISO 3166-1 country code sent to the TIDAL API. +# TIDAL_COUNTRY_CODE=GB + +# --- Site ------------------------------------------------------------------ +# Public URL of the site (used for social sharing tags). On Vercel, defaults to +# the project's production URL; set it if you use a custom domain. +# SITE_URL=https://example.com +# Link for the "View on TIDAL" button in the footer. Hidden if empty. +TIDAL_PROFILE_URL= + +# --- Behaviour ------------------------------------------------------------- +# How long the server trusts its copy of your playlists before re-checking TIDAL (ms). +CACHE_DURATION=600000 +# On Vercel: how long the CDN serves cached playlist data before refreshing (seconds). +# CDN_CACHE_SECONDS=600 +# PORT=3000 +# LOG_LEVEL=info + +# --- Error reporting (optional) --------------------------------------------- +# Set to send server and browser errors to Sentry (https://sentry.io). +# SENTRY_DSN= + +# --- Local development ------------------------------------------------------ +# Serve generated demo playlists instead of calling TIDAL (`npm run dev:mock`). +# TIDAL_MOCK=1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..19470e78 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node: [22, 24] + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 + with: + node-version: ${{ matrix.node }} + cache: npm + - run: npm ci + - run: npm run check + - run: npm test diff --git a/.gitignore b/.gitignore index 1a76ad53..21e5e072 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ node_modules/ .env -**/.DS_Store \ No newline at end of file +.env.* +!.env.example +.cache/ +coverage/ +**/.DS_Store diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..2bd5a0a9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/README.md b/README.md index f999db2f..d6b17ac5 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,128 @@ -# Selections +# SoundSelections -Selections is a Spotify playlist app that serves my weekly curated playlists for every genre and mood, as well as deep dives on artist's back catalogues. With this app, you'll be able to discover new music and artists that you might not have found otherwise. +A fast, responsive browser for Beere's curated playlists on [TIDAL](https://tidal.com): weekly selections for every genre and mood, plus deep dives into artists' back catalogues. -## Features +- Browse every public playlist, artwork first, on any screen size. +- Search titles, artist/genre tags and descriptions as you type (accents ignored: "bjork" finds "Björk"). +- Filter by artist or genre, taken from the playlist title — "Night drive (rock)" is tagged *rock*. +- Open a playlist to play it in TIDAL's embedded player, open it in TIDAL, or copy its link. +- Every view has its own URL (`?q=`, `?tag=`, `?sort=`, `?p=`), so it can be shared, bookmarked, and the Back button closes an open playlist. -* Weekly curated playlists for every genre and mood -* Deep dives on artist's back catalogues +## Quick start -## Getting Started +Requires Node.js 22.12 or newer. -1. Clone the repository to your local machine. +```bash +npm install +npm run dev:mock # demo playlists, no TIDAL account needed +``` -2. Create a new Spotify App at the Spotify Developer Dashboard. +Open . -3. Add http://localhost:3000/callback as a Redirect URI in your Spotify App settings. +## Connecting your TIDAL account -4. Copy the Client ID and Client Secret from your Spotify App settings and add them, along with a cache duration to a `.env` file at the root of the project: - -``` -CLIENT_ID= -CLIENT_SECRET= -CACHE_DURATION= -``` +1. In your app at [developer.tidal.com](https://developer.tidal.com/dashboard), copy the **Client ID** and **Client Secret**. +2. Copy `.env.example` to `.env` and fill in: -1. Install the required packages + ``` + TIDAL_CLIENT_ID=… + TIDAL_CLIENT_SECRET=… + TIDAL_USER_ID=… # whose playlists to show (see below) + TIDAL_PROFILE_URL=… # optional: link for the "View on TIDAL" button + ``` -```bash -npm install -``` +3. `npm run dev`, and check the terminal: it logs `Fetched playlists from TIDAL` with a count when everything works. + +### If TIDAL refuses: sign in once + +TIDAL has said its playlist endpoints may require a signed-in user, even for public playlists. If the log shows *"TIDAL denied access … Run `npm run tidal:login`"*: + +1. In the TIDAL dashboard, add `http://localhost:3000/callback` as a **Redirect URI** for your app, and enable the `user.read` and `playlists.read` scopes. +2. Stop the app, then run `npm run tidal:login -- --save` and sign in with the link it prints. +3. It saves `TIDAL_REFRESH_TOKEN` (and your `TIDAL_USER_ID`) to `.env`. Add the same values to your Vercel project's environment variables. + +The refresh token grants read access to your account: keep it secret. Only **public** playlists are ever shown, whichever way the app signs in. + +**Finding your user ID:** `npm run tidal:login` prints it. + +## Deploying (Vercel) -1. Start the development server +1. In Vercel, **Add New → Project** and import this GitHub repository. Vercel detects an Express app (`app.js`). There is no build step, and the settings in `vercel.json` need no changes. +2. Under **Settings → Environment Variables**, add for Production (and Preview, if you want working preview deployments): + - `TIDAL_CLIENT_ID`, `TIDAL_CLIENT_SECRET`, `TIDAL_USER_ID`, `TIDAL_REFRESH_TOKEN` + - `TIDAL_PROFILE_URL` (optional) and `SENTRY_DSN` (optional) + - `SITE_URL` only if you use a custom domain; otherwise the project's production URL is used. +3. Deploy. Every pull request gets its own preview deployment. +4. Check `https:///healthz`: it should report `"status":"ok"` and a playlist count. + +How the app runs on Vercel: + +- **One function, CDN-served files:** `app.js` is a single Vercel Function. Everything in `public/` is served directly by Vercel's CDN; `vercel.json` maps the versioned `/static//…` URLs onto those files and marks them cacheable for a year. +- **Playlist data is cached on the CDN:** API responses carry a `Vercel-CDN-Cache-Control` header, so the CDN answers repeat requests and refreshes in the background. Visitors only wait for TIDAL (about 10 seconds for ~340 playlists) on the first request after a deploy, or when the CDN has no copy at all. Change `CDN_CACHE_SECONDS` (default 600) to tune this. +- **Disk:** each function instance keeps its saved copy in the temp directory, the only writable place on Vercel. +- **Background work:** refreshes and Sentry reports run through `waitUntil`, so they finish after the response is sent. +- **Preview toolbar:** on preview deployments, Vercel's toolbar may be blocked by the site's Content Security Policy and show up as CSP reports in the logs. This is harmless; the toolbar can be turned off in the project settings. + +`npm start` still runs a normal long-lived server for any other host. + +## How it stays fast + +**On the server.** All playlists and their artwork come from TIDAL in a handful of paginated requests. The old app made one extra request for every playlist. The result is kept in memory for `CACHE_DURATION` (10 minutes by default) and saved to disk, so a restart serves instantly. After that, the next visit triggers a background refresh, and visitors never wait for it. On Vercel, the CDN also caches the playlist data (see *Deploying*). If TIDAL is down, the last good copy keeps being served while the server retries with back-off. + +**In the browser.** +- **First visit:** one request for everything, roughly 10–20 KB compressed for 150 playlists. A tiny script in `` starts it before the app's code has even downloaded, and the newest playlist's artwork is preloaded. +- **Return visits:** the grid renders instantly from the browser's saved copy (localStorage). The app then asks the server whether anything has changed, using an ETag. Usually the answer is an empty `304 Not Modified`. +- **When something has changed:** the server sends a manifest of every playlist's id and revision. The browser then downloads only the playlists that are new or edited, drops deleted ones, and says *"A new playlist has been added since your last visit."* + +**Images and assets.** +- **Artwork:** each image is sized to fit its card (`srcset`/`sizes`), lazy-loaded as you scroll, and fades in over its own palette colour. Only the first row loads eagerly. +- **TIDAL player:** loads only when a playlist is opened, and is removed when it closes. +- **CSS, JS and fonts:** served from URLs that include a hash of their contents, so browsers cache them for a year and a deploy updates them all at once. No build step is needed. The Outfit font is self-hosted. + +## Errors: handling and reporting + +- **For visitors:** nothing fails silently or shows a broken page. + - Clear messages, with a *Try again* button. + - Offline detection, with an automatic retry on reconnect. + - Automatic retries while TIDAL is unavailable. + - The saved copy stays on screen when a refresh fails. + - A placeholder for any artwork that fails to load, and a fallback when the clipboard is blocked. +- **Server logs:** structured JSON, one line per request, each with a request ID. Visitors see that ID ("Reference: …") on error messages, so a report can be matched to its log line. Secrets are redacted. +- **Browser errors:** sent to `POST /api/reports`, which de-duplicates and rate-limits them before logging. Content-Security-Policy violations are reported there too. +- **Sentry (optional):** set `SENTRY_DSN` to receive server and browser errors with alerting. The SDK loads only when configured. +- **TIDAL failures:** carry TIDAL's own error code and request ID. Credential problems explain how to fix them. +- **Health:** `GET /healthz` reports `ok`, `degraded` (serving the last good copy) or `unavailable`, with the data's age. +- **Crashes:** an unexpected crash is reported before the process exits, and the host restarts it. Shutdown on deploy is graceful. + +## Development ```bash -node app.js +npm run dev # with your TIDAL account; restarts on server changes +npm run dev:mock # with generated demo data +npm test # unit and integration tests (Node's built-in runner) +npm run check # syntax-check every JS file, including browser code ``` -1. Visit http://localhost:3000 in your web browser to use the app. +CI runs `check` and `test` on every pull request (`.github/workflows/ci.yml`). -## Contributing - -Contributions are always welcome! If you find a bug or have a feature request, please open an issue on the GitHub repository. +``` +app.js entry point: exported as the Vercel Function, or listens locally +vercel.json Vercel rewrites, cache headers and function settings +src/ + site.js builds the app; serve() runs it as a normal server + config.js settings from the environment, validated at start-up + catalogue.js server copy of the playlists: refresh, back-off, disk snapshot + reporting.js one place for errors: logs + optional Sentry + tidal/ TIDAL auth, API client (retries, pagination), normalisation, mock + http/ Express app, security headers, report intake, asset versioning +views/ page templates +public/ + css/app.css all styles + js/ browser modules: sync, store, grid, dialog, filter, report… +scripts/tidal-login.js one-time TIDAL sign-in helper +test/ tests +``` -## License +## Licence -This project is licensed under the MIT License. +MIT. The Outfit font is licensed under the SIL Open Font License (`public/fonts/OFL.txt`). diff --git a/app.js b/app.js index a4f4dd03..d7497323 100644 --- a/app.js +++ b/app.js @@ -1,185 +1,19 @@ -require('dotenv').config(); - -const express = require('express'); -const app = express(); -const axios = require('axios'); -const cache = require('memory-cache'); - -app.set('view engine', 'ejs'); -app.use(express.static('public')); - -const PORT = process.env.PORT || 3000; -app.listen(PORT, () => { - console.log(`Server listening on port ${PORT}`); -}); - -const client_id = process.env.CLIENT_ID; -const client_secret = process.env.CLIENT_SECRET; -const cache_duration = parseInt(process.env.CACHE_DURATION) || 10 * 60 * 1000; -let access_token; - -const getAccessToken = async () => { - try { - const response = await axios({ - url: 'https://accounts.spotify.com/api/token', - method: 'post', - params: { - grant_type: 'client_credentials', - }, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - Authorization: `Basic ${Buffer.from(`${client_id}:${client_secret}`).toString('base64')}`, - }, - }); - access_token = response.data.access_token; - } catch (error) { - console.error(error); - } -}; - -const retry = async (fn, retries = 3, delay = 1000, backoffFactor = 2) => { - for (let i = 0; i < retries; i++) { - try { - return await fn(); - } catch (error) { - if (i === retries - 1) { - throw error; - } - - if (error.response && error.response.status === 429) { - // Use the 'Retry-After' header if available, otherwise, use the default delay - const retryAfter = error.response.headers['retry-after'] ? parseInt(error.response.headers['retry-after']) * 1000 : delay * Math.pow(backoffFactor, i); - console.log(`Rate limited. Retrying after ${retryAfter / 1000} seconds.`); - await new Promise((resolve) => setTimeout(resolve, retryAfter)); - } else { - await new Promise((resolve) => setTimeout(resolve, delay)); - } - } - } -}; - - - -getAccessToken(); - -app.get('/', (req, res) => { - res.render('index'); -}); - -app.get('/playlists/:userId', async (req, res) => { - try { - const search = req.query.search ? req.query.search.toLowerCase() : ''; - - const cacheKey = `playlists-${req.params.userId}-${search}`; - const cachedPlaylists = cache.get(cacheKey); - - if (cachedPlaylists) { - res.json({ items: cachedPlaylists }); - return; - } - - const limit = 50; - let offset = 0; - let allPlaylists = []; - - while (true) { - const response = await retry(async () => { - const res = await axios.get(`https://api.spotify.com/v1/users/${req.params.userId}/playlists`, { - headers: { - Authorization: `Bearer ${access_token}`, - }, - params: { - limit, - offset, - }, - }); - - if (res.status === 429) { - throw new Error('Rate limited'); - } - - return res; - }); - - console.log('Fetched playlists:', response.data.items); - - allPlaylists.push(...response.data.items); - - if (response.data.items.length < limit) { - break; - } - - offset += limit; - } - - const detailedPlaylistsPromises = allPlaylists.map(async (playlist) => { - const details = await retry(async () => { - const res = await axios.get(`https://api.spotify.com/v1/playlists/${playlist.id}`, { - headers: { - Authorization: `Bearer ${access_token}`, - }, - }); - - if (res.status === 429) { - throw new Error('Rate limited'); - } - - return res; - }); - - return { - ...playlist, - fullDescription: details.data.description || '', - followers: details.data.followers || { total: 0 }, - }; - }); - - const detailedPlaylists = await Promise.all(detailedPlaylistsPromises); - - const filteredPlaylists = detailedPlaylists.filter((playlist) => { - return ( - playlist.name.toLowerCase().includes(search) || - playlist.description.toLowerCase().includes(search) - ); - }); - - console.log('Returning all playlists:', detailedPlaylists); - cache.put(cacheKey, filteredPlaylists, cache_duration); // Cache for cache_duration - res.json({ items: filteredPlaylists }); - } catch (error) { - console.error(error); - res.status(500).json({ error: 'Error fetching playlists', details: error.message }); - } -}); - -app.get('/playlists/:userId/:playlistId', async (req, res) => { - try { - const cacheKey = `playlist-${req.params.playlistId}`; - const cachedPlaylist = cache.get(cacheKey); - - if (cachedPlaylist) { - res.json(cachedPlaylist); - return; - } - - const response = await retry(async () => { - const res = await axios.get(`https://api.spotify.com/v1/playlists/${req.params.playlistId}`, { - headers: { - Authorization: `Bearer ${access_token}`, - }, - }); - - if (res.status === 429) { - throw new Error('Rate limited'); - } - - return res; - }); - - cache.put(cacheKey, response.data, cache_duration); // Cache for cache_duration - res.json(response.data); - } catch (error) { - console.error(error); - res.status(500).send('Error fetching playlist details'); - } -}); +// Entry point. On Vercel this file is the function: it exports the Express app +// and Vercel handles requests. Anywhere else (`npm run dev`, `npm start`) it +// listens on PORT as a normal server. +import { ConfigError } from './src/errors.js'; +import { createSite, serve } from './src/site.js'; + +let site; +try { + site = await createSite(); +} catch (error) { + // A readable message instead of a stack trace; on Vercel, rethrow so the deploy's logs show it. + if (!(error instanceof ConfigError) || process.env.VERCEL) throw error; + console.error(`\n${error.message}\n`); + process.exit(1); +} + +if (!site.config.onVercel) serve(site); + +export default site.app; diff --git a/package-lock.json b/package-lock.json index 140df33d..6c0aed13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,661 +1,1790 @@ { - "name": "my-spotify", - "version": "1.0.0", + "name": "selections", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "my-spotify", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "axios": "^1.3.4", - "dotenv": "^16.0.3", - "ejs": "^3.1.9", - "express": "^4.18.2", - "memory-cache": "^0.2.0" - } - }, - "node_modules/accepts": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", - "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "name": "selections", + "version": "2.0.0", + "license": "MIT", "dependencies": { - "mime-types": "~2.1.34", - "negotiator": "0.6.3" + "@sentry/node": "^11.9.0", + "@vercel/functions": "^3.10.3", + "compression": "^1.8.2", + "ejs": "^7.0.2", + "express": "^5.3.0", + "helmet": "^8.3.0", + "pino": "^10.4.0", + "pino-http": "^11.0.0" + }, + "devDependencies": { + "pino-pretty": "^13.2.0" }, "engines": { - "node": ">= 0.6" + "node": ">=22.12" } }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@opentelemetry/api": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.10.0.tgz", + "integrity": "sha512-lMkyes8iHrG+mk6WH7X70MdCLI2RS0FwNBY1PyQ8UemaijE2m5mv5A0Niy3HtbYTFrgkUEQjFMXmSAk2hQDuPQ==", + "license": "Apache-2.0", "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" + "node": ">=8.0.0" } }, - "node_modules/array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" - }, - "node_modules/async": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", - "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/axios": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz", - "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", - "dependencies": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" + "node_modules/@oxc-parser/binding-android-arm-eabi": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-android-arm-eabi/-/binding-android-arm-eabi-0.152.0.tgz", + "integrity": "sha512-393VtirINkae4XHBTkq/yQxhOwEr4V+r0et37P2fp+sYZSdYgZTRDPo5Um8vBh0QjMZ+RmaMy4PP0qwr4cTMwA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, + "node_modules/@oxc-parser/binding-android-arm64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-android-arm64/-/binding-android-arm64-0.152.0.tgz", + "integrity": "sha512-iYFcExATJNZ0rZj0o02THbD1Nc9jAW0nVgIQPee6ejbSASpbZXlIMw8jxtpzaG14JQTWwGSZ6U5dEtRJXE6V3Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "node_modules/@oxc-parser/binding-darwin-arm64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-darwin-arm64/-/binding-darwin-arm64-0.152.0.tgz", + "integrity": "sha512-fnU+DfUzi5/rFy0LzmipYRz06PAUUkOS8kCJQ3Eg6oqlunC1XZXoffFqxmdL51RmcbYtUG3P8DVG1U5fckoa2A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "node_modules/@oxc-parser/binding-darwin-x64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-darwin-x64/-/binding-darwin-x64-0.152.0.tgz", + "integrity": "sha512-Y3U2okryWTs7hDld6UhjJwLNf8/do+x4g4C+1U5SiGwrTLwbO83WJYJA8+l9iFSilWBgnfpd/+U76tfeNxUHzA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], "engines": { - "node": ">= 0.8" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dependencies": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "node_modules/@oxc-parser/binding-freebsd-x64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-freebsd-x64/-/binding-freebsd-x64-0.152.0.tgz", + "integrity": "sha512-XkhkRrrPffEw+ZLv/d/5pEni0buxinm/E/N6fLbJCunD1DBbeCTtVP23ESV+4CWCWdSz397asks1ViGslpmWiQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, + "node_modules/@oxc-parser/binding-linux-arm-gnueabihf": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-0.152.0.tgz", + "integrity": "sha512-MLzsRRbdfmdzo6JEhbC1yKU9ItfvM8tEf18HM32jCiNYZEz6J3bRBRl3cTkKR0vBdrk9ZVlcARXtwHccs+epDA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, + "node_modules/@oxc-parser/binding-linux-arm-musleabihf": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-0.152.0.tgz", + "integrity": "sha512-HHerTEJz7Iy10Ji6BGsk4gqG6PU0UzFuBu91jIEOX89FnrI5ECWSEr7BLpkYQhp7U0QFtMnBhNfQKI0hYZK78w==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">=7.0.0" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + "node_modules/@oxc-parser/binding-linux-arm64-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-0.152.0.tgz", + "integrity": "sha512-9Bb8GyzZ2uSLzRDZ27usaKokr07mxiBe2dDF5b6bd2janmaJTT1gL51UfP7AU30yFiXrJvcRyFKREAgKwZYs0w==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, + "node_modules/@oxc-parser/binding-linux-arm64-musl": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm64-musl/-/binding-linux-arm64-musl-0.152.0.tgz", + "integrity": "sha512-om7iDMUroI74A/lfRRWY9/Ev3VWrVsrUZ4tyvyh8raBey/sdcfyAD7tYWc+iykAiotnmftyKTpUKFr1QnaBrAQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">= 0.8" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "node_modules/@oxc-parser/binding-linux-ppc64-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-0.152.0.tgz", + "integrity": "sha512-Lf1OL2lMTqwDMFC6jnRb30B+WYHKV0XT+bPHcFM6xHtNVwxpobiTzUIvKH6a0LWpvfwyru8Yu6zCGHqqFHH+gg==", + "cpu": [ + "ppc64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } }, - "node_modules/content-disposition": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", - "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", - "dependencies": { - "safe-buffer": "5.2.1" - }, + "node_modules/@oxc-parser/binding-linux-riscv64-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-0.152.0.tgz", + "integrity": "sha512-BYWSMQK+YJ9ZILStPcmmiSVq8KEG9Qdq/c4BHPC3rUEq/fEDCVjUIwdj5ZzjgZ9P9is9PKu0tcAXzq1ZXg4urQ==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">= 0.6" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/content-type": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "node_modules/@oxc-parser/binding-linux-riscv64-musl": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-0.152.0.tgz", + "integrity": "sha512-d2LqHNNNqdH185sRK5dPKWZu201JrNu9/CRFuVEuT+ht7n/QaVblEMWT9MALQPrDWYvhG10P+NSKJFquDWZ09w==", + "cpu": [ + "riscv64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">= 0.6" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "node_modules/@oxc-parser/binding-linux-s390x-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-0.152.0.tgz", + "integrity": "sha512-8gBeHt5rA/8+pKhHl+zLggfa3L/V/L2at96p7ty6pBE7id6lFO19nFUc15u2PcjC4OYeYK465MKy1fhhbpFIGw==", + "cpu": [ + "s390x" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">= 0.6" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + "node_modules/@oxc-parser/binding-linux-x64-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.152.0.tgz", + "integrity": "sha512-ltgrSF6L+yPTVsIdaAyqKq3zTqzj/1VlNbxWZuxAe8flR3sWdyNsKvdXukoO8/ucJbLickhmieRBge+o/e8Ugw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } }, - "node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" + "node_modules/@oxc-parser/binding-linux-x64-musl": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-musl/-/binding-linux-x64-musl-0.152.0.tgz", + "integrity": "sha512-LcMp6BvrBnewSfdkLHoSqidhoAq4syKOTBV5TYHWd+2VnGkfD/nPRRVIzTBt/Lkbt7pfOFDGtkiTntFS0p6sQQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "node_modules/@oxc-parser/binding-openharmony-arm64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-openharmony-arm64/-/binding-openharmony-arm64-0.152.0.tgz", + "integrity": "sha512-jbhoMCslVxzRCRNQ8TSHxjYdSKRvk8O6ciLVDkahJvmyHDzBqba/bMQHM6ULKj/rgHNNbSzlIiakdx8SEfkJzA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], "engines": { - "node": ">=0.4.0" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "node_modules/@oxc-parser/binding-win32-arm64-msvc": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-0.152.0.tgz", + "integrity": "sha512-JZYVlhv36mr/nertnRB7vchJECOBb1Lz6lltalILsB+o9M/is+H6BEDRLQKdqA4JKs6NjJszo46+iM5sfwj6jQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], "engines": { - "node": ">= 0.8" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/destroy": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", - "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "node_modules/@oxc-parser/binding-win32-ia32-msvc": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-0.152.0.tgz", + "integrity": "sha512-1X9oganvVsunRH0lH10UU05N+H9atpX6WsOybByUjwnfcd3h/0tYwvuv16XuHglrIUOnxV2TodbLVEwwafd64g==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/dotenv": { - "version": "16.0.3", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", - "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "node_modules/@oxc-parser/binding-win32-x64-msvc": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-x64-msvc/-/binding-win32-x64-msvc-0.152.0.tgz", + "integrity": "sha512-sw0M80/dn9rcpu+Rqqph/C+MjvDDce6MlXmFjsNQtPEymha0eJy3ml6+foSUTqFfpDIDyHZZ4eoJ43IoMe8bJw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], "engines": { - "node": ">=12" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + "node_modules/@oxc-project/types": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.152.0.tgz", + "integrity": "sha512-oM/5rLBm2tPkg0iBgkH/FOeR3PCDpY19GTgAZjMFM8h9WI9VW7cLgzp6nwtarYKmovavIQZ+Fe/RKX/8C8O/Rw==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } }, - "node_modules/ejs": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz", - "integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==", + "node_modules/@pinojs/redact": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz", + "integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==", + "license": "MIT" + }, + "node_modules/@sentry/bundler-plugins": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/@sentry/bundler-plugins/-/bundler-plugins-11.9.0.tgz", + "integrity": "sha512-wpz/gcM/6rld/wb4Mhf8kbDN9ngG5myKQSZC+45gzqR1w+GcdfVnYkp3sHL9AV4mrwL8skhTItdUghMwMTknKg==", + "license": "MIT", "dependencies": { - "jake": "^10.8.5" - }, - "bin": { - "ejs": "bin/cli.js" + "@sentry/core": "11.9.0", + "dotenv": "^17.4.2", + "glob": "^13.0.6", + "magic-string": "~0.30.8 || ^1.0.0", + "oxc-parser": "^0.152.0", + "sentry": "^0.45.0", + "supports-color": "^8.1.1" }, "engines": { - "node": ">=0.10.0" + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" + }, + "peerDependencies": { + "rollup": ">=3.2.0", + "webpack": ">=5.1.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "webpack": { + "optional": true + } } }, - "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "node_modules/@sentry/conventions": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@sentry/conventions/-/conventions-0.27.0.tgz", + "integrity": "sha512-Mrqd/o7n/z7qWSYfQQA7x4fFTA0IqOG6JNsbBpnC97khPwZk7n6DPtOO7YgaYplSl8R8QLRbBz9Xv2lVhToSAg==", + "license": "MIT", "engines": { - "node": ">= 0.8" + "node": ">=14" } }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" - }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "node_modules/@sentry/core": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-11.9.0.tgz", + "integrity": "sha512-t0dZyHILt2XVC4Fe9UmAty6YRfOuQv95cvWeNl+HlW4LphjF5/jkALV3cJCUMdhpblYELgIJC4U/S/GoYuI2bA==", + "license": "MIT", + "dependencies": { + "@sentry/conventions": "^0.27.0" + }, "engines": { - "node": ">= 0.6" + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" } }, - "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", - "dependencies": { - "accepts": "~1.3.8", - "array-flatten": "1.1.1", - "body-parser": "1.20.1", - "content-disposition": "0.5.4", - "content-type": "~1.0.4", - "cookie": "0.5.0", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "2.0.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "1.2.0", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.7", - "qs": "6.11.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" + "node_modules/@sentry/node": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-11.9.0.tgz", + "integrity": "sha512-cz219PzVaAPTlQ4bRBTRBCOvxbZkXK0KkqyqWPV6OmSn6vWn935CTfOs+MKUc1A+locvB8i9OfBIbO6v03BBuQ==", + "license": "MIT", + "dependencies": { + "@opentelemetry/api": "^1.9.1", + "@sentry/bundler-plugins": "11.9.0", + "@sentry/conventions": "^0.27.0", + "@sentry/core": "11.9.0", + "@sentry/opentelemetry": "11.9.0", + "@sentry/server-runtime-injection": "11.9.0", + "@sentry/server-utils": "11.9.0" }, "engines": { - "node": ">= 0.10.0" + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" } }, - "node_modules/filelist": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", - "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", + "node_modules/@sentry/opentelemetry": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/@sentry/opentelemetry/-/opentelemetry-11.9.0.tgz", + "integrity": "sha512-FMCkAbEfBpFterrkR7k4P8LEabUAEHjZMbu+ycDjbnI1U4pT22tpwcFJOt06orFkacoWNsYT9+EdfmkvaCKtSA==", + "license": "MIT", "dependencies": { - "minimatch": "^5.0.1" + "@sentry/conventions": "^0.27.0", + "@sentry/core": "11.9.0" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.9.0" } }, - "node_modules/filelist/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "node_modules/@sentry/server-runtime-injection": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/@sentry/server-runtime-injection/-/server-runtime-injection-11.9.0.tgz", + "integrity": "sha512-Q2G5xaeoiYwGheCZyeqZ/v//SZYjRLlITlanTsZM/fox1qk7cmbDX7+o4q+JkApVV9VuXQZVxppaVCsBglfDKA==", + "license": "MIT", "dependencies": { - "balanced-match": "^1.0.0" + "@sentry/core": "11.9.0", + "@sentry/server-utils": "11.9.0" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" } }, - "node_modules/filelist/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "node_modules/@sentry/server-utils": { + "version": "11.9.0", + "resolved": "https://registry.npmjs.org/@sentry/server-utils/-/server-utils-11.9.0.tgz", + "integrity": "sha512-xHETix5jAjs/4tY+b9RCejEU7O49pNBiGgCWX0KFRMSpWbw9moqQ8i8N62bS7L+/BJnBcZ5SZ1nweXh7w787Qg==", + "license": "MIT", "dependencies": { - "brace-expansion": "^2.0.1" + "@opentelemetry/api": "^1.9.1", + "@sentry/conventions": "^0.27.0", + "@sentry/core": "11.9.0" }, "engines": { - "node": ">=10" + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" } }, - "node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "node_modules/@vercel/cli-config": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@vercel/cli-config/-/cli-config-0.3.3.tgz", + "integrity": "sha512-5T0ZtIFgcFHuPFuuoJKno5ZeKvLQGiS/JAFMI1zG1HBw2dklScoHdA0LDb/SoeRYD53N33iXFAqyRA0tHLhdnQ==", + "license": "Apache-2.0", "dependencies": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "statuses": "2.0.1", - "unpipe": "~1.0.0" + "xdg-app-paths": "5", + "zod": "4.1.11" + } + }, + "node_modules/@vercel/cli-exec": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@vercel/cli-exec/-/cli-exec-1.0.1.tgz", + "integrity": "sha512-g9XerViJ/paZujufXYcu5XYI2vU2rtB4sgdpjUHde5RnOkdmpu0ngH46LCFGHoPXO/C+qDPSczIHIRN+8Q2YKQ==", + "license": "Apache-2.0", + "dependencies": { + "execa": "5.1.1" }, "engines": { - "node": ">= 0.8" + "node": ">= 18" } }, - "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], + "node_modules/@vercel/functions": { + "version": "3.10.3", + "resolved": "https://registry.npmjs.org/@vercel/functions/-/functions-3.10.3.tgz", + "integrity": "sha512-EjMUf+myWckV9vj5FbzRG1wQP1IFRgmlOu2ho1FiFTjLs1mFnY4dxeI8Swk9pszj4jv/jGdvlmqRKHipuEt5bw==", + "license": "Apache-2.0", + "dependencies": { + "@vercel/oidc": "4.0.3" + }, "engines": { - "node": ">=4.0" + "node": ">= 20" + }, + "peerDependencies": { + "@aws-sdk/credential-provider-web-identity": "*", + "ws": ">=8" }, "peerDependenciesMeta": { - "debug": { + "@aws-sdk/credential-provider-web-identity": { + "optional": true + }, + "ws": { "optional": true } } }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "node_modules/@vercel/oidc": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@vercel/oidc/-/oidc-4.0.3.tgz", + "integrity": "sha512-0sljpA/leE1vLkY7DVOs/z/OH6x1hgKhrF+IY2YdbRYm/6UnQjeu0SMnzOKLtkJWp13srUFkWdir4iU3feFYfg==", + "license": "Apache-2.0", "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" + "@vercel/cli-config": "0.3.3", + "@vercel/cli-exec": "1.0.1", + "jose": "^5.9.6" }, "engines": { - "node": ">= 6" + "node": ">= 20" } }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, "engines": { "node": ">= 0.6" } }, - "node_modules/fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "node_modules/accepts/node_modules/negotiator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz", + "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", + "license": "MIT", + "dependencies": { + "content-type": "^2.1.0" + }, "engines": { - "node": ">= 0.6" + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, - "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } }, - "node_modules/get-intrinsic": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", - "integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==", + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/body-parser": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz", + "integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==", + "license": "MIT", "dependencies": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.3" + "bytes": "^3.1.2", + "content-type": "^2.1.0", + "debug": "^4.4.3", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.3", + "on-finished": "^2.4.1", + "qs": "^6.16.1", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" + }, + "engines": { + "node": ">=18" }, "funding": { - "url": "https://github.com/sponsors/ljharb" + "type": "opencollective", + "url": "https://opencollective.com/express" } }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "node_modules/body-parser/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", "dependencies": { - "function-bind": "^1.1.1" + "ms": "^2.1.3" }, "engines": { - "node": ">= 0.4.0" + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "node_modules/body-parser/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, "engines": { - "node": ">=8" + "node": "20 || >=22" } }, - "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "node": ">= 0.8" } }, - "node_modules/http-errors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", - "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/colorette": { + "version": "2.0.20", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", + "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", + "dev": true, + "license": "MIT" + }, + "node_modules/compressible": { + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", + "integrity": "sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==", + "license": "MIT", + "dependencies": { + "mime-db": ">= 1.43.0 < 2" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/compression": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.8.2.tgz", + "integrity": "sha512-o8vI5RE5A6EVVOd9o41jKp41aJom+QTEO/Bx8MYNjexMo/Bv2WOjUfZr+aL0WnYSgymUy6zeguqLTsIhV0gMvQ==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "compressible": "~2.0.18", + "debug": "2.6.9", + "destroy": "1.2.0", + "negotiator": "~0.6.4", + "on-headers": "~1.1.0", + "safe-buffer": "5.2.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.8.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-disposition": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-2.0.1.tgz", + "integrity": "sha512-e+H0ZXHSWYrENhQzw1LPuP4oF5MzVKmDU6d3hxlvaPEYLLg62MxtQNPRx4SYSuYJSBUgnQIG4HIN2tEtNv7Dog==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/dateformat": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", + "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dotenv": { + "version": "17.4.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz", + "integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/ejs": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-7.0.2.tgz", + "integrity": "sha512-LcDSEP6Oclb9sTiSyG0MpG0RuKvLDRxCOOt+2sIk+kdk1rMkFU8SRnT0qaNt5zvU0LOV1YXXOvIoZL/sKwabvw==", + "license": "Apache-2.0", + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.12.18" + } + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/express": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/express/-/express-5.3.0.tgz", + "integrity": "sha512-qCqy1xSoaugxOD4IVHb1ZWdkvCF2W3aE2okKouWj8VwJ+ztskSiXoBnCSJqfKT+cVPJhuJqe9YLbY425+Zh00g==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.3.0", + "content-disposition": "^2.0.1", + "content-type": "^2.0.0", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.8", + "qs": "^6.16.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.1.0", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/express/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/fast-copy": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-4.3.0.tgz", + "integrity": "sha512-oWBZLHWpUYt2A471n+ayC4+bJSGDWpl2h3COgBxYX5xHFnr7KqOSrYJZX82ZmrtAfVK+SqsOuNMgsoL+lJquuQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "dev": true, + "license": "MIT" + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/finalhandler/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "13.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", + "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "license": "BlueOak-1.0.0", + "dependencies": { + "minimatch": "^10.2.2", + "minipass": "^7.1.3", + "path-scurry": "^2.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/helmet": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/helmet/-/helmet-8.3.0.tgz", + "integrity": "sha512-Qgpiaws3Sm30Av8Eah6sjMCZZwjlBu+E68rhpCWBshY1lb09HtLwj5GviX0OyQIn+ulUS0iX0AxN5n3tLZzz1w==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/EvanHahn" + } + }, + "node_modules/help-me": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz", + "integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==", + "dev": true, + "license": "MIT" + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "license": "Apache-2.0", + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "license": "ISC" + }, + "node_modules/jose": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/jose/-/jose-5.10.0.tgz", + "integrity": "sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/magic-string": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.3.tgz", + "integrity": "sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz", + "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "license": "MIT" + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz", + "integrity": "sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "license": "MIT", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-exit-leak-free": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", + "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/on-finished": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz", + "integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/on-headers": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz", + "integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", "dependencies": { - "depd": "2.0.0", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "toidentifier": "1.0.1" - }, - "engines": { - "node": ">= 0.8" + "wrappy": "1" } }, - "node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "license": "MIT", "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" + "mimic-fn": "^2.1.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "node_modules/os-paths": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/os-paths/-/os-paths-4.4.0.tgz", + "integrity": "sha512-wrAwOeXp1RRMFfQY8Sy7VaGVmPocaLwSFOYCGKSyo8qmJ+/yaafCl5BCA1IQZWqFSRBrKDYFeR9d/VyQzfH/jg==", + "license": "MIT", "engines": { - "node": ">= 0.10" + "node": ">= 6.0" } }, - "node_modules/jake": { - "version": "10.8.5", - "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.5.tgz", - "integrity": "sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw==", + "node_modules/oxc-parser": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/oxc-parser/-/oxc-parser-0.152.0.tgz", + "integrity": "sha512-ZztsZgaCWmPeKYMdoTT5e0oV/oxD1NeLWNR3kAtr/G707cUPYaaozRlVDHLCGnszHJRszN9mJwmPNpqgwloC0A==", + "license": "MIT", "dependencies": { - "async": "^3.2.3", - "chalk": "^4.0.2", - "filelist": "^1.0.1", - "minimatch": "^3.0.4" - }, - "bin": { - "jake": "bin/cli.js" + "@oxc-project/types": "^0.152.0" }, "engines": { - "node": ">=10" + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/oxc-project" + }, + "optionalDependencies": { + "@oxc-parser/binding-android-arm-eabi": "0.152.0", + "@oxc-parser/binding-android-arm64": "0.152.0", + "@oxc-parser/binding-darwin-arm64": "0.152.0", + "@oxc-parser/binding-darwin-x64": "0.152.0", + "@oxc-parser/binding-freebsd-x64": "0.152.0", + "@oxc-parser/binding-linux-arm-gnueabihf": "0.152.0", + "@oxc-parser/binding-linux-arm-musleabihf": "0.152.0", + "@oxc-parser/binding-linux-arm64-gnu": "0.152.0", + "@oxc-parser/binding-linux-arm64-musl": "0.152.0", + "@oxc-parser/binding-linux-ppc64-gnu": "0.152.0", + "@oxc-parser/binding-linux-riscv64-gnu": "0.152.0", + "@oxc-parser/binding-linux-riscv64-musl": "0.152.0", + "@oxc-parser/binding-linux-s390x-gnu": "0.152.0", + "@oxc-parser/binding-linux-x64-gnu": "0.152.0", + "@oxc-parser/binding-linux-x64-musl": "0.152.0", + "@oxc-parser/binding-openharmony-arm64": "0.152.0", + "@oxc-parser/binding-win32-arm64-msvc": "0.152.0", + "@oxc-parser/binding-win32-ia32-msvc": "0.152.0", + "@oxc-parser/binding-win32-x64-msvc": "0.152.0" } }, - "node_modules/media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", "engines": { - "node": ">= 0.6" + "node": ">= 0.8" } }, - "node_modules/memory-cache": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/memory-cache/-/memory-cache-0.2.0.tgz", - "integrity": "sha512-OcjA+jzjOYzKmKS6IQVALHLVz+rNTMPoJvCztFaZxwG14wtAW7VRZjwTQu06vKCYOxh4jVnik7ya0SXTB0W+xA==" - }, - "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" - }, - "node_modules/methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "license": "MIT", "engines": { - "node": ">= 0.6" + "node": ">=8" } }, - "node_modules/mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "bin": { - "mime": "cli.js" + "node_modules/path-scurry": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", + "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" }, "engines": { - "node": ">=4" + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "engines": { - "node": ">= 0.6" + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "node_modules/pino": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-10.4.0.tgz", + "integrity": "sha512-bk1ZMTwG/Vymx+zPoa28MhNzucFvXJWp3csrSuxuHPSMeUettaCoQ5Jvg07mtC4JGNpcfTwz41oVCnNgBK9+vA==", + "license": "MIT", "dependencies": { - "mime-db": "1.52.0" + "@pinojs/redact": "^0.4.0", + "atomic-sleep": "^1.0.0", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^3.0.0", + "pino-std-serializers": "^7.0.0", + "process-warning": "^5.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^1.0.0", + "safe-stable-stringify": "^2.3.1", + "sonic-boom": "^4.0.1", + "thread-stream": "^4.0.0" }, - "engines": { - "node": ">= 0.6" + "bin": { + "pino": "bin.js" } }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "node_modules/pino-abstract-transport": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-3.0.0.tgz", + "integrity": "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==", + "license": "MIT", "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, - "node_modules/negotiator": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "engines": { - "node": ">= 0.6" + "split2": "^4.0.0" } }, - "node_modules/object-inspect": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", - "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", - "funding": { - "url": "https://github.com/sponsors/ljharb" + "node_modules/pino-http": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/pino-http/-/pino-http-11.0.0.tgz", + "integrity": "sha512-wqg5XIAGRRIWtTk8qPGxkbrfiwEWz1lgedVLvhLALudKXvg1/L2lTFgTGPJ4Z2e3qcRmxoFxDuSdMdMGNM6I1g==", + "license": "MIT", + "dependencies": { + "get-caller-file": "^2.0.5", + "pino": "^10.0.0", + "pino-std-serializers": "^7.0.0", + "process-warning": "^5.0.0" } }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "node_modules/pino-pretty": { + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-13.2.0.tgz", + "integrity": "sha512-jjghD1ML+Di/WxjJDz6j6Y4FT7hIXOlb8h27AyJ+ohtAXJXH4PS/xkv7si+RCCIW59HMgZsMKTDgzdr0RhuRrg==", + "dev": true, + "license": "MIT", "dependencies": { - "ee-first": "1.1.1" + "colorette": "^2.0.7", + "dateformat": "^4.6.3", + "fast-copy": "^4.0.0", + "fast-safe-stringify": "^2.1.1", + "help-me": "^5.0.0", + "joycon": "^3.1.1", + "minimist": "^1.2.6", + "on-exit-leak-free": "^2.1.2", + "pino-abstract-transport": "^3.0.0", + "pump": "^3.0.3", + "secure-json-parse": "^4.1.0", + "sonic-boom": "^5.0.0", + "strip-json-comments": "^5.0.3" }, - "engines": { - "node": ">= 0.8" + "bin": { + "pino-pretty": "bin.js" } }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "engines": { - "node": ">= 0.8" + "node_modules/pino-pretty/node_modules/sonic-boom": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-5.0.2.tgz", + "integrity": "sha512-/JEruzo6yhNVhsLblTRchgTQHIt7SsdJP0YyrfWaNKjIOQDfrdZv9gwYraYCAsmKV39/LAdV31FLL5NCDpoL/A==", + "dev": true, + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" } }, - "node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + "node_modules/pino-std-serializers": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz", + "integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==", + "license": "MIT" + }, + "node_modules/process-warning": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.1.1.tgz", + "integrity": "sha512-oCkNVj4OKnKEcocVBcDfiIugN1/cE6rgfT3nCtzeqZPA8+rIxMaQ0xXzIkGP8Gj2qUaP1UR7uhJ1VD8lUCpzCg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" }, "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz", + "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==", + "license": "MIT", "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" }, "engines": { "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + "node_modules/pump": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", + "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } }, "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.16.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.1.tgz", + "integrity": "sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==", + "license": "BSD-3-Clause", "dependencies": { - "side-channel": "^1.0.4" + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" }, "engines": { "node": ">=0.6" @@ -664,28 +1793,85 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", + "license": "MIT" + }, "node_modules/range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", + "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", + "license": "MIT", "engines": { "node": ">= 0.6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" }, "engines": { - "node": ">= 0.8" + "node": ">= 0.10" + } + }, + "node_modules/real-require": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-1.0.0.tgz", + "integrity": "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g==", + "license": "MIT" + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/router/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, + "node_modules/router/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -703,135 +1889,401 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/secure-json-parse": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-4.1.1.tgz", + "integrity": "sha512-lnd81MQEZKjhW/Gd2TQqdd4XP6QYNdDW/EP+I7nTrFHP9y2LmaGPIHk9xsnzcOiEr1c39c/e84xFgGviQKBTRw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" }, "node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", "dependencies": { - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "mime": "1.6.0", - "ms": "2.1.3", - "on-finished": "2.4.1", - "range-parser": "~1.2.1", - "statuses": "2.0.1" + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" }, "engines": { - "node": ">= 0.8.0" + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/send/node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/send/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/sentry": { + "version": "0.45.0", + "resolved": "https://registry.npmjs.org/sentry/-/sentry-0.45.0.tgz", + "integrity": "sha512-kgmEbLlC22lL7uneeUm9Sjz65rp5cvwYOMTxXbZCmBum4sbVre/lLT3zTV3kwXHJ9/BM8ZS0/GhZe9Cl1t6WyA==", + "license": "FSL-1.1-Apache-2.0", + "bin": { + "sentry": "dist/bin.cjs" + }, + "engines": { + "node": ">=20.0" + } }, "node_modules/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", "dependencies": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.18.0" + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" }, "engines": { - "node": ">= 0.8.0" + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "license": "MIT", + "engines": { + "node": ">=8" + } }, "node_modules/side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", "dependencies": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "license": "ISC" + }, + "node_modules/sonic-boom": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz", + "integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, "node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", "engines": { "node": ">= 0.8" } }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/strip-json-comments": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz", + "integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/thread-stream": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-4.2.0.tgz", + "integrity": "sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ==", + "license": "MIT", + "dependencies": { + "real-require": "^1.0.0" + }, + "engines": { + "node": ">=20" } }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", "engines": { "node": ">=0.6" } }, "node_modules/type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", + "license": "MIT", "dependencies": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" + "content-type": "^2.0.0", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" }, "engines": { - "node": ">= 0.6" + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", "engines": { "node": ">= 0.8" } }, - "node_modules/utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", - "engines": { - "node": ">= 0.4.0" - } - }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", "engines": { "node": ">= 0.8" } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, + "node_modules/xdg-app-paths": { + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/xdg-app-paths/-/xdg-app-paths-5.5.1.tgz", + "integrity": "sha512-hI3flOB4PLZIy5prbtTpirobtPE2ZtZ52szO+2mM9Efp6ErM398La+C1lIpNWDfNoQk+6Lsi6nMcCwVB7pxeMQ==", + "license": "MIT", + "dependencies": { + "os-paths": "^4.0.1", + "xdg-portable": "^7.2.0" + }, + "engines": { + "node": ">= 6.0" + } + }, + "node_modules/xdg-portable": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/xdg-portable/-/xdg-portable-7.3.0.tgz", + "integrity": "sha512-sqMMuL1rc0FmMBOzCpd0yuy9trqF2yTTVe+E9ogwCSWQCdDEtQUwrZPT6AxqtsFGRNxycgncbP/xmOOSPw5ZUw==", + "license": "MIT", + "dependencies": { + "os-paths": "^4.0.1" + }, + "engines": { + "node": ">= 6.0" + } + }, + "node_modules/zod": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.11.tgz", + "integrity": "sha512-WPsqwxITS2tzx1bzhIKsEs19ABD5vmCVa4xBo2tq/SrV4RNZtfws1EnCWQXM6yh8bD08a1idvkB5MZSBiZsjwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/package.json b/package.json index 3b2ef36f..5b2fd022 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,35 @@ { - "name": "my-spotify", - "version": "1.0.0", + "name": "selections", + "version": "2.0.0", + "description": "SoundSelections — a fast, responsive browser for Beere's curated TIDAL playlists.", + "private": true, + "type": "module", "main": "app.js", + "engines": { + "node": ">=22.12" + }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "start": "node app.js", + "dev": "node --watch-path=src --watch-path=views app.js", + "dev:mock": "TIDAL_MOCK=1 node --watch-path=src --watch-path=views app.js", + "tidal:login": "node scripts/tidal-login.js", + "check": "node scripts/check-syntax.js", + "test": "node --test --test-reporter=spec \"test/**/*.test.js\"" }, "keywords": [], - "author": "", - "license": "ISC", + "author": "Beere", + "license": "MIT", "dependencies": { - "axios": "^1.3.4", - "dotenv": "^16.0.3", - "ejs": "^3.1.9", - "express": "^4.18.2", - "memory-cache": "^0.2.0" + "@sentry/node": "^11.9.0", + "@vercel/functions": "^3.10.3", + "compression": "^1.8.2", + "ejs": "^7.0.2", + "express": "^5.3.0", + "helmet": "^8.3.0", + "pino": "^10.4.0", + "pino-http": "^11.0.0" }, - "description": "" + "devDependencies": { + "pino-pretty": "^13.2.0" + } } diff --git a/public/css/app.css b/public/css/app.css new file mode 100644 index 00000000..d8a16929 --- /dev/null +++ b/public/css/app.css @@ -0,0 +1,948 @@ +/* SoundSelections — one stylesheet, organised top-down: + fonts → tokens → base → layout → masthead/toolbar → filters → grid/cards + → states → dialog → toast → footer → utilities → motion preferences. */ + +/* Fonts ---------------------------------------------------------------- */ + +@font-face { + font-family: 'Outfit'; + font-style: normal; + font-weight: 100 900; + font-display: swap; + src: url('../fonts/outfit-latin-wght-normal.woff2') format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} + +@font-face { + font-family: 'Outfit'; + font-style: normal; + font-weight: 100 900; + font-display: swap; + src: url('../fonts/outfit-latin-ext-wght-normal.woff2') format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} + +/* Tokens --------------------------------------------------------------- */ + +:root { + color-scheme: dark; + + --black: #000; + --grey-900: #141414; + --grey-800: #1c1c1c; + --grey-700: #2a2a2a; + --grey-500: #9a9a9a; + --grey-300: #cbcbcb; + --white: #fff; + --blue-light: #8a8aff; + --blue: #0000bf; + --blue-dark: #000034; + --yellow: hsl(39 87% 50%); + --line: rgb(255 255 255 / 0.1); + + --gradient-blue: linear-gradient(0deg, #000 0%, #000060 50%, #0000bf 100%); + + --font: 'Outfit', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif; + + --radius-s: 0.25rem; + --radius-m: 0.5rem; + --radius-l: 0.875rem; + --radius-pill: 999px; + + --gutter: clamp(1rem, 4vw, 2.5rem); + --gap: clamp(0.75rem, 2vw, 1.5rem); + --max-width: 80rem; + --tap: 2.75rem; + + --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1); + --fast: 120ms; + --base: 200ms; + --slow: 320ms; +} + +/* Base ----------------------------------------------------------------- */ + +*, +*::before, +*::after { + box-sizing: border-box; +} + +html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; + scroll-padding-top: 6rem; +} + +body { + margin: 0; + min-height: 100dvh; + display: flex; + flex-direction: column; + background: var(--black); + color: var(--white); + font-family: var(--font); + font-size: 1rem; + font-weight: 300; + line-height: 1.5; + letter-spacing: 0.01em; +} + +h1, +h2, +p { + margin: 0; +} + +/* `hidden` must win over component display rules (e.g. inline-flex chips). */ +[hidden] { + display: none !important; +} + +img { + display: block; + max-width: 100%; +} + +button, +input, +select { + font: inherit; + color: inherit; + letter-spacing: inherit; +} + +a { + color: var(--grey-300); + text-underline-offset: 0.2em; + transition: color var(--fast) ease-out; +} + +a:hover { + color: var(--white); +} + +:focus-visible { + outline: 3px solid var(--yellow); + outline-offset: 2px; +} + +/* Layout --------------------------------------------------------------- */ + +.container { + width: 100%; + max-width: var(--max-width); + margin-inline: auto; + padding-inline: var(--gutter); +} + +main { + flex: 1; + padding-block: 1.25rem 3rem; +} + +main:focus { + outline: none; +} + +/* Masthead & toolbar ------------------------------------------------------ */ + +.masthead { + background: var(--gradient-blue); + padding-block: clamp(1.75rem, 6vw, 3.5rem) clamp(1rem, 3vw, 1.75rem); +} + +.masthead-inner { + display: flex; + align-items: center; + gap: clamp(0.75rem, 2vw, 1.25rem); +} + +.avatar { + flex: none; + width: clamp(3rem, 8vw, 4rem); + height: auto; + aspect-ratio: 1; + border-radius: 50%; + border: 1px solid var(--white); + object-fit: cover; +} + +.site-name { + font-size: clamp(1.75rem, 5vw, 3rem); + font-weight: 600; + line-height: 1.05; + letter-spacing: -0.02em; +} + +.tagline { + margin-top: 0.375rem; + max-width: 42rem; + color: var(--grey-300); + font-size: clamp(0.9375rem, 2vw, 1.0625rem); + text-wrap: pretty; +} + +.toolbar { + position: sticky; + top: 0; + z-index: 10; + padding-block: 0.75rem; + background: rgb(0 0 0 / 0.82); + border-bottom: 1px solid var(--line); + backdrop-filter: blur(14px) saturate(1.4); + -webkit-backdrop-filter: blur(14px) saturate(1.4); +} + +.filters { + display: flex; + gap: 0.75rem; + align-items: center; +} + +.search-input { + flex: 1; + min-width: 0; + min-height: var(--tap); + padding: 0.625rem 1rem; + background: var(--blue-dark); + border: 1px solid var(--blue); + border-radius: var(--radius-s); + font-size: clamp(1rem, 2.4vw, 1.25rem); + font-weight: 300; + transition: border-color var(--fast) ease-out, background-color var(--fast) ease-out; +} + +.search-input::placeholder { + color: var(--grey-500); + opacity: 1; +} + +.search-input:hover { + border-color: var(--blue-light); +} + +.search-input:focus { + border-color: var(--white); + background: var(--black); +} + +.sort { + display: flex; + align-items: center; + gap: 0.5rem; + font-size: 0.875rem; + color: var(--grey-500); +} + +.sort select { + min-height: var(--tap); + padding: 0.5rem 0.75rem; + background: var(--grey-800); + border: 1px solid var(--grey-700); + border-radius: var(--radius-s); + color: var(--white); + cursor: pointer; +} + +@media (max-width: 30rem) { + .sort-label { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + } +} + +/* Results, tags & notices --------------------------------------------------- */ + +.results-bar { + display: flex; + flex-wrap: wrap; + align-items: baseline; + gap: 0.25rem 1rem; + min-height: 1.75rem; + color: var(--grey-500); + font-size: 0.9375rem; +} + +.text-button { + min-height: var(--tap); + padding: 0; + background: none; + border: 0; + color: var(--grey-300); + text-decoration: underline; + text-underline-offset: 0.2em; + cursor: pointer; +} + +.text-button:hover { + color: var(--white); +} + +.tags { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; + margin-block: 0.75rem 1.5rem; +} + +@media (max-width: 40rem) { + /* One swipeable row on phones instead of a wall of chips. */ + .tags { + flex-wrap: nowrap; + overflow-x: auto; + margin-inline: calc(var(--gutter) * -1); + padding-inline: var(--gutter); + padding-block: 0.25rem; + scroll-padding-inline: var(--gutter); + scrollbar-width: none; + mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - 2.5rem), transparent); + } + + .tags::-webkit-scrollbar { + display: none; + } +} + +.tag-chip { + flex: none; + display: inline-flex; + align-items: center; + gap: 0.375rem; + min-height: 2.25rem; + padding: 0.25rem 0.875rem; + background: transparent; + border: 1px solid rgb(255 255 255 / 0.22); + border-radius: var(--radius-pill); + font-size: 0.875rem; + font-weight: 400; + white-space: nowrap; + cursor: pointer; + transition: background-color var(--fast) ease-out, border-color var(--fast) ease-out, color var(--fast) ease-out; +} + +.tag-chip:hover { + border-color: var(--white); +} + +.tag-chip[aria-pressed='true'] { + background: var(--white); + border-color: var(--white); + color: var(--black); + font-weight: 500; +} + +.tag-count { + color: var(--grey-500); + font-size: 0.75rem; +} + +.tag-chip[aria-pressed='true'] .tag-count { + color: var(--grey-700); +} + +.notice { + display: grid; + justify-items: start; + gap: 1rem; + margin-block: 1rem 2rem; + padding: 1.25rem 1.5rem; + background: var(--grey-800); + border: 1px solid var(--line); + border-left: 3px solid var(--yellow); + border-radius: var(--radius-m); + color: var(--grey-300); +} + +/* Grid & cards ------------------------------------------------------------ */ + +.grid { + display: grid; + /* Never fewer than two columns, so phones still show off the artwork. + CARD_IMAGE_SIZES in js/constants.js mirrors these widths. */ + grid-template-columns: repeat(auto-fill, minmax(min(13.5rem, calc((100% - var(--gap)) / 2)), 1fr)); + gap: clamp(1.5rem, 3vw, 2.5rem) var(--gap); + margin: 0; + padding: 0; + list-style: none; +} + +.card { + position: relative; + display: flex; + flex-direction: column; + gap: 0.375rem; + min-width: 0; +} + +.card-art { + position: relative; + aspect-ratio: 1; + margin-bottom: 0.375rem; + overflow: hidden; + border-radius: var(--radius-m); + background: var(--art, var(--grey-800)); + box-shadow: 0 0 0 1px rgb(255 255 255 / 0.06); + transition: transform var(--base) var(--ease-out), box-shadow var(--base) var(--ease-out); +} + +.card-art img, +.sheet-art img { + width: 100%; + height: 100%; + object-fit: cover; + transition: opacity var(--slow) ease-out; +} + +/* Artwork fades in over its palette colour once loaded. */ +:is(.card-art, .sheet-art) img.is-loading { + opacity: 0; +} + +:is(.card-art, .sheet-art) img:not([src]) { + visibility: hidden; +} + +/* Placeholder note for playlists without artwork (or whose artwork failed). */ +.card.no-art .card-art::after, +.sheet.no-art .sheet-art::after { + content: '♪'; + position: absolute; + inset: 0; + display: grid; + place-items: center; + color: rgb(255 255 255 / 0.4); + font-size: clamp(2.5rem, 8vw, 4rem); +} + +.card:hover .card-art { + transform: translateY(-4px); + box-shadow: 0 18px 36px -18px var(--art, var(--blue)), 0 0 0 1px rgb(255 255 255 / 0.12); +} + +.badge { + position: absolute; + top: 0.5rem; + left: 0.5rem; + padding: 0.125rem 0.5rem; + background: var(--yellow); + border-radius: var(--radius-pill); + color: var(--black); + font-size: 0.6875rem; + font-weight: 700; + letter-spacing: 0.08em; + text-transform: uppercase; +} + +.card-title { + font-size: 1rem; + font-weight: 600; + line-height: 1.3; + letter-spacing: 0; + overflow-wrap: anywhere; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + line-clamp: 2; + overflow: hidden; +} + +.card-link { + color: inherit; + text-decoration: none; +} + +/* The whole card is clickable; the tag chip sits above this overlay. */ +.card-link::after { + content: ''; + position: absolute; + inset: -0.25rem; + border-radius: var(--radius-m); +} + +.card-link:focus-visible { + outline: none; +} + +.card-link:focus-visible::after { + outline: 3px solid var(--yellow); + outline-offset: 2px; +} + +.card-meta { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.375rem 0.625rem; + color: var(--grey-500); + font-size: 0.8125rem; +} + +.card-meta .tag-chip { + position: relative; + z-index: 1; + min-height: 1.75rem; + max-width: 100%; + padding-inline: 0.625rem; + overflow: hidden; + text-overflow: ellipsis; + color: var(--grey-300); + font-size: 0.8125rem; +} + +.card-description { + color: var(--grey-500); + font-size: 0.8125rem; + line-height: 1.45; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + line-clamp: 2; + overflow: hidden; +} + +.card-description:empty { + display: none; +} + +@media (max-width: 30rem) { + .card-description { + display: none; + } +} + +/* Loading skeleton ----------------------------------------------------------- */ + +.card.is-skeleton .card-art, +.skeleton-line { + background: linear-gradient(90deg, var(--grey-800) 25%, var(--grey-700) 50%, var(--grey-800) 75%); + background-size: 200% 100%; + animation: shimmer 1.4s linear infinite; + box-shadow: none; +} + +.skeleton-line { + height: 0.875rem; + border-radius: var(--radius-s); +} + +.skeleton-line.short { + width: 55%; +} + +@keyframes shimmer { + to { + background-position: -200% 0; + } +} + +/* Buttons -------------------------------------------------------------------- */ + +.button { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 0.5rem; + min-height: var(--tap); + padding: 0.5rem 1.125rem; + background: transparent; + border: 1px solid var(--grey-300); + border-radius: var(--radius-s); + color: var(--grey-300); + font-size: 0.875rem; + font-weight: 500; + letter-spacing: 0.1em; + text-align: center; + text-decoration: none; + text-transform: uppercase; + cursor: pointer; + transition: color var(--fast) ease-out, border-color var(--fast) ease-out, background-color var(--fast) ease-out; +} + +.button:hover { + border-color: var(--white); + color: var(--white); +} + +.button-primary { + background: var(--white); + border-color: var(--white); + color: var(--black); +} + +.button-primary:hover { + background: var(--grey-300); + border-color: var(--grey-300); + color: var(--black); +} + +/* Playlist dialog -------------------------------------------------------------- */ + +.sheet { + width: min(100% - 2rem, 66rem); + max-width: none; + max-height: min(100% - 2rem, 50rem); + padding: 0; + overflow: auto; + overscroll-behavior: contain; + background: var(--grey-800); + border: 0; + border-radius: var(--radius-l); + box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.9), 0 0 0 1px var(--line); + color: var(--white); +} + +.sheet::backdrop { + background: rgb(0 0 0 / 0.65); + backdrop-filter: blur(6px); + -webkit-backdrop-filter: blur(6px); +} + +.sheet-layout { + position: relative; + display: grid; + grid-template-columns: minmax(0, 19rem) minmax(0, 1fr); + grid-template-rows: auto auto auto 1fr; + grid-template-areas: + 'art player' + 'head player' + 'desc player' + 'body player'; + gap: 1rem 2rem; + /* The top padding leaves room for the close button, clear of TIDAL's player. */ + padding: 3.5rem 2rem 2rem; +} + +.sheet-close { + position: absolute; + top: 0.5rem; + right: 0.5rem; + z-index: 2; + display: grid; + place-items: center; + width: var(--tap); + height: var(--tap); + padding: 0; + background: rgb(0 0 0 / 0.55); + border: 1px solid var(--line); + border-radius: 50%; + cursor: pointer; + transition: background-color var(--fast) ease-out; +} + +.sheet-close:hover { + background: var(--black); +} + +.sheet-art { + grid-area: art; + position: relative; + aspect-ratio: 1; + overflow: hidden; + border-radius: var(--radius-m); + background: var(--art, var(--grey-700)); + box-shadow: 0 24px 48px -24px var(--art, transparent); +} + +.sheet-head { + grid-area: head; + display: grid; + gap: 0.25rem; +} + +.sheet-tag { + color: var(--blue-light); + font-size: 0.8125rem; + font-weight: 500; + letter-spacing: 0.1em; + text-transform: uppercase; +} + +.sheet-title { + font-size: clamp(1.375rem, 3vw, 1.875rem); + font-weight: 600; + line-height: 1.15; + letter-spacing: -0.01em; + overflow-wrap: anywhere; + text-wrap: balance; +} + +.sheet-stats { + color: var(--grey-500); + font-size: 0.875rem; +} + +.sheet-body { + grid-area: body; + display: grid; + align-content: start; + gap: 1.25rem; +} + +.sheet-description { + grid-area: desc; + color: var(--grey-300); + white-space: pre-line; + text-wrap: pretty; +} + +.sheet-description:empty { + display: none; +} + +.sheet-actions { + display: flex; + flex-wrap: wrap; + gap: 0.75rem; +} + +.copy-status { + color: var(--grey-300); + font-size: 0.875rem; + overflow-wrap: anywhere; +} + +.copy-status:empty { + display: none; +} + +.sheet-player { + grid-area: player; + position: relative; + min-height: 30rem; + overflow: hidden; + border-radius: var(--radius-m); + background: var(--grey-900); +} + +.sheet-player iframe { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + border: 0; + opacity: 0; + transition: opacity var(--slow) ease-out; +} + +.sheet-player[data-state='loaded'] iframe { + opacity: 1; +} + +/* Spinner while the embed loads. */ +.sheet-player[data-state='loading']::before { + content: ''; + position: absolute; + top: 50%; + left: 50%; + width: 2rem; + height: 2rem; + margin: -1rem 0 0 -1rem; + border: 2px solid var(--grey-700); + border-top-color: var(--white); + border-radius: 50%; + animation: spin 0.8s linear infinite; +} + +.player-message { + position: absolute; + inset: auto 1rem 1rem; + padding: 0.75rem 1rem; + background: var(--black); + border-radius: var(--radius-s); + color: var(--grey-300); + font-size: 0.875rem; +} + +@keyframes spin { + to { + transform: rotate(1turn); + } +} + +@media (max-width: 52rem) { + /* Phones and small tablets: full-screen sheet, compact header, player up top. */ + .sheet { + width: 100%; + max-height: 100%; + height: 100%; + margin: 0; + border-radius: 0; + } + + /* Actions before the player: on a phone, "Open in TIDAL" is the main event. */ + .sheet-layout { + min-height: 100%; + grid-template-columns: 5.5rem minmax(0, 1fr); + grid-template-rows: auto auto auto auto; + grid-template-areas: + 'art head' + 'body body' + 'player player' + 'desc desc'; + align-items: center; + padding: 1rem var(--gutter) max(1.5rem, env(safe-area-inset-bottom)); + } + + .sheet-head { + padding-right: 3rem; + } + + .sheet-player { + min-height: 0; + height: min(62dvh, 32rem); + } +} + +/* Dialog motion (entry via @starting-style; exit needs overlay + discrete display). */ +.sheet, +.sheet::backdrop { + transition-property: opacity, transform, display, overlay; + transition-duration: var(--slow); + transition-timing-function: var(--ease-out); + transition-behavior: allow-discrete; +} + +.sheet { + opacity: 0; + transform: translateY(1.5rem) scale(0.98); +} + +.sheet::backdrop { + opacity: 0; +} + +:is(.sheet[open]):where(:not([data-closing])) { + opacity: 1; + transform: none; + + &::backdrop { + opacity: 1; + } + + @starting-style { + opacity: 0; + transform: translateY(1.5rem) scale(0.98); + + &::backdrop { + opacity: 0; + } + } +} + +/* Toast ------------------------------------------------------------------------ */ + +.toast { + position: fixed; + bottom: max(1rem, env(safe-area-inset-bottom)); + left: 50%; + z-index: 20; + max-width: calc(100% - 2rem); + padding: 0.75rem 1.25rem; + background: var(--white); + border-radius: var(--radius-pill); + box-shadow: 0 12px 32px -8px rgb(0 0 0 / 0.7); + color: var(--black); + font-size: 0.9375rem; + font-weight: 500; + transform: translateX(-50%); + transition: opacity var(--base) ease-out, translate var(--base) var(--ease-out); + + @starting-style { + opacity: 0; + translate: 0 1rem; + } +} + +/* Footer ------------------------------------------------------------------------ */ + +.site-footer { + padding-block: 1.5rem; + border-top: 1px solid var(--line); + color: var(--grey-500); + font-size: 0.875rem; +} + +.footer-inner { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 1rem 1.5rem; +} + +/* Error page ---------------------------------------------------------------------- */ + +.error-page { + display: grid; + gap: 1.25rem; + justify-items: start; + padding-block: 4rem; +} + +.error-reference { + color: var(--grey-500); + font-size: 0.875rem; +} + +/* Utilities ------------------------------------------------------------------------ */ + +.visually-hidden { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border: 0; +} + +.skip-link { + position: absolute; + top: 0.5rem; + left: 0.5rem; + z-index: 30; + padding: 0.75rem 1rem; + background: var(--white); + color: var(--black); + font-weight: 600; + transform: translateY(-200%); +} + +.skip-link:focus { + transform: none; +} + +/* Motion preferences ------------------------------------------------------------- */ + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + scroll-behavior: auto !important; + } + + .card:hover .card-art { + transform: none; + } + + .sheet, + .sheet::backdrop { + transition-duration: 0.1s; + } + + .sheet, + :is(.sheet[open]):where(:not([data-closing])) { + transform: none; + + @starting-style { + transform: none; + } + } +} diff --git a/public/css/component.css b/public/css/component.css deleted file mode 100644 index 7bf5c405..00000000 --- a/public/css/component.css +++ /dev/null @@ -1,227 +0,0 @@ -nav { - /* background-color: var(--swatch-blue); */ - background: linear-gradient(0deg, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 96, 1) 50%, rgba(0, 0, 191, 1) 100%); -} - -footer { - background-color: var(--swatch-black); - padding-top: var(--size-small); - padding-bottom: var(--size-small); -} - -/* Link */ - -a { - font-weight: var(--font-weight-regular); - color: var(--swatch-lightest-grey); - cursor: pointer; - border-color: transparent; - border-style: solid; - border-width: 0; - border-radius: var(--size-small-xx); - transition: all var(--transition-base) ease-in-out; -} - -a:hover, -a:focus { - color: var(--swatch-white); - transition: all var(--transition-fast) ease-in-out; -} - -/* button */ - -.button { - padding: var(--size-small-x) var(--size-base); - background-color: transparent; - border-color: var(--swatch-lightest-grey); - color: var(--swatch-lightest-grey); - border-style: solid; - border-width: 1px; - border-radius: var(--size-small-xx); - box-sizing: border-box; - font-size: var(--font-size-base); - line-height: var(--font-height-base); - font-weight: var(--font-weight-medium); - letter-spacing: .1em; - text-align: center; - text-transform: uppercase; - text-decoration: none; - transition: all var(--transition-base) ease-in-out; -} - -.button:hover, -.button:focus { - color: var(--swatch-white); - border-color: var(--swatch-white); - transition: all var(--transition-fast) ease-in-out; -} - -/* Close Button */ - -.close-overlay { - position: absolute; - top: var(--size-large-xx); - right: var(--size-large-xx); - font-size: var(--font-size-playlist); - line-height: var(--font-height-playlist); - font-weight: var(--font-weight-regular); - cursor: pointer; - border-radius: 50%; - width: var(--size-large-xxx); - height: var(--size-large-xxx); - display: flex; - align-content: center; - justify-content: center; - align-items: center; - transform: scale(1); - -moz-transform: scale(1); - -webkit-transform: scale(1); - -o-transform: scale(1); - -ms-transform: scale(1); - transition: transform var(--transition-fast) ease-in-out; -} - -.close-overlay:hover { - background-color: var(--swatch-black); - transform: scale(1.025); - -moz-transform: scale(1.025); - -webkit-transform: scale(1.025); - -o-transform: scale(1.025); - -ms-transform: scale(1.025); - transition: transform var(--transition-base) ease-in-out; -} - -/* Media */ - -.avatar { - border-radius: 50%; - width: 2rem; - height: auto; - border: 1px solid var(--swatch-white); - box-sizing: border-box; -} - -/* Search */ - -#search::after { - content: '⮑ ENTER'; - position: absolute; - right: 0; - transform: translatex(-7rem); - pointer-events: none; - font-size: var(--font-size-base); - font-weight: var(--font-weight-regular); - color: var(--swatch-lightest-grey); - display: flex; -} - -input::placeholder { - color: var(--swatch-light-grey); - font-family: var(--type-sans); -} - -#search { - display: flex; - flex-grow: 1; - padding: var(--size-base) var(--size-large-x); - background-color: var(--swatch-blue-dark); - color: var(--swatch-white); - border: 1px solid var(--swatch-blue); - font-size: var(--font-size-statement); - line-height: var(--font-height-statement); - font-weight: var(--font-weight-light); - border-radius: var(--size-small-xx); - transition: background-color var(--transition-fast) ease-in; -} - -#search:hover { - color: var(--swatch-white); - background-color: var(--swatch-black); - border: 1px solid var(--swatch-blue-light); -} - -#search:focus { - border: 1px solid var(--swatch-white); - /* background-color: var(--swatch-black); */ -} - -/* Counter */ - -#playlist-counter { - display: inline-block; -} - -/* Playlist Item */ - -.playlist { - cursor: pointer; - padding-bottom: var(--size-small); - border-radius: var(--size-small-x); - transform: scale(1); - -moz-transform: scale(1); - -webkit-transform: scale(1); - -o-transform: scale(1); - -ms-transform: scale(1); - transition: transform var(--transition-fast) ease-in-out; -} - -.playlist:hover { - /* cursor: pointer; */ - transform: scale(1.025); - -moz-transform: scale(1.025); - -webkit-transform: scale(1.025); - -o-transform: scale(1.025); - -ms-transform: scale(1.025); - transition: transform var(--transition-base) ease-in-out; -} - -.playlist:focus { - outline-offset: 0.5rem; -} - -.playlist-img { - width: 100%; - height: auto; - margin-bottom: var(--size-small); - border-radius: var(--size-small-x); -} - -/* Loading */ - -.loading-message { - display: none; - padding: var(--size-base) var(--size-large-x); - background-color: var(--swatch-dark-grey); - color: var(--swatch-white); - font-size: var(--font-size-base); - line-height: var(--font-height-base); - border-radius: var(--size-small-xx); -} - -/* Tooltip */ - -.tooltip { - position: relative; - display: inline-block; - cursor: pointer; -} - -.tooltip-container { - position: absolute; - font-size: var(--font-size-base); - line-height: var(--font-height-base); - background-color: var(--swatch-black); - color: var(--swatch-white); - padding: var(--size-small-x); - border-radius: var(--size-small-x); - white-space: nowrap; - z-index: 9999; - visibility: hidden; - opacity: 0; - transition: opacity 0.2s; -} - -.tooltip-container.visible { - visibility: visible; - opacity: 1; -} \ No newline at end of file diff --git a/public/css/global.css b/public/css/global.css deleted file mode 100644 index 9a392a1a..00000000 --- a/public/css/global.css +++ /dev/null @@ -1,40 +0,0 @@ -.hidden { - visibility: hidden; -} - -html { - font-size: 15px; -} - -body { - font-family: var(--type-sans); - background-color: var(--swatch-black); - color: var(--swatch-white); - font-size: var(--font-size-base); - line-height: var(--font-height-base); - font-weight: var(--font-weight-extralight); - letter-spacing: 0.5px; - margin: 0; - margin-block-start: 0; - margin-block-end: 0; - margin-inline-start: 0; - margin-inline-end: 0; - padding: 0; -} - -:focus { - outline: 2px solid var(--swatch-yellow); - outline-offset: 2px; -} - -.primary { - color: var(--swatch-white); -} - -.mid { - color: var(--swatch-lightest-grey); -} - -.secondary { - color: var(--swatch-light-grey); -} \ No newline at end of file diff --git a/public/css/layout.css b/public/css/layout.css deleted file mode 100644 index 2f3f5278..00000000 --- a/public/css/layout.css +++ /dev/null @@ -1,185 +0,0 @@ -/* Display */ - -.flex { - display: flex; -} - -.grid { - display: grid; -} - -/* Columns */ - -.lay--column { - flex-direction: column; -} - -.lay--row { - flex-direction: row; -} - -/* Gap */ - -.lay--gap-small-xx { - gap: var(--size-small-xx); -} - -.lay--gap-small-x { - gap: var(--size-small-x); -} - -.lay--gap-small { - gap: var(--size-small); -} - -.lay--gap { - gap: var(--size-base); -} - -.lay--gap-large { - gap: var(--size-large); -} - -.lay--gap-large-xx { - gap: var(--size-large-xx); -} - -/* Padding */ - -.lay--pad-small { - padding: var(--size-small); -} - -.lay--pad { - padding: var(--size-base); -} - -.lay--pad-large { - padding: var(--size-large); -} - -/* Justify */ - -.lay--justify-center { - justify-content: center; -} - -.lay--justify-left { - justify-content: left; -} - -.lay--justify-right { - justify-content: right; -} - -/* Align Items */ - -.lay--align-stretch { - align-items: stretch -} - -.lay--align-flex { - align-items: flex-start; -} - -.lay--align-center { - align-items: center; -} - -/* Width */ - -.width-control { - width: 100%; - max-width: 1280px; -} - -/* [!] Add responsive here! */ - -/* OLD ——————————————————————————————————— */ - - -nav { - position: sticky; - top: 0px; - padding-top: var(--size-base); - padding-bottom: var(--size-base); - z-index: 2500; -} - -footer { - position: sticky; - bottom: 0px; -} - -/* PLAYLISTS */ - -#playlists-container { - grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); -} - -@media (max-width: 991px) { - #playlists-container { - grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); - } -} - -@media (max-width: 768px) { - #playlists-container { - grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); - } -} - -@media (max-width: 478px) { - #playlists-container { - grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); - } -} - -/* Overlay */ - -.overlay { - background-color: rgba(0, 0, 0, 0.25); - box-sizing: border-box; - display: flex; - flex-direction: column; - height: 100vh; - left: 0; - /* padding: var(--size-large-x); */ - position: fixed; - top: 0; - width: 100vw; - z-index: 5000; -} - -.overlay-content { - flex: auto; - justify-content: flex-start; - background-color: var(--swatch-dark-grey); - border-radius: var(--size-small); - gap: var(--size-small-xx); - width: auto; - height: auto; - padding: var(--size-large-xxxxxx); - margin: var(--size-large-xxxxxx); - position: relative; -} - -/* Spotify Player */ - -.overlay-player-wrapper { - position: relative; - width: 100%; - height: 30rem; - margin-top: var(--size-base); - left: 0; - display: flex; -} - -#spotify-player { - position: absolute; - width: 100%; - height: 100%; - border: 0; - top: 0; - left: 0; -} \ No newline at end of file diff --git a/public/css/reset.css b/public/css/reset.css deleted file mode 100644 index e69de29b..00000000 diff --git a/public/css/tokens.css b/public/css/tokens.css deleted file mode 100644 index 70b5a01b..00000000 --- a/public/css/tokens.css +++ /dev/null @@ -1,74 +0,0 @@ -:root { - /* Color palette */ - --swatch-black: #000000; - --swatch-dark-grey: #1c1c1c; - --swatch-light-grey: #9a9a9a; - --swatch-lightest-grey: #cbcbcb; - --swatch-blue-light: #8a8aff; - --swatch-blue: #0000bf; - --swatch-blue-dark: #000034; - --swatch-cyan: #00d5ff; - --swatch-yellow: hsl(39, 87%, 50%); - --swatch-white: #FFFFFF; - - /* Gradients */ - --gradient-blue: linear-gradient (0deg, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 96, 1) 50%, rgba(0, 0, 191, 1) 100%); - - /* Typography */ - --type-sans: 'Outfit', 'Arial', sans-serif; - --font-weight-thin: 100; - --font-weight-extralight: 200; - --font-weight-light: 300; - --font-weight-regular: 400; - --font-weight-medium: 500; - --font-weight-semibold: 600; - --font-weight-bold: 700; - --font-weight-extrabold: 800; - --font-weight-black: 900; - - --size-small-1px: 1px; - --size-small-xxx: 0.125rem; - --size-small-xx: 0.25rem; - --size-small-x: 0.5rem; - --size-small: 0.75rem; - --size-base: 1rem; - --size-large: 1.25rem; - --size-large-x: 1.5rem; - --size-large-xx: 2rem; - --size-large-xxx: 2.5rem; - --size-large-xxxx: 3rem; - --size-large-xxxxx: 3.5rem; - --size-large-xxxxxx: 4rem; - --size-large-xxxxxxxx: 5.5rem; - --size-large-xxxxxxxxx: 6rem; - - --font-size-context: var(--size-small); - --font-size-button: var(--size-small); - --font-size-base: var(--size-base); - --font-size-statement: var(--size-large); - --font-size-brand: var(--size-large-x); - --font-size-playlist: var(--size-large-xx); - --font-size-app: var(--size-large-xxxxxxxxx); - - --font-height-context: var(--size-large); - --font-height-app: var(--size-large); - --font-height-base: var(--size-large); - --font-height-statement: var(--size-large-x); - --font-height-brand: var(--size-large-x); - --font-height-playlist: var(--size-large-xxx); - --font-height-app: var(--size-large-xxxxxxxxx); - - /* Transition */ - --transition-fast: 50ms; - --transition-base: 150ms; - --transition-slow: 300ms; - - - /* Breakpoints */ - @media (max-width: 991px) {} - - @media (max-width: 768px) {} - - @media (max-width: 478px) {} - -} \ No newline at end of file diff --git a/public/css/typography.css b/public/css/typography.css deleted file mode 100644 index 0af33935..00000000 --- a/public/css/typography.css +++ /dev/null @@ -1,57 +0,0 @@ -h1, -h2, -h3, -p { - display: block; - margin: 0; - padding: 0; - letter-spacing: 0; - margin-block-start: 0; - margin-block-end: 0; - margin-inline-start: 0; - margin-inline-end: 0; -} - -.text-name-site { - font-size: var(--font-size-brand); - line-height: var(--font-height-brand); - font-weight: var(--font-weight-medium); -} - -.text-name-playlist { - font-weight: var(--font-weight-semibold); - font-size: var(--font-size-base); - line-height: var(--font-height-base); -} - -.text-desc-playlist { - font-weight: var(--font-weight-extralight); - font-size: var(--font-size-base); - line-height: var(--font-height-base); - letter-spacing: 0.2px; -} - -.clamp-1 { - overflow: hidden; - display: -webkit-box; - -webkit-line-clamp: 1; - -webkit-box-orient: vertical; -} - -.clamp-2 { - overflow: hidden; - display: -webkit-box; - -webkit-line-clamp: 2; - -webkit-box-orient: vertical; -} - -.clamp-2 { - overflow: hidden; - display: -webkit-box; - -webkit-line-clamp: 3; - -webkit-box-orient: vertical; -} - -.uppercase { - text-transform: uppercase; -} \ No newline at end of file diff --git a/public/fonts/OFL.txt b/public/fonts/OFL.txt new file mode 100644 index 00000000..c8d1ebad --- /dev/null +++ b/public/fonts/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2021 The Outfit Project Authors (https://github.com/Outfitio/Outfit-Fonts) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/public/fonts/outfit-latin-ext-wght-normal.woff2 b/public/fonts/outfit-latin-ext-wght-normal.woff2 new file mode 100644 index 00000000..c54ceec8 Binary files /dev/null and b/public/fonts/outfit-latin-ext-wght-normal.woff2 differ diff --git a/public/fonts/outfit-latin-wght-normal.woff2 b/public/fonts/outfit-latin-wght-normal.woff2 new file mode 100644 index 00000000..85e3332e Binary files /dev/null and b/public/fonts/outfit-latin-wght-normal.woff2 differ diff --git a/public/js/api.js b/public/js/api.js new file mode 100644 index 00000000..6fefa69e --- /dev/null +++ b/public/js/api.js @@ -0,0 +1,73 @@ +// Talking to our own server. Every failure becomes an ApiError with a `code` +// the UI can explain to people, and the server's request id for support. + +export class ApiError extends Error { + constructor(message, { status = 0, code = 'UNKNOWN', requestId, retryAfter, cause } = {}) { + super(message, { cause }); + this.name = 'ApiError'; + this.status = status; + this.code = code; + this.requestId = requestId; + this.retryAfter = retryAfter; + } + + get isOffline() { + return this.code === 'NETWORK' && navigator.onLine === false; + } +} + +const timeoutSignal = (ms) => (typeof AbortSignal.timeout === 'function' ? AbortSignal.timeout(ms) : undefined); + +/** Resolves a fetch() promise into { status, data }, or throws an ApiError. */ +export async function readJson(responsePromise) { + let res; + try { + res = await responsePromise; + } catch (cause) { + const timedOut = cause?.name === 'TimeoutError'; + throw new ApiError(timedOut ? 'The request took too long.' : 'Could not reach the server.', { + code: timedOut ? 'TIMEOUT' : 'NETWORK', + cause, + }); + } + + if (res.status === 304) return { status: 304 }; + + let body = null; + try { + body = await res.json(); + } catch (cause) { + if (res.ok) throw new ApiError('The server sent a response we could not read.', { status: res.status, code: 'BAD_RESPONSE', cause }); + } + + if (!res.ok) { + throw new ApiError(body?.error?.message || `Request failed (${res.status}).`, { + status: res.status, + code: body?.error?.code || `HTTP_${res.status}`, + requestId: body?.error?.requestId || res.headers.get('x-request-id') || undefined, + retryAfter: Number(res.headers.get('retry-after')) || undefined, + }); + } + return { status: res.status, data: body }; +} + +// 503 means "the server has no playlists yet"; the caller waits Retry-After instead. +const isRetryable = (error) => ['NETWORK', 'TIMEOUT', 'BAD_RESPONSE'].includes(error.code) || (error.status >= 500 && error.status !== 503); + +/** GET with a timeout, an optional ETag for a conditional request, and one retry on transient failures. */ +export async function getJson(url, { etag, timeoutMs = 15_000, retries = 1 } = {}) { + for (let attempt = 0; ; attempt++) { + try { + return await readJson( + fetch(url, { + headers: etag ? { 'If-None-Match': `"${etag}"` } : {}, + cache: 'no-store', + signal: timeoutSignal(timeoutMs), + }), + ); + } catch (error) { + if (attempt >= retries || !isRetryable(error)) throw error; + await new Promise((resolve) => setTimeout(resolve, 800 * (attempt + 1))); + } + } +} diff --git a/public/js/app.js b/public/js/app.js deleted file mode 100644 index 9c1458f4..00000000 --- a/public/js/app.js +++ /dev/null @@ -1,256 +0,0 @@ -const userId = '111112791'; -const playlistsContainer = document.getElementById('playlists-container'); -const searchInput = document.getElementById('search'); -const loadingMessage = document.getElementById('loading-message'); -const resetButton = document.getElementById('reset-button'); -const openWebButton = document.getElementById('open-web'); -const copyUrlButton = document.getElementById('copy-url'); - -let allFetchedPlaylists = []; -let searchQuery = ''; - -const toggleLoadingMessage = (show) => { - loadingMessage.style.display = show ? 'block' : 'none'; -}; - -const updateResetButton = (search) => { - resetButton.style.display = search !== '' ? 'inline-block' : 'none'; -}; - -const fetchAllPlaylists = async (userId, offset = 0, fetchedPlaylists = []) => { - try { - const response = await fetch(`/playlists/${userId}?offset=${offset}`); - if (!response.ok) { - const errorDetails = await response.json(); - console.error('Error fetching playlists:', errorDetails); - return []; - } - - const newPlaylists = await response.json(); - console.log('Received playlists:', newPlaylists); - - fetchedPlaylists = fetchedPlaylists.concat(newPlaylists.items); - - if (newPlaylists.items.length === 50) { - return await fetchAllPlaylists(userId, offset + 50, - fetchedPlaylists); - } - - return fetchedPlaylists; - } catch (error) { - console.error('Error fetching playlists:', error); - return []; - } -}; - -const fetchPlaylists = async (search = '') => { - toggleLoadingMessage(true); - - try { - if (allFetchedPlaylists.length === 0) { - const cacheKey = `playlists-${userId}`; - const cachedPlaylists = localStorage.getItem(cacheKey); - - if (cachedPlaylists) { - console.log('Using cached playlists'); - allFetchedPlaylists = JSON.parse(cachedPlaylists); - } else { - allFetchedPlaylists = await fetchAllPlaylists(userId); - localStorage.setItem(cacheKey, JSON.stringify(allFetchedPlaylists)); - } - } - - const searchLowerCase = search.toLowerCase(); - - const filteredPlaylists = allFetchedPlaylists.filter((playlist) => - playlist.name.toLowerCase().includes(searchLowerCase) || - (playlist.description && playlist.description.toLowerCase().includes(searchLowerCase)) - ); - displayPlaylists(filteredPlaylists); - updateResetButton(search); - } catch (error) { - console.error(error); - } finally { - toggleLoadingMessage(false); - } -}; - -const handleArrowKeys = (event) => { - const focusedElement = document.activeElement; - const gridItems = Array.from(playlistsContainer.children); - const currentIndex = gridItems.indexOf(focusedElement); - - let nextIndex; - switch (event.key) { - case 'ArrowUp': - nextIndex = currentIndex - 4; // Adjust this value based on your grid layout - break; - case 'ArrowDown': - nextIndex = currentIndex + 4; // Adjust this value based on your grid layout - break; - case 'ArrowLeft': - nextIndex = currentIndex - 1; - break; - case 'ArrowRight': - nextIndex = currentIndex + 1; - break; - default: - return; - } - - if (nextIndex >= 0 && nextIndex < gridItems.length) { - gridItems[nextIndex].focus(); - } - - event.preventDefault(); // Prevent default scrolling behavior -}; - -const displayPlaylists = (playlists) => { - while (playlistsContainer.firstChild) { - playlistsContainer.removeChild(playlistsContainer.firstChild); - } - - playlists.sort((a, b) => a.name.localeCompare(b.name)); - - const counter = document.getElementById('playlist-counter'); - counter.textContent = `Showing ${playlists.length} playlists`; - - playlists.forEach((playlist, index) => { - const playlistElement = document.createElement('article'); - playlistElement.className = 'playlist flex lay--column lay--gap-small-xx'; - // playlistElement.tabIndex = index === 0 ? 0 : -1; // Set tabindex here - playlistElement.innerHTML = ` - ${playlist.name} cover art -

${playlist.name}

-
-

${(playlist.tracks?.total || 0)} songs

-

|

-

${(playlist.followers?.total || 0)} followers

-
-

${playlist.description || ''}

- `; - - playlistElement.addEventListener('keydown', handleArrowKeys); // Attach event listener for keyboard navigation - - playlistsContainer.appendChild(playlistElement); - - const coverArt = playlistElement.querySelector('.playlist-img'); - coverArt.addEventListener('click', (event) => { - event.stopPropagation(); - const overlay = document.getElementById('overlay-background'); - const player = document.getElementById('spotify-player'); - const overlayTitle = document.getElementById('overlay-playlist-title'); - const overlayTracks = document.getElementById('overlay-playlist-tracks'); - const overlayFollowers = document.getElementById('overlay-playlist-followers'); - const overlayDescription = document.getElementById('overlay-playlist-description'); - - player.src = `https://open.spotify.com/embed/playlist/${playlist.id}`; - overlayTitle.textContent = playlist.name; - overlayTracks.textContent = `${playlist.tracks.total} songs`; - overlayFollowers.textContent = `${playlist.followers.total} followers`; - overlayDescription.textContent = playlist.description || ''; - openWebButton.setAttribute('data-playlist-id', playlist.id); - overlay.classList.remove('hidden'); - }); - }); -}; - -const closeOverlay = document.getElementById('close-overlay'); -closeOverlay.addEventListener('click', () => { - const overlay = document.getElementById('overlay-background'); - overlay.classList.add('hidden'); -}); - -const overlay = document.getElementById('overlay-background'); -overlay.addEventListener('click', (event) => { - event.stopPropagation(); -}); - -const overlayBackground = document.getElementById('overlay-background'); -overlayBackground.addEventListener('click', (event) => { - if (event.target === event.currentTarget) { - overlayBackground.classList.add('hidden'); - } -}); - -const searchPlaylists = (query) => { - playlistsContainer.innerHTML = ''; - searchQuery = query; - fetchPlaylists(query); -}; - -searchInput.addEventListener('keydown', (event) => { - if (event.key === 'Enter') { - searchPlaylists(event.target.value); - } -}); - -resetButton.addEventListener('click', () => { - searchInput.value = ''; - resetButton.style.display = 'none'; - fetchPlaylists(); -}); - -let isLoading = false; - -window.addEventListener('scroll', async () => { - if (isLoading || (window.innerHeight + window.scrollY) < document.body.offsetHeight - 500) { - return; - } - - isLoading = true; - const currentPlaylistsCount = playlistsContainer.childElementCount; - await fetchPlaylists(searchQuery, currentPlaylistsCount); - isLoading = false; -}); - -openWebButton.addEventListener('click', () => { - const playlistId = openWebButton.getAttribute('data-playlist-id'); - const webUrl = `https://open.spotify.com/playlist/${playlistId}`; - window.open(webUrl, '_blank'); -}); - -copyUrlButton.addEventListener('click', () => { - const player = document.getElementById('spotify-player'); - const textarea = document.createElement('textarea'); - textarea.value = player.src; - document.body.appendChild(textarea); - textarea.select(); - document.execCommand('copy'); - document.body.removeChild(textarea); - alert('Playlist URL copied to clipboard'); -}); - -const tooltipElements = document.querySelectorAll('.tooltip'); -const tooltipContainer = document.getElementById('tooltip'); - -tooltipElements.forEach((element) => { - element.addEventListener('mouseover', (event) => { - tooltipContainer.textContent = event.target.getAttribute('data-tooltip'); - tooltipContainer.classList.add('visible'); - }); - - element.addEventListener('mousemove', (event) => { - tooltipContainer.style.left = event.pageX + 10 + 'px'; - tooltipContainer.style.top = event.pageY + 10 + 'px'; - }); - - element.addEventListener('mouseout', () => { - tooltipContainer.classList.remove('visible'); - }); -}); - -const genreLinks = document.querySelectorAll('.genre-link'); - -genreLinks.forEach(link => { - link.addEventListener('click', (event) => { - event.preventDefault(); - const genre = event.target.getAttribute('data-genre'); - const searchInput = document.getElementById('search'); - searchInput.value = genre; - searchPlaylists(genre); - }); -}); - -fetchPlaylists(); - diff --git a/public/js/constants.js b/public/js/constants.js new file mode 100644 index 00000000..3621e240 --- /dev/null +++ b/public/js/constants.js @@ -0,0 +1,20 @@ +// Shared by the browser and the server (which uses CARD_IMAGE_SIZES to preload +// the first artwork). Keep this file free of DOM access. + +/** localStorage keys. Bump the version when the cached record shape changes. */ +export const CACHE_KEY = 'selections:v1'; +export const CACHE_ETAG_KEY = 'selections:v1:etag'; + +/** Approximate rendered width of a grid card's artwork; mirrors the grid in app.css. */ +export const CARD_IMAGE_SIZES = '(min-width: 80rem) 14rem, (min-width: 40rem) 30vw, 50vw'; + +/** Cards in the first rows load eagerly; the rest are lazy-loaded as you scroll. */ +export const EAGER_CARD_COUNT = 6; + +/** Playlists created within this many days get a "New" badge. */ +export const NEW_PLAYLIST_DAYS = 21; + +export const embedUrl = (id) => `https://embed.tidal.com/playlists/${encodeURIComponent(id)}`; + +/** `srcset` value from a record's artwork sources. */ +export const srcsetFor = (art) => art?.sources?.map(([url, width]) => `${url} ${width}w`).join(', ') ?? ''; diff --git a/public/js/dialog.js b/public/js/dialog.js new file mode 100644 index 00000000..9c0b03e9 --- /dev/null +++ b/public/js/dialog.js @@ -0,0 +1,198 @@ +// The playlist dialog: artwork, details, TIDAL player, and open/copy actions. +// A native modal provides the focus trap, Esc to close, an inert +// background and focus restoration; this module adds the rest. + +import { embedUrl } from './constants.js'; +import { formatDate, formatDuration, formatFollowers, formatTracks, joinStats } from './format.js'; +import { setArtwork } from './grid.js'; +import { reportError } from './report.js'; + +const PLAYER_SLOW_MS = 12_000; +const DIALOG_ART_SIZES = '(min-width: 52rem) 19rem, 5.5rem'; + +// --- Exit animations where the browser can't animate leaving the top layer --- + +let displayTransitionSupport; +function canTransitionDisplay() { + if (displayTransitionSupport !== undefined) return displayTransitionSupport; + if (!window.CSS?.supports?.('transition-behavior', 'allow-discrete')) return (displayTransitionSupport = false); + // Firefox parses allow-discrete without transitioning display, so probe for real. + const probe = document.createElement('div'); + probe.style.cssText = 'transition: display 1s allow-discrete !important; display: block;'; + document.body.append(probe); + getComputedStyle(probe).display; + probe.style.display = 'none'; + displayTransitionSupport = getComputedStyle(probe).display === 'block'; + probe.remove(); + return displayTransitionSupport; +} + +const supportsTopLayerExit = () => Boolean(window.CSS?.supports?.('overlay', 'auto')) && canTransitionDisplay(); +const prefersReducedMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches; + +async function closeTopLayer(dialog) { + if (!dialog.open) return; + if (!supportsTopLayerExit() && !prefersReducedMotion()) { + dialog.setAttribute('data-closing', ''); + const transitions = dialog.getAnimations().filter((animation) => animation instanceof CSSTransition); + if (transitions.length) { + await Promise.race([Promise.allSettled(transitions.map((animation) => animation.finished)), new Promise((resolve) => setTimeout(resolve, 600))]); + } + if (!dialog.hasAttribute('data-closing')) return; + dialog.removeAttribute('data-closing'); + } + dialog.close(); +} + +// --- Clipboard ------------------------------------------------------------------- + +async function writeClipboard(text, container) { + if (navigator.clipboard?.writeText && window.isSecureContext) { + try { + return await navigator.clipboard.writeText(text); + } catch (error) { + if (error?.name !== 'NotAllowedError') reportError(error, { where: 'clipboard' }); + } + } + // Older browsers, or clipboard permission denied: the classic selection trick. + const field = document.createElement('textarea'); + field.value = text; + field.readOnly = true; + field.className = 'visually-hidden'; + container.append(field); + field.select(); + const copied = document.execCommand('copy'); + field.remove(); + if (!copied) throw new Error('Copying to the clipboard was blocked'); +} + +// --- Dialog ------------------------------------------------------------------------ + +export function createPlaylistDialog({ dialog, onClose }) { + const $ = (selector) => dialog.querySelector(selector); + const ui = { + img: $('.sheet-art img'), + tag: $('.sheet-tag'), + title: $('.sheet-title'), + stats: $('.sheet-stats'), + description: $('.sheet-description'), + open: $('[data-action="open"]'), + copy: $('[data-action="copy"]'), + copyStatus: $('.copy-status'), + close: $('.sheet-close'), + player: $('.sheet-player'), + playerMessage: $('.player-message'), + }; + let current = null; + let slowTimer; + let copyTimer; + + function unloadPlayer() { + clearTimeout(slowTimer); + ui.player.querySelector('iframe')?.remove(); // Also stops playback. + ui.player.dataset.state = 'idle'; + ui.playerMessage.hidden = true; + } + + function loadPlayer(record) { + unloadPlayer(); + const iframe = document.createElement('iframe'); + iframe.title = `TIDAL player: ${record.title}`; + iframe.allow = 'encrypted-media; fullscreen; clipboard-write; autoplay'; + iframe.referrerPolicy = 'strict-origin-when-cross-origin'; + iframe.addEventListener( + 'load', + () => { + clearTimeout(slowTimer); + ui.player.dataset.state = 'loaded'; + ui.playerMessage.hidden = true; + }, + { once: true }, + ); + ui.player.dataset.state = 'loading'; + slowTimer = setTimeout(() => { + if (ui.player.dataset.state === 'loading') ui.playerMessage.hidden = false; + }, PLAYER_SLOW_MS); + iframe.src = embedUrl(record.id); + ui.player.append(iframe); + } + + function fill(record) { + dialog.classList.toggle('no-art', !record.art); + dialog.style.setProperty('--art', record.art?.color ?? ''); + setArtwork(ui.img, record.art, { sizes: DIALOG_ART_SIZES, loading: 'eager' }); + ui.tag.textContent = record.tag ?? ''; + ui.tag.hidden = !record.tag; + ui.title.textContent = record.title; + ui.stats.textContent = joinStats( + formatTracks(record.tracks), + formatDuration(record.duration), + formatFollowers(record.followers), + record.createdAt && `Added ${formatDate(record.createdAt)}`, + ); + ui.description.textContent = record.description ?? ''; + ui.open.href = record.url; + ui.copy.textContent = 'Copy link'; + ui.copyStatus.textContent = ''; + } + + async function copyLink() { + if (!current) return; + clearTimeout(copyTimer); + try { + await writeClipboard(current.url, dialog); + ui.copy.textContent = 'Copied ✓'; + ui.copyStatus.textContent = 'Link copied to your clipboard.'; + copyTimer = setTimeout(() => { + ui.copy.textContent = 'Copy link'; + ui.copyStatus.textContent = ''; + }, 2500); + } catch (error) { + reportError(error, { where: 'copyLink' }); + ui.copyStatus.textContent = `Couldn't copy automatically. Here's the link: ${current.url}`; + } + ui.copy.focus(); + } + + const close = () => closeTopLayer(dialog); + + ui.close.addEventListener('click', close); + ui.copy.addEventListener('click', copyLink); + dialog.addEventListener('close', () => { + unloadPlayer(); + const closed = current; + current = null; + onClose?.(closed); + }); + + // Route Esc through the animated close where the browser can't animate it natively. + dialog.addEventListener('cancel', (event) => { + if (supportsTopLayerExit() || prefersReducedMotion()) return; + event.preventDefault(); + close(); + }); + + // Light dismiss (click outside) for browsers without . + if (!('closedBy' in HTMLDialogElement.prototype)) { + dialog.addEventListener('click', (event) => { + if (event.target !== dialog) return; + const rect = dialog.getBoundingClientRect(); + const inside = rect.top <= event.clientY && event.clientY <= rect.bottom && rect.left <= event.clientX && event.clientX <= rect.right; + if (!inside) close(); + }); + } + + return { + get openId() { + return current?.id ?? null; + }, + open(record) { + current = record; + fill(record); + if (!dialog.open) dialog.showModal(); + dialog.scrollTop = 0; + loadPlayer(record); + }, + close, + }; +} diff --git a/public/js/error-handlers.js b/public/js/error-handlers.js new file mode 100644 index 00000000..78882d6e --- /dev/null +++ b/public/js/error-handlers.js @@ -0,0 +1,4 @@ +// Imported first by main.js, so errors in any later module are still reported. +import { installGlobalErrorHandlers } from './report.js'; + +installGlobalErrorHandlers(); diff --git a/public/js/filter.js b/public/js/filter.js new file mode 100644 index 00000000..fed1ac46 --- /dev/null +++ b/public/js/filter.js @@ -0,0 +1,61 @@ +// Searching, filtering and sorting. Pure functions: no DOM, easy to test. + +const collator = new Intl.Collator('en-GB', { sensitivity: 'base', numeric: true }); + +/** Lower-case and strip accents, so "bjork" finds "Björk". */ +export const fold = (text) => + String(text ?? '') + .normalize('NFKD') + .replace(/\p{M}/gu, '') + .toLowerCase(); + +export const tagKey = (tag) => (tag ? fold(tag).trim() : ''); + +/** Text searched for a record: its title, artist/genre tag and description. */ +export const searchText = (record) => fold([record.title, record.tag, record.description].filter(Boolean).join('\n')); + +export const parseQuery = (query) => fold(query).split(/\s+/).filter(Boolean); + +/** Every word of the query must appear somewhere in the record. */ +export const matches = (text, terms) => terms.every((term) => text.includes(term)); + +export const SORTS = { + newest: (a, b) => (b.createdAt ?? '').localeCompare(a.createdAt ?? '') || collator.compare(a.title, b.title), + updated: (a, b) => (b.updatedAt ?? '').localeCompare(a.updatedAt ?? '') || collator.compare(a.title, b.title), + az: (a, b) => collator.compare(a.title, b.title) || collator.compare(a.tag ?? '', b.tag ?? ''), +}; + +export const DEFAULT_SORT = 'newest'; +export const isSort = (value) => Object.hasOwn(SORTS, value); + +/** + * Applies a view to `entries` ({ record, text }) and returns the visible + * records in order. + */ +export function applyView(entries, { query = '', tag = '', sort = DEFAULT_SORT } = {}) { + const terms = parseQuery(query); + const key = tagKey(tag); + return entries + .filter((entry) => (!key || tagKey(entry.record.tag) === key) && matches(entry.text, terms)) + .map((entry) => entry.record) + .sort(SORTS[isSort(sort) ? sort : DEFAULT_SORT]); +} + +/** + * Tags shared by at least `min` playlists, most common first — in practice + * the genres, since single-artist deep dives tend to be one per artist. + */ +export function popularTags(records, { min = 2, limit = 24 } = {}) { + const byKey = new Map(); + for (const { tag } of records) { + const key = tagKey(tag); + if (!key) continue; + const entry = byKey.get(key) ?? { key, label: tag, count: 0 }; + entry.count++; + byKey.set(key, entry); + } + return [...byKey.values()] + .filter((entry) => entry.count >= min) + .sort((a, b) => b.count - a.count || collator.compare(a.label, b.label)) + .slice(0, limit); +} diff --git a/public/js/format.js b/public/js/format.js new file mode 100644 index 00000000..4f0e695f --- /dev/null +++ b/public/js/format.js @@ -0,0 +1,33 @@ +import { NEW_PLAYLIST_DAYS } from './constants.js'; + +const LOCALE = 'en-GB'; +const numbers = new Intl.NumberFormat(LOCALE); +const dates = new Intl.DateTimeFormat(LOCALE, { day: 'numeric', month: 'short', year: 'numeric' }); + +const plural = (n, one, many) => `${numbers.format(n)} ${n === 1 ? one : many}`; + +export const formatTracks = (n) => (Number.isFinite(n) ? plural(n, 'track', 'tracks') : null); +// Zero followers says nothing useful, so it is left out. +export const formatFollowers = (n) => (Number.isFinite(n) && n > 0 ? plural(n, 'follower', 'followers') : null); + +/** 3723 → "1 hr 2 min"; 2880 → "48 min". */ +export function formatDuration(seconds) { + if (!Number.isFinite(seconds) || seconds <= 0) return null; + const minutes = Math.round(seconds / 60); + const hours = Math.floor(minutes / 60); + if (!hours) return `${minutes} min`; + return minutes % 60 ? `${hours} hr ${minutes % 60} min` : `${hours} hr`; +} + +export function formatDate(iso) { + const time = Date.parse(iso); + return Number.isFinite(time) ? dates.format(time) : null; +} + +export function isNew(record, now = Date.now()) { + const created = Date.parse(record.createdAt); + return Number.isFinite(created) && now - created < NEW_PLAYLIST_DAYS * 86_400_000; +} + +/** "42 tracks · 2 hr 13 min" — skipping anything unknown. */ +export const joinStats = (...parts) => parts.filter(Boolean).join(' · '); diff --git a/public/js/grid.js b/public/js/grid.js new file mode 100644 index 00000000..d1184823 --- /dev/null +++ b/public/js/grid.js @@ -0,0 +1,145 @@ +// The playlist grid. Cards are created once per playlist and reused: filtering +// and sorting only re-order existing elements, so loaded artwork is never +// re-requested and typing in the search box stays instant. + +import { CARD_IMAGE_SIZES, EAGER_CARD_COUNT, srcsetFor } from './constants.js'; +import { formatDuration, formatTracks, isNew, joinStats } from './format.js'; +import { reportError } from './report.js'; + +/** A sensible single image for browsers that ignore srcset: the first ≥ 320px wide. */ +export const fallbackSrc = (art) => (art.sources.find(([, width]) => width >= 320) ?? art.sources.at(-1))[0]; + +let reportedArtworkFailure = false; + +// Per-image listeners (not delegated): a card can be detached by filtering while its image loads. +function onImageLoad(event) { + event.currentTarget.classList.remove('is-loading'); +} + +function onImageError(event) { + const img = event.currentTarget; + img.classList.remove('is-loading'); + img.closest('.card, .sheet')?.classList.add('no-art'); + if (!reportedArtworkFailure) { + reportedArtworkFailure = true; + reportError(new Error('Playlist artwork failed to load'), { where: 'artwork', src: img.currentSrc || img.src }); + } +} + +/** Points an at a playlist's artwork, fading it in once loaded. */ +export function setArtwork(img, art, { sizes, loading = 'lazy', priority = false }) { + const srcset = srcsetFor(art); + if (srcset && img.getAttribute('srcset') === srcset) return; // Unchanged: keep what is loaded. + img.removeAttribute('srcset'); + img.removeAttribute('src'); + if (!art) return; + // Order matters: `loading` must be set before the browser sees a source. + img.loading = loading; + if (priority) img.fetchPriority = 'high'; + img.classList.add('is-loading'); + img.addEventListener('load', onImageLoad); + img.addEventListener('error', onImageError); + img.sizes = sizes; + img.srcset = srcset; + img.src = fallbackSrc(art); +} + +export function createGrid({ list, template, onOpen, onTag }) { + const cards = new Map(); // id → { el, rev } + let order = null; // null until the first render, so the loading skeletons are always replaced + let firstRender = true; + + function fillImage(el, record, { eager, priority }) { + el.classList.toggle('no-art', !record.art); + el.style.setProperty('--art', record.art?.color ?? ''); + setArtwork(el.querySelector('img'), record.art, { + loading: eager ? 'eager' : 'lazy', + priority, + // `auto` lets lazy images use their laid-out width; eager ones need the explicit list. + sizes: eager ? CARD_IMAGE_SIZES : `auto, ${CARD_IMAGE_SIZES}`, + }); + } + + function fillText(el, record) { + el.dataset.id = record.id; + const link = el.querySelector('.card-link'); + link.href = `?p=${encodeURIComponent(record.id)}`; + link.textContent = record.title; + + const tag = el.querySelector('.tag-chip'); + tag.hidden = !record.tag; + tag.textContent = record.tag ?? ''; + tag.dataset.tag = record.tag ?? ''; + tag.setAttribute('aria-label', record.tag ? `Show all “${record.tag}” playlists` : ''); + + el.querySelector('.card-stats').textContent = joinStats(formatTracks(record.tracks), formatDuration(record.duration)); + el.querySelector('.card-description').textContent = record.description ?? ''; + el.querySelector('.badge').hidden = !isNew(record); + } + + function cardFor(record, index) { + let card = cards.get(record.id); + if (!card) { + const el = template.content.firstElementChild.cloneNode(true); + fillText(el, record); + const eager = firstRender && index < EAGER_CARD_COUNT; + fillImage(el, record, { eager, priority: eager && index === 0 }); + card = { el, rev: record.rev }; + cards.set(record.id, card); + } else if (card.rev !== record.rev) { + fillText(card.el, record); + fillImage(card.el, record, { eager: false, priority: false }); + card.rev = record.rev; + } + return card.el; + } + + /** Shows exactly `records`, in order. */ + function render(records) { + const elements = records.map(cardFor); + const ids = records.map((record) => record.id); + if (!order || ids.length !== order.length || ids.some((id, i) => id !== order[i])) { + const focusedId = document.activeElement?.closest?.('.card')?.dataset.id; + list.replaceChildren(...elements); + order = ids; + // Re-ordering detaches the focused card; put focus back if it is still shown. + if (focusedId && cards.has(focusedId) && ids.includes(focusedId)) { + cards.get(focusedId).el.querySelector('.card-link').focus({ preventScroll: true }); + } + } + list.setAttribute('aria-busy', 'false'); + // An empty render (e.g. after a failed load) shouldn't use up the first-row priority hints. + if (records.length) firstRender = false; + } + + /** Forgets cards for playlists that no longer exist. */ + function prune(liveIds) { + for (const id of cards.keys()) if (!liveIds.has(id)) cards.delete(id); + } + + // Event delegation: one listener each, however many cards there are. + list.addEventListener('click', (event) => { + const tag = event.target.closest('.tag-chip'); + if (tag) return onTag(tag.dataset.tag); + const link = event.target.closest('.card-link'); + // Let modified clicks (new tab, new window) behave as normal links. + if (!link || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; + event.preventDefault(); + onOpen(link.closest('.card').dataset.id); + }); + + // Arrow keys move between cards, row by row, as well as Tab. + list.addEventListener('keydown', (event) => { + const link = event.target.closest?.('.card-link'); + if (!link) return; + const links = [...list.querySelectorAll('.card-link')]; + const index = links.indexOf(link); + const columns = getComputedStyle(list).gridTemplateColumns.split(' ').length; + const target = { ArrowRight: index + 1, ArrowLeft: index - 1, ArrowDown: index + columns, ArrowUp: index - columns, Home: 0, End: links.length - 1 }[event.key]; + if (target === undefined || event.altKey || event.ctrlKey || event.metaKey) return; + event.preventDefault(); + links[Math.max(0, Math.min(links.length - 1, target))].focus(); + }); + + return { render, prune }; +} diff --git a/public/js/main.js b/public/js/main.js new file mode 100644 index 00000000..ddb7c82c --- /dev/null +++ b/public/js/main.js @@ -0,0 +1,348 @@ +import './error-handlers.js'; +import { ApiError } from './api.js'; +import { createPlaylistDialog } from './dialog.js'; +import { DEFAULT_SORT, applyView, isSort, popularTags, searchText, tagKey } from './filter.js'; +import { createGrid } from './grid.js'; +import { reportError } from './report.js'; +import { loadCache, saveCache } from './store.js'; +import { syncPlaylists } from './sync.js'; +import { showToast } from './toast.js'; + +const RESYNC_AFTER_MS = 30 * 60_000; +const MAX_AUTO_RETRIES = 3; + +const $ = (id) => document.getElementById(id); +const els = { + main: $('playlists'), + form: $('filters'), + search: $('search'), + sort: $('sort'), + count: $('result-count'), + announcer: $('announcer'), + clear: $('clear-filters'), + tags: $('tags'), + notice: $('notice'), + empty: $('empty'), + grid: $('grid'), +}; + +const state = { + playlists: [], + entries: [], + byId: new Map(), + view: readViewFromUrl(), + deepLink: new URL(location.href).searchParams.get('p'), + lastSyncAt: 0, + syncing: false, + autoRetries: 0, +}; + +const plural = (n, word) => `${n.toLocaleString('en-GB')} ${word}${n === 1 ? '' : 's'}`; + +// --- URL state --------------------------------------------------------------------- +// ?q= search, ?tag= artist/genre, ?sort=, ?p= open playlist. Shareable and bookmarkable. + +function readViewFromUrl() { + const params = new URL(location.href).searchParams; + const sort = params.get('sort'); + return { query: params.get('q') ?? '', tag: params.get('tag') ?? '', sort: isSort(sort) ? sort : DEFAULT_SORT }; +} + +let urlTimer; +function flushViewToUrl() { + clearTimeout(urlTimer); + urlTimer = undefined; + const url = new URL(location.href); + const set = (key, value) => (value ? url.searchParams.set(key, value) : url.searchParams.delete(key)); + set('q', state.view.query.trim()); + set('tag', state.view.tag); + set('sort', state.view.sort === DEFAULT_SORT ? '' : state.view.sort); + if (url.href !== location.href) history.replaceState(history.state, '', url); +} + +/** Debounced, so typing doesn't spam the history API. */ +function writeViewToUrl() { + clearTimeout(urlTimer); + urlTimer = setTimeout(flushViewToUrl, 300); +} + +// --- Rendering ------------------------------------------------------------------------- + +const grid = createGrid({ + list: els.grid, + template: $('card-template'), + onOpen: (id) => openPlaylist(id, { push: true }), + onTag: (tag) => { + setView({ tag }); + els.main.scrollIntoView({ block: 'start', behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth' }); + }, +}); + +const sheet = createPlaylistDialog({ dialog: $('playlist-dialog'), onClose: handleDialogClosed }); + +function makeTagChip({ label, count, key }) { + const chip = document.createElement('button'); + chip.type = 'button'; + chip.className = 'tag-chip'; + chip.dataset.tag = key ? label : ''; + chip.dataset.key = key; + chip.textContent = label; + if (count) { + const badge = document.createElement('span'); + badge.className = 'tag-count'; + badge.textContent = count; + badge.setAttribute('aria-label', `(${plural(count, 'playlist')})`); + chip.append(' ', badge); + } + return chip; +} + +/** Chips for the common tags; built only when the playlists change, so focus is kept. */ +function renderTags() { + const tags = popularTags(state.playlists); + els.tags.replaceChildren(makeTagChip({ label: 'All', key: '' }), ...tags.map(makeTagChip)); + els.tags.hidden = tags.length === 0; +} + +function syncTagChips() { + const active = tagKey(state.view.tag); + let found = !active; + for (const chip of els.tags.querySelectorAll('.tag-chip')) { + const pressed = chip.dataset.key === active; + chip.setAttribute('aria-pressed', String(pressed)); + found ||= pressed; + if (chip.dataset.extra && !pressed) chip.remove(); + } + // A tag picked from a card that isn't among the common ones: show it so it can be cleared. + if (!found) { + const chip = makeTagChip({ label: state.view.tag, key: active }); + chip.dataset.extra = 'true'; + chip.setAttribute('aria-pressed', 'true'); + els.tags.firstElementChild?.after(chip); + els.tags.hidden = false; + } +} + +let announceTimer; +function renderView({ announce = false } = {}) { + const visible = applyView(state.entries, state.view); + grid.render(visible); + + const total = state.playlists.length; + const filtered = Boolean(state.view.query.trim() || state.view.tag); + els.count.textContent = filtered ? `${visible.length} of ${plural(total, 'playlist')}` : plural(total, 'playlist'); + els.clear.hidden = !filtered; + syncTagChips(); + + const noMatches = filtered && total > 0 && visible.length === 0; + els.empty.hidden = !noMatches; + if (noMatches) { + const what = [state.view.query.trim() && `“${state.view.query.trim()}”`, state.view.tag && `the tag “${state.view.tag}”`].filter(Boolean).join(' and '); + els.empty.querySelector('.empty-message').textContent = `No playlists match ${what}.`; + } + + if (announce) { + // Debounced so screen readers hear the result, not every keystroke. + clearTimeout(announceTimer); + announceTimer = setTimeout(() => { + els.announcer.textContent = filtered ? `${plural(visible.length, 'playlist')} found` : `Showing all ${plural(total, 'playlist')}`; + }, 700); + } +} + +function setView(changes) { + state.view = { ...state.view, ...changes }; + syncControls(); + renderView({ announce: true }); + writeViewToUrl(); +} + +function syncControls() { + if (els.search.value !== state.view.query) els.search.value = state.view.query; + els.sort.value = state.view.sort; +} + +function setPlaylists(playlists) { + state.playlists = playlists; + state.byId = new Map(playlists.map((record) => [record.id, record])); + state.entries = playlists.map((record) => ({ record, text: searchText(record) })); + grid.prune(state.byId); + renderTags(); + renderView(); +} + +// --- Dialog & history ---------------------------------------------------------------------- + +let closingFromHistory = false; + +function openPlaylist(id, { push }) { + const record = state.byId.get(id); + if (!record) return false; + if (push) { + // Save the current filters into this history entry first, so Back returns to them. + if (urlTimer) flushViewToUrl(); + const url = new URL(location.href); + url.searchParams.set('p', id); + history.pushState({ playlist: id }, '', url); + } + sheet.open(record); + return true; +} + +function handleDialogClosed() { + if (closingFromHistory) { + closingFromHistory = false; + return; + } + // Opened from the grid: step back so Back doesn't reopen it. Arrived via a link: tidy the URL. + if (history.state?.playlist) { + history.back(); + } else { + const url = new URL(location.href); + url.searchParams.delete('p'); + history.replaceState(null, '', url); + } +} + +window.addEventListener('popstate', () => { + const id = new URL(location.href).searchParams.get('p'); + if (id && state.byId.has(id)) { + if (sheet.openId !== id) openPlaylist(id, { push: false }); + } else if (sheet.openId) { + closingFromHistory = true; + sheet.close(); + } + state.view = readViewFromUrl(); + syncControls(); + renderView(); +}); + +/** Opens ?p= once its playlist is known; after a full sync, gives up politely. */ +function openDeepLink({ final }) { + if (!state.deepLink) return; + if (openPlaylist(state.deepLink, { push: false })) { + state.deepLink = null; + } else if (final) { + state.deepLink = null; + handleDialogClosed(); + showToast('Sorry, that playlist isn’t available any more.'); + } +} + +// --- Notices --------------------------------------------------------------------------------- + +function showNotice(message, action) { + els.notice.querySelector('.notice-message').textContent = message; + const button = els.notice.querySelector('.notice-action'); + button.hidden = !action; + if (action) { + button.textContent = action.label; + button.onclick = action.run; + } + els.notice.hidden = false; +} + +const hideNotice = () => { + els.notice.hidden = true; +}; + +function handleSyncError(error) { + const known = error instanceof ApiError; + // Network trouble is the visitor's, and 5xx errors are already logged by the server. + const worthReporting = !known || error.code === 'BAD_RESPONSE' || (error.status >= 400 && error.status < 500); + if (worthReporting) reportError(error, { where: 'sync', code: error.code, status: error.status, requestId: error.requestId }); + + const retry = () => refresh(); + if (known && error.isOffline) window.addEventListener('online', retry, { once: true }); + + if (state.playlists.length) { + // We still have the saved copy on screen; mention it without getting in the way. + showToast(known && error.isOffline ? 'You’re offline — showing your saved playlists.' : 'Couldn’t check for new playlists. Showing your saved copy.'); + return; + } + + grid.render([]); + els.count.textContent = ''; + if (known && error.isOffline) { + showNotice('You’re offline. The playlists will load as soon as you reconnect.'); + } else if (known && error.code === 'CATALOGUE_UNAVAILABLE' && state.autoRetries < MAX_AUTO_RETRIES) { + state.autoRetries++; + const seconds = Math.min(error.retryAfter ?? 15, 60); + showNotice('The playlists are temporarily unavailable — TIDAL may be having a moment. Trying again shortly…', { label: 'Try again now', run: retry }); + setTimeout(retry, seconds * 1000); + } else { + const reference = known && error.requestId ? ` (Reference: ${error.requestId.slice(0, 8)})` : ''; + showNotice(`Sorry, the playlists couldn’t be loaded.${reference}`, { label: 'Try again', run: retry }); + } +} + +// --- Sync ------------------------------------------------------------------------------------ + +async function refresh({ boot } = {}) { + if (state.syncing) return; + state.syncing = true; + const cache = loadCache(); + try { + const result = await syncPlaylists({ cache, boot }); + state.lastSyncAt = Date.now(); + state.autoRetries = 0; + hideNotice(); + if (result.mode !== 'unchanged') saveCache(result); + if (result.mode !== 'unchanged' || !state.playlists.length) setPlaylists(result.playlists); + if (!result.playlists.length) showNotice('There are no playlists to show just yet. Please check back soon.'); + if (cache && result.added.length) { + showToast(result.added.length === 1 ? 'A new playlist has been added since your last visit.' : `${result.added.length} new playlists have been added since your last visit.`); + } + } catch (error) { + handleSyncError(error); + } finally { + state.syncing = false; + openDeepLink({ final: true }); + } +} + +// --- Controls -------------------------------------------------------------------------------- + +els.search.addEventListener('input', () => setView({ query: els.search.value })); +els.sort.addEventListener('change', () => setView({ sort: els.sort.value })); +els.form.addEventListener('submit', (event) => { + event.preventDefault(); + els.search.blur(); // Closes the on-screen keyboard on phones. +}); +els.clear.addEventListener('click', () => { + setView({ query: '', tag: '' }); + els.search.focus(); +}); +els.empty.querySelector('[data-action="clear-filters"]').addEventListener('click', () => { + setView({ query: '', tag: '' }); + els.search.focus(); +}); +els.tags.addEventListener('click', (event) => { + const chip = event.target.closest('.tag-chip'); + if (!chip) return; + setView({ tag: chip.getAttribute('aria-pressed') === 'true' ? '' : chip.dataset.tag }); +}); + +// Long-lived tabs: look for new playlists when the visitor comes back. +const resyncIfStale = () => { + if (document.visibilityState === 'visible' && Date.now() - state.lastSyncAt > RESYNC_AFTER_MS) refresh(); +}; +document.addEventListener('visibilitychange', resyncIfStale); +window.addEventListener('pageshow', (event) => event.persisted && resyncIfStale()); + +// --- Start ------------------------------------------------------------------------------------- + +try { + syncControls(); + const cached = loadCache(); + if (cached) { + setPlaylists(cached.playlists); // Instant: no network needed to show the grid. + openDeepLink({ final: false }); + } + const boot = window.__selectionsBoot; + window.__selectionsBoot = undefined; + await refresh({ boot }); +} catch (error) { + reportError(error, { where: 'start' }); + showNotice('Sorry, something went wrong while starting up.', { label: 'Reload', run: () => location.reload() }); +} diff --git a/public/js/modules/DataFetcher.js b/public/js/modules/DataFetcher.js deleted file mode 100644 index 8609bc22..00000000 --- a/public/js/modules/DataFetcher.js +++ /dev/null @@ -1,61 +0,0 @@ -export const DataFetcher = (() => { - const userId = '111112791'; - - const fetchAllPlaylists = async (userId, offset = 0, fetchedPlaylists = []) => { - try { - const response = await fetch(`/playlists/${userId}?offset=${offset}`); - if (!response.ok) { - const errorDetails = await response.json(); - console.error('Error fetching playlists:', errorDetails); - return []; - } - - const newPlaylists = await response.json(); - console.log('Received playlists:', newPlaylists); - - fetchedPlaylists = fetchedPlaylists.concat(newPlaylists.items); - - if (newPlaylists.items.length === 50) { - return await fetchAllPlaylists(userId, offset + 50, fetchedPlaylists); - } - - return fetchedPlaylists; - } catch (error) { - console.error('Error fetching playlists:', error); - return []; - } - }; - - const fetchPlaylists = async (search = '') => { - let allFetchedPlaylists = []; - - try { - const cacheKey = `playlists-${userId}`; - const cachedPlaylists = localStorage.getItem(cacheKey); - - if (cachedPlaylists) { - console.log('Using cached playlists'); - allFetchedPlaylists = JSON.parse(cachedPlaylists); - } else { - allFetchedPlaylists = await fetchAllPlaylists(userId); - localStorage.setItem(cacheKey, JSON.stringify(allFetchedPlaylists)); - } - - const searchLowerCase = search.toLowerCase(); - - const filteredPlaylists = allFetchedPlaylists.filter((playlist) => - playlist.name.toLowerCase().includes(searchLowerCase) || - (playlist.description && playlist.description.toLowerCase().includes(searchLowerCase)) - ); - return filteredPlaylists; - } catch (error) { - console.error(error); - return []; - } - }; - - return { - fetchAllPlaylists, - fetchPlaylists - }; -})(); diff --git a/public/js/modules/EventHandlers.js b/public/js/modules/EventHandlers.js deleted file mode 100644 index 6f218dd2..00000000 --- a/public/js/modules/EventHandlers.js +++ /dev/null @@ -1,82 +0,0 @@ -import { DataFetcher } from './DataFetcher.js'; -import { UIManager } from './UIManager.js'; - -export const EventHandlers = (() => { - const searchInput = document.getElementById('search'); - const resetButton = document.getElementById('reset-button'); - const closeOverlay = document.getElementById('close-overlay'); - const overlayBackground = document.getElementById('overlay-background'); - const openWebButton = document.getElementById('open-web'); - const copyUrlButton = document.getElementById('copy-url'); - - const onSearchInputKeyDown = async (event) => { - if (event.key === 'Enter') { - UIManager.toggleLoadingMessage(true); - try { - const playlists = await DataFetcher.fetchPlaylists(event.target.value); - UIManager.displayPlaylists(playlists); - } catch (error) { - console.error('Error fetching playlists:', error); - } finally { - UIManager.toggleLoadingMessage(false); - } - } - }; - - const onResetButtonClick = async () => { - searchInput.value = ''; - UIManager.updateResetButton(''); - UIManager.toggleLoadingMessage(true); - try { - const playlists = await DataFetcher.fetchPlaylists(); - UIManager.displayPlaylists(playlists); - } catch (error) { - console.error('Error fetching playlists:', error); - } finally { - UIManager.toggleLoadingMessage(false); - } - }; - - const onCloseOverlayClick = () => { - const overlay = document.getElementById('overlay-background'); - overlay.classList.add('hidden'); - }; - - const onOverlayBackgroundClick = (event) => { - if (event.target === event.currentTarget) { - overlayBackground.classList.add('hidden'); - } - }; - - const onOpenWebButtonClick = () => { - const playlistId = openWebButton.getAttribute('data-playlist-id'); - const webUrl = `https://open.spotify.com/playlist/${playlistId}`; - window.open(webUrl, '_blank'); - }; - - const onCopyUrlButtonClick = () => { - const player = document.getElementById('spotify-player'); - const textarea = document.createElement('textarea'); - textarea.value = player.src; - document.body.appendChild(textarea); - textarea.select(); - document.execCommand('copy'); - document.body.removeChild(textarea); - alert('Playlist URL copied to clipboard'); - }; - - // Initialize all event listeners - const initEventListeners = () => { - searchInput.addEventListener('keydown', onSearchInputKeyDown); - resetButton.addEventListener('click', onResetButtonClick); - closeOverlay.addEventListener('click', onCloseOverlayClick); - overlayBackground.addEventListener('click', onOverlayBackgroundClick); - openWebButton.addEventListener('click', onOpenWebButtonClick); - copyUrlButton.addEventListener('click', onCopyUrlButtonClick); - // Additional event listeners can be added here as needed - }; - - return { - initEventListeners - }; -})(); diff --git a/public/js/modules/UIManager.js b/public/js/modules/UIManager.js deleted file mode 100644 index 06642e6e..00000000 --- a/public/js/modules/UIManager.js +++ /dev/null @@ -1,55 +0,0 @@ -export const UIManager = (() => { - const playlistsContainer = document.getElementById('playlists-container'); - const loadingMessage = document.getElementById('loading-message'); - const resetButton = document.getElementById('reset-button'); - - const toggleLoadingMessage = (show) => { - loadingMessage.style.display = show ? 'block' : 'none'; - }; - - const updateResetButton = (search) => { - resetButton.style.display = search !== '' ? 'inline-block' : 'none'; - }; - - const displayPlaylists = (playlists) => { - while (playlistsContainer.firstChild) { - playlistsContainer.removeChild(playlistsContainer.firstChild); - } - - playlists.sort((a, b) => a.name.localeCompare(b.name)); - - const counter = document.getElementById('playlist-counter'); - counter.textContent = `Showing ${playlists.length} playlists`; - - playlists.forEach((playlist) => { - const playlistElement = document.createElement('div'); - playlistElement.className = 'playlist flex lay--column lay--gap-small-xx'; - playlistElement.innerHTML = ` - ${playlist.name} cover art -

${playlist.name}

-
-

${(playlist.tracks?.total || 0)} songs

-

|

-

${(playlist.followers?.total || 0)} followers

-
-

${playlist.description || ''}

- `; - - playlistsContainer.appendChild(playlistElement); - - // Additional logic for playlist interaction can be added here - }); - }; - - const updateOverlay = (playlist) => { - // Logic to update overlay with playlist details - // This needs to be implemented based on your specific requirements - }; - - return { - toggleLoadingMessage, - updateResetButton, - displayPlaylists, - updateOverlay - }; -})(); diff --git a/public/js/modules/Utils.js b/public/js/modules/Utils.js deleted file mode 100644 index 395030f5..00000000 --- a/public/js/modules/Utils.js +++ /dev/null @@ -1 +0,0 @@ -export const Utils = (() => { })(); \ No newline at end of file diff --git a/public/js/report.js b/public/js/report.js new file mode 100644 index 00000000..5e0ee50b --- /dev/null +++ b/public/js/report.js @@ -0,0 +1,68 @@ +// Sends browser errors to the server (POST /api/reports), which logs them and +// forwards them to Sentry when configured. No third-party script required. + +const ENDPOINT = '/api/reports'; +const MAX_REPORTS_PER_PAGE = 10; + +// Errors that are not ours or not actionable. +const IGNORED = [/ResizeObserver loop/i, /^Script error\.?$/i, /extension:\/\//i, /^AbortError/]; + +const sent = new Set(); +let count = 0; + +const release = () => document.documentElement.dataset.release; + +function toError(value) { + if (value instanceof Error) return value; + if (typeof value === 'string') return new Error(value); + try { + return new Error(JSON.stringify(value)); + } catch { + return new Error(String(value)); + } +} + +/** + * Records an error: always logs to the console, and reports it to the server + * at most once per distinct message, and at most 10 times per page view. + */ +export function reportError(value, context = {}) { + const error = toError(value); + console.error(error, context); + + const signature = `${error.name}: ${error.message}`; + const haystack = `${signature}\n${error.stack ?? ''}`; + if (IGNORED.some((pattern) => pattern.test(haystack))) return; + if (sent.has(signature) || count >= MAX_REPORTS_PER_PAGE) return; + sent.add(signature); + count++; + + const payload = JSON.stringify({ + type: 'client-error', + name: error.name, + message: error.message, + stack: error.stack, + url: location.href, + userAgent: navigator.userAgent, + release: release(), + context, + }); + + try { + const blob = new Blob([payload], { type: 'application/json' }); + if (navigator.sendBeacon?.(ENDPOINT, blob)) return; + fetch(ENDPOINT, { method: 'POST', body: payload, headers: { 'Content-Type': 'application/json' }, keepalive: true }).catch(() => {}); + } catch { + // Reporting must never throw. + } +} + +/** Catches anything not handled elsewhere. */ +export function installGlobalErrorHandlers() { + window.addEventListener('error', (event) => { + reportError(event.error ?? event.message, { where: 'window.onerror', source: event.filename, line: event.lineno, column: event.colno }); + }); + window.addEventListener('unhandledrejection', (event) => { + reportError(event.reason, { where: 'unhandledrejection' }); + }); +} diff --git a/public/js/store.js b/public/js/store.js new file mode 100644 index 00000000..7c3a1612 --- /dev/null +++ b/public/js/store.js @@ -0,0 +1,60 @@ +// The browser's copy of the playlists, kept in localStorage so repeat visits +// render instantly and only download what changed. ~100 KB for 150 playlists. + +import { CACHE_ETAG_KEY, CACHE_KEY } from './constants.js'; +import { reportError } from './report.js'; + +export const isRecord = (record) => + typeof record?.id === 'string' && typeof record.rev === 'string' && typeof record.title === 'string'; + +function storage() { + try { + return window.localStorage; // Throws when storage is blocked. + } catch { + return null; + } +} + +export function clearCache() { + try { + storage()?.removeItem(CACHE_KEY); + storage()?.removeItem(CACHE_ETAG_KEY); + } catch { + // Nothing more we can do. + } +} + +/** The cached { etag, savedAt, playlists }, or null if missing or unusable. */ +export function loadCache() { + const store = storage(); + if (!store) return null; + try { + const raw = store.getItem(CACHE_KEY); + if (!raw) return null; + const data = JSON.parse(raw); + if (typeof data?.etag !== 'string' || !Array.isArray(data.playlists) || !data.playlists.every(isRecord)) { + throw new Error('Cached playlists have an unexpected shape'); + } + return data; + } catch (error) { + reportError(error, { where: 'loadCache' }); + clearCache(); + return null; + } +} + +export function saveCache({ etag, playlists }) { + const store = storage(); + if (!store) return false; + try { + store.setItem(CACHE_KEY, JSON.stringify({ etag, savedAt: Date.now(), playlists })); + // Written last, read by the boot script in : only set once the data it describes is saved. + store.setItem(CACHE_ETAG_KEY, etag); + return true; + } catch (error) { + clearCache(); + // A full disk is the browser's business, not a bug; anything else is worth knowing about. + if (error?.name !== 'QuotaExceededError') reportError(error, { where: 'saveCache' }); + return false; + } +} diff --git a/public/js/sync.js b/public/js/sync.js new file mode 100644 index 00000000..c8c29240 --- /dev/null +++ b/public/js/sync.js @@ -0,0 +1,100 @@ +// Keeps the browser's copy of the playlists current while downloading as little +// as possible: +// +// 1. Ask for the manifest with the cached etag → usually a bodiless 304. Done. +// 2. Otherwise compare the manifest (id + revision per playlist) with the +// cache, and fetch only playlists that are new or changed. +// 3. Fall back to one full download when most of it changed anyway. + +import { ApiError, getJson, readJson } from './api.js'; +import { isRecord } from './store.js'; + +const BATCH_SIZE = 50; +const FULL_DOWNLOAD_RATIO = 0.5; + +const chunk = (items, size) => Array.from({ length: Math.ceil(items.length / size) }, (_, i) => items.slice(i * size, (i + 1) * size)); + +export function diffManifest(cached, items) { + const known = new Map(cached.map((record) => [record.id, record.rev])); + const live = new Set(); + const added = []; + const changed = []; + for (const [id, rev] of items) { + live.add(id); + if (!known.has(id)) added.push(id); + else if (known.get(id) !== rev) changed.push(id); + } + const removed = cached.filter((record) => !live.has(record.id)).map((record) => record.id); + return { added, changed, removed }; +} + +export function mergePlaylists(cached, fetched, removed) { + const byId = new Map(cached.map((record) => [record.id, record])); + for (const id of removed) byId.delete(id); + for (const record of fetched) byId.set(record.id, record); + return [...byId.values()]; +} + +function expectPlaylists(data) { + if (typeof data?.etag !== 'string' || !Array.isArray(data.playlists) || !data.playlists.every(isRecord)) { + throw new ApiError('The server sent playlists in an unexpected format.', { code: 'BAD_RESPONSE' }); + } + return data; +} + +function expectManifest(data) { + if (typeof data?.etag !== 'string' || !Array.isArray(data.items) || !data.items.every((item) => Array.isArray(item) && item.length === 2)) { + throw new ApiError('The server sent a manifest in an unexpected format.', { code: 'BAD_RESPONSE' }); + } + return data; +} + +async function downloadAll() { + const { data } = await getJson('/api/playlists'); + return expectPlaylists(data); +} + +/** + * @param cache { etag, playlists } from localStorage, or null + * @param boot { etag, request } started by the inline script in , if any + * @returns { playlists, etag, added, changed, removed, mode: 'unchanged' | 'delta' | 'full' } + */ +export async function syncPlaylists({ cache, boot }) { + if (!cache) { + // The boot script only requested everything when it found no cached etag. + const data = boot && !boot.etag ? expectPlaylists((await readJson(boot.request)).data) : await downloadAll(); + return { playlists: data.playlists, etag: data.etag, added: [], changed: 0, removed: 0, mode: 'full' }; + } + + const response = boot?.etag === cache.etag ? await readJson(boot.request) : await getJson('/api/playlists/manifest', { etag: cache.etag }); + if (response.status === 304) { + return { playlists: cache.playlists, etag: cache.etag, added: [], changed: 0, removed: 0, mode: 'unchanged' }; + } + + const manifest = expectManifest(response.data); + const { added, changed, removed } = diffManifest(cache.playlists, manifest.items); + const wanted = [...added, ...changed]; + + if (wanted.length > Math.max(20, manifest.items.length * FULL_DOWNLOAD_RATIO)) { + const data = await downloadAll(); + return { playlists: data.playlists, etag: data.etag, added, changed: changed.length, removed: removed.length, mode: 'full' }; + } + + const pages = await Promise.all( + chunk(wanted, BATCH_SIZE).map(async (ids) => expectPlaylists((await getJson(`/api/playlists?ids=${ids.map(encodeURIComponent).join(',')}`)).data)), + ); + // The catalogue changed between our two requests: simplest to start afresh. + if (pages.some((page) => page.missing?.length)) { + const data = await downloadAll(); + return { playlists: data.playlists, etag: data.etag, added, changed: changed.length, removed: removed.length, mode: 'full' }; + } + + return { + playlists: mergePlaylists(cache.playlists, pages.flatMap((page) => page.playlists), removed), + etag: manifest.etag, + added, + changed: changed.length, + removed: removed.length, + mode: 'delta', + }; +} diff --git a/public/js/toast.js b/public/js/toast.js new file mode 100644 index 00000000..d253bfb2 --- /dev/null +++ b/public/js/toast.js @@ -0,0 +1,13 @@ +let timer; + +/** Brief, non-blocking message at the bottom of the page (announced politely). */ +export function showToast(message, { duration = 4000 } = {}) { + const toast = document.getElementById('toast'); + if (!toast) return; + clearTimeout(timer); + toast.textContent = message; + toast.hidden = false; + timer = setTimeout(() => { + toast.hidden = true; + }, duration); +} diff --git a/scripts/check-syntax.js b/scripts/check-syntax.js new file mode 100644 index 00000000..f986c4ac --- /dev/null +++ b/scripts/check-syntax.js @@ -0,0 +1,29 @@ +// Parses every JavaScript file in the project without running it, so syntax +// errors in browser modules (which no server test imports) still fail CI. +import { spawnSync } from 'node:child_process'; +import { readdirSync } from 'node:fs'; +import { join } from 'node:path'; + +const roots = ['app.js', 'src', 'scripts', 'public/js', 'test']; +const files = []; + +const walk = (path) => { + if (path.endsWith('.js')) return files.push(path); + for (const entry of readdirSync(path, { withFileTypes: true })) { + if (entry.isDirectory()) walk(join(path, entry.name)); + else if (entry.name.endsWith('.js')) files.push(join(path, entry.name)); + } +}; +roots.forEach(walk); + +let failed = 0; +for (const file of files) { + const result = spawnSync(process.execPath, ['--check', file], { encoding: 'utf8' }); + if (result.status !== 0) { + failed++; + process.stderr.write(result.stderr); + } +} + +console.log(`Checked ${files.length} files, ${failed} with syntax errors.`); +process.exit(failed ? 1 : 0); diff --git a/scripts/tidal-login.js b/scripts/tidal-login.js new file mode 100644 index 00000000..ab5156d5 --- /dev/null +++ b/scripts/tidal-login.js @@ -0,0 +1,129 @@ +// One-time sign-in with your TIDAL account, for when TIDAL won't let the app +// read your playlists with client credentials alone. +// +// npm run tidal:login prints TIDAL_REFRESH_TOKEN and TIDAL_USER_ID +// npm run tidal:login -- --save also writes them into .env +// +// Uses the OAuth 2.1 authorisation-code flow with PKCE. Register the redirect +// URI (default http://localhost:3000/callback) in your app at +// developer.tidal.com first, and stop the app if it is using that port. + +import { createHash, randomBytes } from 'node:crypto'; +import { existsSync, readFileSync, writeFileSync } from 'node:fs'; +import { createServer } from 'node:http'; +import { loadEnvFile } from '../src/config.js'; + +const AUTHORIZE_URL = 'https://login.tidal.com/authorize'; +const TOKEN_URL = 'https://auth.tidal.com/v1/oauth2/token'; +const API_URL = 'https://openapi.tidal.com/v2'; +const TIMEOUT_MS = 5 * 60_000; + +loadEnvFile(); +const clientId = process.env.TIDAL_CLIENT_ID?.trim(); +const clientSecret = process.env.TIDAL_CLIENT_SECRET?.trim(); +const redirectUri = process.env.TIDAL_REDIRECT_URI?.trim() || 'http://localhost:3000/callback'; +const scopes = process.env.TIDAL_SCOPES?.trim() || 'user.read playlists.read'; +const save = process.argv.includes('--save'); + +const fail = (message) => { + console.error(`\n✖ ${message}\n`); + process.exit(1); +}; + +if (!clientId) fail('Set TIDAL_CLIENT_ID (and TIDAL_CLIENT_SECRET) in .env first.'); +const redirect = new URL(redirectUri); +if (redirect.protocol !== 'http:' || !['localhost', '127.0.0.1'].includes(redirect.hostname)) { + fail('TIDAL_REDIRECT_URI must be a http://localhost address for this helper.'); +} + +const verifier = randomBytes(48).toString('base64url'); +const challenge = createHash('sha256').update(verifier).digest('base64url'); +const state = randomBytes(16).toString('base64url'); +const authorizeUrl = `${AUTHORIZE_URL}?${new URLSearchParams({ + response_type: 'code', + client_id: clientId, + redirect_uri: redirectUri, + scope: scopes, + code_challenge_method: 'S256', + code_challenge: challenge, + state, +})}`; + +async function exchangeCode(code) { + const body = new URLSearchParams({ grant_type: 'authorization_code', client_id: clientId, code, redirect_uri: redirectUri, code_verifier: verifier }); + if (clientSecret) body.set('client_secret', clientSecret); + const res = await fetch(TOKEN_URL, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body }); + const payload = await res.json().catch(() => ({})); + if (!res.ok) throw new Error(`TIDAL refused the sign-in (${res.status}): ${payload.error_description || payload.error || res.statusText}`); + if (!payload.refresh_token) throw new Error('TIDAL did not return a refresh token.'); + return payload; +} + +async function findUserId(tokens) { + const fromToken = tokens.user_id ?? tokens.user?.userId; + if (fromToken) return String(fromToken); + try { + const res = await fetch(`${API_URL}/users/me`, { headers: { Authorization: `Bearer ${tokens.access_token}`, Accept: 'application/vnd.api+json' } }); + if (res.ok) return (await res.json())?.data?.id ?? null; + } catch { + // Not essential: with a refresh token the app can use "me". + } + return null; +} + +function saveToEnv(values) { + const lines = existsSync('.env') ? readFileSync('.env', 'utf8').split('\n') : []; + for (const [key, value] of Object.entries(values)) { + if (!value) continue; + const index = lines.findIndex((line) => line.startsWith(`${key}=`)); + if (index === -1) lines.push(`${key}=${value}`); + else lines[index] = `${key}=${value}`; + } + writeFileSync('.env', `${lines.join('\n').replace(/\n*$/, '')}\n`, { mode: 0o600 }); +} + +const page = (title, message) => + `${title}

${title}

${message}

`; + +const server = createServer(async (req, res) => { + const url = new URL(req.url, redirectUri); + if (url.pathname !== redirect.pathname) return res.writeHead(404).end(); + + const respond = (status, title, message) => res.writeHead(status, { 'Content-Type': 'text/html; charset=utf-8' }).end(page(title, message)); + try { + if (url.searchParams.get('error')) throw new Error(`TIDAL said: ${url.searchParams.get('error_description') || url.searchParams.get('error')}`); + if (url.searchParams.get('state') !== state) throw new Error('The sign-in response did not match this request. Please run the command again.'); + const code = url.searchParams.get('code'); + if (!code) throw new Error('TIDAL did not send an authorisation code.'); + + const tokens = await exchangeCode(code); + const userId = await findUserId(tokens); + respond(200, 'Signed in ✓', 'You can close this tab and return to the terminal.'); + + console.log('\n✔ Signed in to TIDAL.\n'); + if (save) { + saveToEnv({ TIDAL_REFRESH_TOKEN: tokens.refresh_token, TIDAL_USER_ID: userId }); + console.log('Saved TIDAL_REFRESH_TOKEN' + (userId ? ' and TIDAL_USER_ID' : '') + ' to .env.'); + } else { + console.log('Add these to .env (and to your host’s environment settings):\n'); + console.log(` TIDAL_REFRESH_TOKEN=${tokens.refresh_token}`); + if (userId) console.log(` TIDAL_USER_ID=${userId}`); + } + console.log('\nKeep the refresh token secret: it grants read access to your TIDAL account.\n'); + server.close(() => process.exit(0)); + } catch (error) { + respond(400, 'Sign-in failed', error.message); + server.close(() => fail(error.message)); + } +}); + +server.on('error', (error) => { + fail(error.code === 'EADDRINUSE' ? `Port ${redirect.port} is in use. Stop the app (or whatever uses it) and try again.` : error.message); +}); + +server.listen(Number(redirect.port) || 80, '127.0.0.1', () => { + console.log('\nOpen this link to sign in to TIDAL:\n'); + console.log(` ${authorizeUrl}\n`); + console.log(`Waiting for TIDAL to redirect back to ${redirectUri} …`); + setTimeout(() => server.close(() => fail('Timed out waiting for the sign-in. Run the command again.')), TIMEOUT_MS).unref(); +}); diff --git a/src/catalogue.js b/src/catalogue.js new file mode 100644 index 00000000..905e8d36 --- /dev/null +++ b/src/catalogue.js @@ -0,0 +1,162 @@ +import { createHash } from 'node:crypto'; +import { mkdir, readFile, rename, writeFile } from 'node:fs/promises'; +import { dirname } from 'node:path'; +import { CatalogueUnavailableError, TidalAuthError } from './errors.js'; + +// Bump when the record shape changes, so old snapshots on disk are ignored. +const SNAPSHOT_VERSION = 1; + +/** Content-derived version of the whole catalogue: identical data ⇒ identical etag, across restarts. */ +export function catalogueEtag(records) { + const hash = createHash('sha256'); + for (const record of records) hash.update(`${record.id}:${record.rev}\n`); + return hash.digest('base64url').slice(0, 16); +} + +function buildSnapshot(records, fetchedAt) { + return { + records, + byId: new Map(records.map((record) => [record.id, record])), + manifest: records.map((record) => [record.id, record.rev]), + etag: catalogueEtag(records), + fetchedAt, + }; +} + +const isValidRecord = (record) => typeof record?.id === 'string' && typeof record?.rev === 'string' && typeof record?.title === 'string'; + +/** + * The server's copy of the playlists. + * + * - Serves from memory; once older than `ttlMs`, the next request triggers a + * background refresh and is answered immediately with the current copy. + * - Persists a last-known-good snapshot to disk, so restarts are instant and + * a TIDAL outage doesn't take the site down. + * - Backs off exponentially while TIDAL is failing. + */ +/** + * `background(promise)` keeps work going after a response has been sent. On + * Vercel that is `waitUntil`, without which a function may be frozen mid-refresh. + */ +export function createCatalogue({ load, ttlMs, snapshotPath, logger, reporter, now = Date.now, minRetryMs = 30_000, background = () => {} }) { + let snapshot = null; + let refreshing = null; + let failures = 0; + let lastError = null; + let nextAttemptAt = 0; + + async function persist(snap) { + if (!snapshotPath) return; + const tmp = `${snapshotPath}.${process.pid}.tmp`; + await mkdir(dirname(snapshotPath), { recursive: true }); + await writeFile(tmp, JSON.stringify({ version: SNAPSHOT_VERSION, fetchedAt: snap.fetchedAt, records: snap.records })); + await rename(tmp, snapshotPath); + } + + async function restore() { + if (!snapshotPath) return false; + let raw; + try { + raw = await readFile(snapshotPath, 'utf8'); + } catch (err) { + if (err.code !== 'ENOENT') logger.warn({ err }, 'Could not read playlist snapshot'); + return false; + } + try { + const data = JSON.parse(raw); + if (data?.version !== SNAPSHOT_VERSION || !Array.isArray(data.records) || !data.records.length || !data.records.every(isValidRecord)) { + logger.info('Ignoring playlist snapshot that is empty or from an older version'); + return false; + } + snapshot = buildSnapshot(data.records, Number(data.fetchedAt) || 0); + logger.info({ count: snapshot.records.length, ageSeconds: ageSeconds() }, 'Restored playlist snapshot from disk'); + return true; + } catch (err) { + logger.warn({ err }, 'Playlist snapshot is corrupt; ignoring it'); + return false; + } + } + + const ageSeconds = () => (snapshot ? Math.round((now() - snapshot.fetchedAt) / 1000) : null); + const isStale = () => !snapshot || now() - snapshot.fetchedAt >= ttlMs; + + function refresh() { + refreshing ??= (async () => { + const startedAt = now(); + try { + const records = await load(); + const changed = snapshot?.etag !== catalogueEtag(records); + snapshot = buildSnapshot(records, now()); + failures = 0; + lastError = null; + nextAttemptAt = 0; + logger.info({ count: records.length, etag: snapshot.etag, changed, ms: now() - startedAt }, 'Playlist catalogue refreshed'); + await persist(snapshot).catch((err) => logger.warn({ err }, 'Could not save playlist snapshot')); + return snapshot; + } catch (error) { + failures++; + lastError = { code: error.code ?? 'UNKNOWN', message: error.message, at: new Date(now()).toISOString() }; + nextAttemptAt = now() + Math.min(minRetryMs * 2 ** (failures - 1), ttlMs); + // Credentials problems never fix themselves; a blip while we still have data is just a warning. + const serious = !snapshot || error instanceof TidalAuthError || failures >= 3; + reporter.exception(error, { + level: serious ? 'error' : 'warn', + msg: snapshot ? 'Could not refresh playlists from TIDAL; still serving the previous copy' : 'Could not load playlists from TIDAL', + tags: { component: 'catalogue' }, + extra: { failures, retryInSeconds: Math.round((nextAttemptAt - now()) / 1000) }, + }); + throw error; + } finally { + refreshing = null; + } + })(); + return refreshing; + } + + const unavailable = (cause) => { + const error = new CatalogueUnavailableError(cause); + error.retryAfterSeconds = Math.max(5, Math.ceil((nextAttemptAt - now()) / 1000)); + return error; + }; + + return { + /** Restores the disk snapshot and starts fetching fresh data without waiting for it. */ + async start() { + await restore(); + if (isStale()) background(refresh().catch(() => {})); + }, + + /** The current snapshot. Only waits for TIDAL when there is nothing to serve yet. */ + async get() { + if (snapshot) { + if (isStale() && !refreshing && now() >= nextAttemptAt) background(refresh().catch(() => {})); + return snapshot; + } + if (!refreshing && now() < nextAttemptAt) throw unavailable(lastError); + try { + return await (refreshing ?? refresh()); + } catch (error) { + throw unavailable(error); + } + }, + + /** The current snapshot or null, without waiting or triggering a refresh. */ + peek() { + return snapshot; + }, + + status() { + return { + ready: Boolean(snapshot), + count: snapshot?.records.length ?? 0, + etag: snapshot?.etag ?? null, + fetchedAt: snapshot ? new Date(snapshot.fetchedAt).toISOString() : null, + ageSeconds: ageSeconds(), + stale: isStale(), + refreshing: Boolean(refreshing), + consecutiveFailures: failures, + lastError, + }; + }, + }; +} diff --git a/src/config.js b/src/config.js new file mode 100644 index 00000000..07a4349a --- /dev/null +++ b/src/config.js @@ -0,0 +1,104 @@ +import { existsSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { ConfigError } from './errors.js'; + +const MINUTE = 60_000; + +/** Loads `.env` (if present) into process.env without overriding real env vars. */ +export function loadEnvFile(path = '.env') { + if (existsSync(path)) process.loadEnvFile(path); +} + +const toInt = (value, fallback, name) => { + if (value === undefined || value === '') return fallback; + const n = Number(value); + if (!Number.isInteger(n) || n < 0) throw new ConfigError(`${name} must be a whole number, got "${value}".`); + return n; +}; + +const toUrl = (value, name) => { + if (!value) return null; + try { + return new URL(value).href.replace(/\/$/, ''); + } catch { + throw new ConfigError(`${name} must be an absolute URL, got "${value}".`); + } +}; + +/** + * Reads and validates configuration. Throws a ConfigError listing every + * problem at once, so a misconfigured deploy fails fast with a clear message. + */ +export function readConfig(env = process.env) { + const problems = []; + const mock = env.TIDAL_MOCK === '1' || env.TIDAL_MOCK === 'true'; + + const tidal = { + clientId: env.TIDAL_CLIENT_ID?.trim() || '', + clientSecret: env.TIDAL_CLIENT_SECRET?.trim() || '', + userId: env.TIDAL_USER_ID?.trim() || '', + refreshToken: env.TIDAL_REFRESH_TOKEN?.trim() || '', + countryCode: (env.TIDAL_COUNTRY_CODE?.trim() || 'GB').toUpperCase(), + apiBaseUrl: 'https://openapi.tidal.com/v2', + tokenUrl: 'https://auth.tidal.com/v1/oauth2/token', + mock, + }; + + if (!mock) { + if (!tidal.clientId || !tidal.clientSecret) { + const legacy = env.CLIENT_ID || env.CLIENT_SECRET + ? ' Found CLIENT_ID/CLIENT_SECRET, which were the old Spotify settings — rename them to TIDAL_CLIENT_ID/TIDAL_CLIENT_SECRET with your TIDAL values.' + : ''; + problems.push(`TIDAL_CLIENT_ID and TIDAL_CLIENT_SECRET are required.${legacy}`); + } + // With a refresh token the owner is known ("me"); otherwise we must be told whose playlists to list. + if (!tidal.userId && !tidal.refreshToken) { + problems.push('TIDAL_USER_ID is required (run `npm run tidal:login` to find it).'); + } + if (!/^[A-Z]{2}$/.test(tidal.countryCode)) { + problems.push(`TIDAL_COUNTRY_CODE must be a two-letter country code, got "${tidal.countryCode}".`); + } + } + + // Vercel sets VERCEL=1 at build and run time, plus the VERCEL_* values used below. + const onVercel = Boolean(env.VERCEL); + const vercelUrl = env.VERCEL_PROJECT_PRODUCTION_URL ? `https://${env.VERCEL_PROJECT_PRODUCTION_URL}` : null; + + let config; + try { + config = { + env: env.VERCEL_ENV || env.NODE_ENV || 'development', + onVercel, + isProduction: env.NODE_ENV === 'production', + port: toInt(env.PORT, 3000, 'PORT'), + logLevel: env.LOG_LEVEL || (env.NODE_ENV === 'test' ? 'silent' : 'info'), + trustProxy: toInt(env.TRUST_PROXY, 1, 'TRUST_PROXY'), + tidal, + catalogue: { + // CACHE_DURATION keeps the name used by the previous version of the app. + ttlMs: Math.max(toInt(env.CACHE_DURATION, 10 * MINUTE, 'CACHE_DURATION'), 30_000), + // Only the temp directory is writable on Vercel. + snapshotPath: env.SNAPSHOT_PATH || (onVercel ? join(tmpdir(), 'selections', 'playlists.json') : '.cache/playlists.json'), + // How long Vercel's CDN may serve API responses before asking the function again. + cdnMaxAgeSeconds: toInt(env.CDN_CACHE_SECONDS, 600, 'CDN_CACHE_SECONDS'), + }, + site: { + url: toUrl(env.SITE_URL, 'SITE_URL') || vercelUrl || 'http://localhost:3000', + profileUrl: toUrl(env.TIDAL_PROFILE_URL, 'TIDAL_PROFILE_URL'), + }, + sentry: { + dsn: env.SENTRY_DSN?.trim() || '', + release: env.VERCEL_GIT_COMMIT_SHA || env.SOURCE_VERSION || undefined, + }, + }; + } catch (error) { + if (!(error instanceof ConfigError)) throw error; + problems.push(error.message); + } + + if (problems.length) { + throw new ConfigError(`Invalid configuration:\n - ${problems.join('\n - ')}\nSee .env.example for every setting.`); + } + return config; +} diff --git a/src/errors.js b/src/errors.js new file mode 100644 index 00000000..b9942c71 --- /dev/null +++ b/src/errors.js @@ -0,0 +1,76 @@ +/** + * Base class for errors we raise on purpose. `code` is a stable identifier for + * logs and API responses; `status` is the HTTP status to answer with; `expose` + * marks messages that are safe to show to visitors. + */ +export class AppError extends Error { + constructor(message, { code = 'INTERNAL', status = 500, expose = false, cause, details } = {}) { + super(message, { cause }); + this.name = new.target.name; + this.code = code; + this.status = status; + this.expose = expose; + if (details) this.details = details; + } +} + +export class ConfigError extends AppError { + constructor(message) { + super(message, { code: 'CONFIG_INVALID' }); + } +} + +/** A failed call to the TIDAL API or token endpoint. Never carries tokens. */ +export class TidalError extends AppError { + constructor(message, { status, tidalCode, subStatus, requestId, url, retryable = false, cause } = {}) { + super(message, { code: 'TIDAL_ERROR', status: 502, cause }); + this.upstreamStatus = status; + this.tidalCode = tidalCode; + this.subStatus = subStatus; + this.requestId = requestId; + this.url = url; + this.retryable = retryable; + } +} + +/** TIDAL refused our credentials or their scope. Retrying will not help. */ +export class TidalAuthError extends TidalError { + constructor(message, options) { + super(message, { ...options, retryable: false }); + this.code = 'TIDAL_AUTH'; + } +} + +export class CatalogueUnavailableError extends AppError { + constructor(cause) { + super('Playlists are temporarily unavailable. Please try again shortly.', { + code: 'CATALOGUE_UNAVAILABLE', + status: 503, + expose: true, + cause, + }); + } +} + +export class BadRequestError extends AppError { + constructor(message) { + super(message, { code: 'BAD_REQUEST', status: 400, expose: true }); + } +} + +export class NotFoundError extends AppError { + constructor(message = 'Not found.') { + super(message, { code: 'NOT_FOUND', status: 404, expose: true }); + } +} + +/** Plain, loggable summary of any thrown value, including its cause chain. */ +export function serialiseError(error, depth = 0) { + if (!(error instanceof Error)) return { message: String(error) }; + const out = { name: error.name, message: error.message, stack: error.stack }; + for (const key of ['code', 'status', 'upstreamStatus', 'tidalCode', 'subStatus', 'requestId', 'url', 'details']) { + if (error[key] !== undefined) out[key] = error[key]; + } + if (error.cause && depth < 3) out.cause = serialiseError(error.cause, depth + 1); + return out; +} diff --git a/src/http/app.js b/src/http/app.js new file mode 100644 index 00000000..a0cfc100 --- /dev/null +++ b/src/http/app.js @@ -0,0 +1,244 @@ +import { randomBytes, randomUUID } from 'node:crypto'; +import { fileURLToPath } from 'node:url'; +import compression from 'compression'; +import express from 'express'; +import helmet from 'helmet'; +import { pinoHttp } from 'pino-http'; +import { CACHE_ETAG_KEY, CARD_IMAGE_SIZES, srcsetFor } from '../../public/js/constants.js'; +import { AppError, BadRequestError, NotFoundError } from '../errors.js'; +import { mockArtworkHandler } from '../tidal/mock.js'; +import { createRateLimiter, parseReports } from './reports.js'; + +const publicDir = fileURLToPath(new URL('../../public', import.meta.url)); +const viewsDir = fileURLToPath(new URL('../../views', import.meta.url)); + +const MAX_IDS_PER_REQUEST = 100; +const ID_PATTERN = /^[A-Za-z0-9-]{1,64}$/; +const REQUEST_ID_PATTERN = /^[\w.:-]{1,100}$/; + +const asyncRoute = (handler) => (req, res, next) => Promise.resolve(handler(req, res, next)).catch(next); + +function parseIds(raw) { + if (raw === undefined) return null; + const ids = [raw].flat().flatMap((value) => String(value).split(',')).map((id) => id.trim()).filter(Boolean); + if (!ids.length) throw new BadRequestError('`ids` must list at least one playlist id.'); + if (ids.length > MAX_IDS_PER_REQUEST) throw new BadRequestError(`Ask for at most ${MAX_IDS_PER_REQUEST} playlists at a time.`); + if (!ids.every((id) => ID_PATTERN.test(id))) throw new BadRequestError('`ids` contains an invalid playlist id.'); + return [...new Set(ids)]; +} + +/** Whether an If-None-Match header names this entity tag. */ +export function etagMatches(header, etag) { + if (!header) return false; + return header.split(',').some((tag) => { + const value = tag.trim().replace(/^W\//, ''); + return value === '*' || value === `"${etag}"`; + }); +} + +/** + * Sends 304 when the browser already has this version. Compared directly + * rather than via `req.fresh`, which (correctly, for HTTP caches) never says + * "fresh" when the request carries Cache-Control: no-cache — and browsers add + * that header to the app's deliberate `cache: 'no-store'` conditional requests. + */ +function sendVersioned(req, res, etag, body) { + res.set('ETag', `"${etag}"`); + if (etagMatches(req.get('if-none-match'), etag)) return res.status(304).end(); + return res.json(body); +} + +export function createApp({ config, catalogue, reporter, logger, assets }) { + const app = express(); + app.disable('x-powered-by'); + app.set('trust proxy', config.trustProxy); + app.set('view engine', 'ejs'); + app.set('views', viewsDir); + + // --- Request identity, logging, security headers ------------------------- + app.use((req, res, next) => { + const incoming = req.get('x-request-id'); + req.id = incoming && REQUEST_ID_PATTERN.test(incoming) ? incoming : randomUUID(); + res.set('X-Request-Id', req.id); + res.locals.nonce = randomBytes(16).toString('base64'); + next(); + }); + + app.use( + pinoHttp({ + logger, + genReqId: (req) => req.id, + quietReqLogger: true, + autoLogging: { ignore: (req) => req.url === '/healthz' || req.url.startsWith('/static/') || req.url.startsWith('/__mock/') || req.url.startsWith('/.well-known/') }, + customLogLevel: (req, res, err) => (err || res.statusCode >= 500 ? 'error' : res.statusCode >= 400 ? 'warn' : 'info'), + serializers: { + req: (req) => ({ method: req.method, url: req.url }), + res: (res) => ({ statusCode: res.statusCode }), + }, + }), + ); + + app.use( + helmet({ + contentSecurityPolicy: { + useDefaults: false, + directives: { + defaultSrc: ["'self'"], + scriptSrc: ["'self'", (req, res) => `'nonce-${res.locals.nonce}'`], + styleSrc: ["'self'"], + imgSrc: ["'self'", 'data:', 'https://*.tidal.com'], + fontSrc: ["'self'"], + connectSrc: ["'self'"], + frameSrc: ['https://embed.tidal.com'], + objectSrc: ["'none'"], + baseUri: ["'none'"], + formAction: ["'self'"], + frameAncestors: ["'none'"], + reportUri: ['/api/reports'], + reportTo: ['csp'], + }, + }, + // Keep the default browser behaviour so TIDAL's embed sees which site it is on. + referrerPolicy: { policy: 'strict-origin-when-cross-origin' }, + strictTransportSecurity: config.isProduction ? undefined : false, + }), + ); + app.use((req, res, next) => { + // Absolute URL: browsers that reject the endpoint would also stop using report-uri. + res.set('Reporting-Endpoints', `csp="${req.protocol}://${req.get('host')}/api/reports"`); + res.set('Permissions-Policy', 'camera=(), microphone=(), geolocation=(), payment=(), usb=()'); + next(); + }); + + app.use(compression()); + + // --- Static files ---------------------------------------------------------- + const staticOptions = { index: false, redirect: false }; + const immutable = express.static(publicDir, { ...staticOptions, immutable: true, maxAge: '365d' }); + const revalidate = express.static(publicDir, { ...staticOptions, maxAge: 0 }); + app.use('/static/:version', (req, res, next) => + (req.params.version === assets.version && assets.version !== 'dev' ? immutable : revalidate)(req, res, next), + ); + // Stable URL for the social sharing image. + app.use('/media', express.static(`${publicDir}/media`, { ...staticOptions, maxAge: '1d' })); + app.get('/favicon.ico', (req, res) => res.redirect(301, '/media/avatar.jpg')); + app.get('/robots.txt', (req, res) => res.type('text/plain').set('Cache-Control', 'public, max-age=86400').send('User-agent: *\nAllow: /\n')); + if (config.tidal.mock) app.get('/__mock/art/:seed.svg', mockArtworkHandler); + + // --- Health ------------------------------------------------------------------ + app.get('/healthz', (req, res) => { + const catalogueStatus = catalogue.status(); + const status = !catalogueStatus.ready ? (catalogueStatus.refreshing ? 'starting' : 'unavailable') : catalogueStatus.lastError ? 'degraded' : 'ok'; + // Always 200 while the process can serve; the body says how healthy the data is. + res.set('Cache-Control', 'no-store').json({ + status, + version: assets.version, + uptimeSeconds: Math.round(process.uptime()), + errorReporting: reporter.sentryEnabled ? 'sentry' : 'logs', + catalogue: { ...catalogueStatus, lastError: catalogueStatus.lastError && { code: catalogueStatus.lastError.code, at: catalogueStatus.lastError.at } }, + }); + }); + + // --- API --------------------------------------------------------------------- + const api = express.Router(); + api.use((req, res, next) => { + res.set('Cache-Control', 'no-cache'); + next(); + }); + + // On Vercel, let the CDN answer repeat requests for playlist data, refreshing + // in the background, so visitors almost never wait for TIDAL. Browsers still + // revalidate every time (Cache-Control: no-cache); only Vercel reads this header. + const { cdnMaxAgeSeconds } = config.catalogue; + const cdnCache = (res) => { + if (config.onVercel && cdnMaxAgeSeconds > 0) { + res.set('Vercel-CDN-Cache-Control', `max-age=${cdnMaxAgeSeconds}, stale-while-revalidate=86400`); + } + }; + + // Ids and revisions of every playlist. Browsers compare it with their cache + // to fetch only what is new or changed; usually it is a bodiless 304. + api.get( + '/playlists/manifest', + asyncRoute(async (req, res) => { + const snapshot = await catalogue.get(); + cdnCache(res); + sendVersioned(req, res, snapshot.etag, { etag: snapshot.etag, count: snapshot.records.length, items: snapshot.manifest }); + }), + ); + + // All playlists, or just `?ids=a,b,c`. + api.get( + '/playlists', + asyncRoute(async (req, res) => { + const ids = parseIds(req.query.ids); + const snapshot = await catalogue.get(); + cdnCache(res); + if (!ids) return sendVersioned(req, res, snapshot.etag, { etag: snapshot.etag, playlists: snapshot.records }); + const playlists = ids.map((id) => snapshot.byId.get(id)).filter(Boolean); + const missing = ids.filter((id) => !snapshot.byId.has(id)); + res.json({ etag: snapshot.etag, playlists, missing }); + }), + ); + + const allowReport = createRateLimiter(); + api.post( + '/reports', + (req, res, next) => (allowReport(req.ip) ? next() : res.status(429).end()), + express.json({ type: ['application/json', 'application/csp-report', 'application/reports+json'], limit: '16kb' }), + (req, res) => { + for (const report of parseReports(req.body)) { + if (report.kind === 'csp') reporter.cspViolation(report, { requestId: req.id }); + else reporter.browserError(report, { requestId: req.id }); + } + res.status(204).end(); + }, + ); + + api.use((req, res, next) => next(new NotFoundError('No such API endpoint.'))); + app.use('/api', api); + + // --- Page ---------------------------------------------------------------------- + app.get('/', (req, res) => { + // On a plain visit the newest playlist is the first card: start its artwork + // download now rather than after the scripts run. + const plainVisit = !Object.keys(req.query).length; + const first = plainVisit ? catalogue.peek()?.records[0] : null; + res.set('Cache-Control', 'no-cache'); + res.render('index', { + nonce: res.locals.nonce, + asset: assets.url, + modules: assets.modules, + release: assets.version, + site: config.site, + preloadArt: first?.art ? { srcset: srcsetFor(first.art), sizes: CARD_IMAGE_SIZES } : null, + cacheEtagKey: CACHE_ETAG_KEY, + year: new Date().getFullYear(), + }); + }); + + // --- Errors -------------------------------------------------------------------- + app.use((req, res, next) => next(new NotFoundError())); + + app.use((err, req, res, next) => { + const status = Number.isInteger(err.status) && err.status >= 400 && err.status < 600 ? err.status : 500; + const exposed = err instanceof AppError ? err.expose : status < 500 && err.expose !== false; + const code = err.code && typeof err.code === 'string' ? err.code : status >= 500 ? 'INTERNAL' : 'BAD_REQUEST'; + + if (status >= 500 && code !== 'CATALOGUE_UNAVAILABLE') { + // CATALOGUE_UNAVAILABLE was already reported when the refresh failed. + reporter.exception(err, { msg: `Request failed: ${req.method} ${req.originalUrl}`, extra: { requestId: req.id } }); + } + if (res.headersSent) return next(err); + if (err.retryAfterSeconds) res.set('Retry-After', String(err.retryAfterSeconds)); + + const message = exposed ? err.message : status >= 500 ? 'Something went wrong on our side. Please try again.' : 'Bad request.'; + res.status(status).set('Cache-Control', 'no-store'); + if (req.originalUrl.startsWith('/api/') || !req.accepts('html')) { + return res.json({ error: { code, message, requestId: req.id } }); + } + res.render('error', { status, message, requestId: req.id, asset: assets.url }); + }); + + return app; +} diff --git a/src/http/assets.js b/src/http/assets.js new file mode 100644 index 00000000..ace8bee4 --- /dev/null +++ b/src/http/assets.js @@ -0,0 +1,39 @@ +import { createHash } from 'node:crypto'; +import { readdir, readFile } from 'node:fs/promises'; +import { join, relative, sep } from 'node:path'; + +async function listFiles(dir) { + const entries = await readdir(dir, { withFileTypes: true, recursive: true }); + return entries + .filter((entry) => entry.isFile() && !entry.name.startsWith('.')) + .map((entry) => join(entry.parentPath, entry.name)) + .sort(); +} + +/** + * Versioned URLs for everything in /public, without a build step. + * + * Files are served under /static//…, where the version is a hash of + * all their contents. Because ES module imports and CSS url()s are relative, + * they inherit the version automatically, so every asset can be cached + * forever and a deploy that changes anything changes every URL. + */ +export async function createAssets({ publicDir, versioned }) { + const files = await listFiles(publicDir); + const toPath = (file) => relative(publicDir, file).split(sep).join('/'); + + let version = 'dev'; + if (versioned) { + const hash = createHash('sha256'); + for (const file of files) hash.update(toPath(file)).update(await readFile(file)); + version = hash.digest('hex').slice(0, 10); + } + + const url = (path) => `/static/${version}/${path.replace(/^\//, '')}`; + return { + version, + url, + /** Every browser module, for so imports don't load in a waterfall. */ + modules: files.map(toPath).filter((path) => path.startsWith('js/') && path.endsWith('.js')).map(url), + }; +} diff --git a/src/http/reports.js b/src/http/reports.js new file mode 100644 index 00000000..bce081e3 --- /dev/null +++ b/src/http/reports.js @@ -0,0 +1,92 @@ +// Parsing for POST /api/reports. Everything here is untrusted visitor input: +// accept only known fields, cap every string, never echo anything back. + +const clip = (value, max) => (typeof value === 'string' ? value.slice(0, max) : undefined); +const clipNumber = (value) => (Number.isFinite(value) ? value : undefined); + +function clipContext(context) { + if (!context || typeof context !== 'object' || Array.isArray(context)) return undefined; + const out = {}; + for (const [key, value] of Object.entries(context).slice(0, 12)) { + if (['string', 'number', 'boolean'].includes(typeof value)) out[clip(key, 40)] = typeof value === 'string' ? clip(value, 300) : value; + } + return out; +} + +const clientError = (body) => ({ + kind: 'client-error', + name: clip(body.name, 100) || 'Error', + message: clip(body.message, 500) || '(no message)', + stack: clip(body.stack, 4000), + url: clip(body.url, 500), + userAgent: clip(body.userAgent, 300), + release: clip(body.release, 40), + context: clipContext(body.context), +}); + +const cspViolation = ({ documentURL, blockedURL, directive, sourceFile, lineNumber, disposition }) => ({ + kind: 'csp', + documentURL: clip(documentURL, 500), + blockedURL: clip(blockedURL, 500) || '(unknown)', + directive: clip(directive, 100) || '(unknown)', + sourceFile: clip(sourceFile, 500), + lineNumber: clipNumber(lineNumber), + disposition: clip(disposition, 20), +}); + +/** + * Normalises any of the three report formats browsers send: + * our own client-error beacon, legacy `report-uri` CSP reports, and the + * Reporting API (`report-to`) batch format. Returns at most 10 reports. + */ +export function parseReports(body) { + if (Array.isArray(body)) { + return body + .slice(0, 10) + .filter((report) => report?.type === 'csp-violation' && report.body) + .map(({ body: b }) => + cspViolation({ + documentURL: b.documentURL, + blockedURL: b.blockedURL, + directive: b.effectiveDirective, + sourceFile: b.sourceFile, + lineNumber: b.lineNumber, + disposition: b.disposition, + }), + ); + } + if (body?.['csp-report']) { + const r = body['csp-report']; + return [ + cspViolation({ + documentURL: r['document-uri'], + blockedURL: r['blocked-uri'], + directive: r['effective-directive'] || r['violated-directive'], + sourceFile: r['source-file'], + lineNumber: r['line-number'], + disposition: r.disposition, + }), + ]; + } + if (body?.type === 'client-error') return [clientError(body)]; + return []; +} + +/** Fixed-window rate limiter: `perKey` events per key and `total` overall, per window. */ +export function createRateLimiter({ perKey = 20, total = 600, windowMs = 60_000, now = Date.now } = {}) { + let windowStart = now(); + let overall = 0; + const counts = new Map(); + + return function allow(key) { + if (now() - windowStart >= windowMs) { + windowStart = now(); + overall = 0; + counts.clear(); + } + const count = (counts.get(key) ?? 0) + 1; + counts.set(key, count); + overall++; + return count <= perKey && overall <= total; + }; +} diff --git a/src/logger.js b/src/logger.js new file mode 100644 index 00000000..3b11ebeb --- /dev/null +++ b/src/logger.js @@ -0,0 +1,37 @@ +import { createRequire } from 'node:module'; +import pino from 'pino'; +import { serialiseError } from './errors.js'; + +const hasPrettyPrinter = () => { + try { + createRequire(import.meta.url).resolve('pino-pretty'); + return true; + } catch { + return false; + } +}; + +/** + * Structured JSON logs in production (searchable in the host's log viewer), + * readable coloured logs locally. Secrets are redacted wherever they appear. + */ +export function createLogger({ level = 'info', pretty = false } = {}) { + return pino({ + level, + base: undefined, + serializers: { err: serialiseError, error: serialiseError }, + redact: { + paths: [ + 'req.headers.authorization', + 'req.headers.cookie', + '*.access_token', + '*.refresh_token', + '*.client_secret', + ], + censor: '[redacted]', + }, + ...(pretty && hasPrettyPrinter() + ? { transport: { target: 'pino-pretty', options: { translateTime: 'HH:MM:ss', ignore: 'pid,hostname' } } } + : {}), + }); +} diff --git a/src/reporting.js b/src/reporting.js new file mode 100644 index 00000000..e91f5e4f --- /dev/null +++ b/src/reporting.js @@ -0,0 +1,85 @@ +import { serialiseError } from './errors.js'; + +// Sentry's own process handlers would duplicate ours (see serve() in site.js). +const SKIPPED_SENTRY_INTEGRATIONS = new Set(['OnUncaughtException', 'OnUnhandledRejection']); + +/** + * One place for every error, from the server or the browser. Always writes a + * structured log line; also forwards to Sentry when SENTRY_DSN is set. Sentry + * is loaded lazily, so it costs nothing when unused. + */ +export async function createReporter({ logger, dsn, release, environment, background = () => {} }) { + // Serverless functions can be frozen once they respond: send reports before that. + const sendSoon = () => sentry && background(sentry.flush(2000).catch(() => false)); + + let sentry = null; + + if (dsn) { + try { + sentry = await import('@sentry/node'); + sentry.init({ + dsn, + release, + environment, + sendDefaultPii: false, + integrations: (defaults) => defaults.filter((i) => !SKIPPED_SENTRY_INTEGRATIONS.has(i.name)), + }); + logger.info('Error reporting to Sentry is enabled'); + } catch (err) { + sentry = null; + logger.error({ err }, 'Could not start Sentry; errors will only be logged'); + } + } + + return { + get sentryEnabled() { + return Boolean(sentry); + }, + + /** Server-side exception. `level` is 'error' (default), 'warn' or 'fatal'. */ + exception(err, { level = 'error', msg, tags, extra } = {}) { + logger[level]({ err, tags, ...extra }, msg ?? err?.message ?? 'Unknown error'); + sentry?.captureException(err, { level: level === 'warn' ? 'warning' : level, tags, extra }); + sendSoon(); + }, + + /** Error reported by a visitor's browser via POST /api/reports. */ + browserError(report, { requestId }) { + logger.warn({ source: 'browser', report, requestId }, `Browser error: ${report.name}: ${report.message}`); + sentry?.captureEvent({ + level: 'error', + platform: 'javascript', + release: report.release || release, + exception: { values: [{ type: report.name, value: report.message }] }, + fingerprint: ['browser', report.name, report.message], + tags: { source: 'browser', ...(report.context?.where ? { where: String(report.context.where) } : {}) }, + request: { url: report.url, headers: { 'User-Agent': report.userAgent } }, + extra: { stack: report.stack, context: report.context, requestId }, + }); + sendSoon(); + }, + + /** Content-Security-Policy violation reported by a browser. */ + cspViolation(violation, { requestId }) { + logger.warn({ source: 'csp', violation, requestId }, `CSP blocked ${violation.blockedURL} (${violation.directive})`); + sentry?.captureEvent({ + level: 'warning', + message: `CSP violation: ${violation.directive} blocked ${violation.blockedURL}`, + fingerprint: ['csp', violation.directive, violation.blockedURL], + tags: { source: 'csp' }, + extra: { violation, requestId }, + }); + sendSoon(); + }, + + async flush(timeoutMs = 2000) { + if (!sentry) return true; + try { + return await sentry.flush(timeoutMs); + } catch (err) { + logger.warn({ err: serialiseError(err) }, 'Sentry flush failed'); + return false; + } + }, + }; +} diff --git a/src/site.js b/src/site.js new file mode 100644 index 00000000..b480845a --- /dev/null +++ b/src/site.js @@ -0,0 +1,104 @@ +import { fileURLToPath } from 'node:url'; +import { waitUntil } from '@vercel/functions'; +import { createCatalogue } from './catalogue.js'; +import { loadEnvFile, readConfig } from './config.js'; +import { createAssets } from './http/assets.js'; +import { createApp } from './http/app.js'; +import { createLogger } from './logger.js'; +import { createReporter } from './reporting.js'; +import { createTokenProvider } from './tidal/auth.js'; +import { createTidalClient } from './tidal/client.js'; +import { createMockFetch } from './tidal/mock.js'; +import { fetchPublicPlaylists } from './tidal/playlists.js'; + +const SHUTDOWN_TIMEOUT_MS = 10_000; + +/** + * Builds the whole site: configuration, logging, error reporting, TIDAL and + * the Express app. Starts loading playlists, but does not listen on a port, + * so the same app runs as a Vercel Function or as a normal server. + * Throws a ConfigError when settings are missing or invalid. + */ +export async function createSite() { + loadEnvFile(); + const config = readConfig(); + + // Keeps background work (refreshes, error reports) alive after a response on Vercel; a no-op elsewhere. + const background = (promise) => waitUntil(promise); + + const logger = createLogger({ level: config.logLevel, pretty: !config.isProduction }); + const reporter = await createReporter({ + logger, + dsn: config.sentry.dsn, + release: config.sentry.release, + environment: config.env, + background, + }); + + const { tidal } = config; + const fetchImpl = tidal.mock ? createMockFetch() : globalThis.fetch; + if (tidal.mock) logger.warn('TIDAL_MOCK is on: serving generated demo playlists, not your TIDAL account'); + + const tokens = createTokenProvider({ ...tidal, fetch: fetchImpl, logger }); + const client = createTidalClient({ baseUrl: tidal.apiBaseUrl, tokens, fetch: fetchImpl, logger, pageDelayMs: tidal.mock ? 0 : 400 }); + const ownerId = tidal.userId || 'me'; + logger.info({ authMode: tokens.mode, ownerId, onVercel: config.onVercel }, 'TIDAL configured'); + + const catalogue = createCatalogue({ + load: () => fetchPublicPlaylists({ client, ownerId, countryCode: tidal.countryCode, authMode: tokens.mode, logger }), + ttlMs: config.catalogue.ttlMs, + snapshotPath: tidal.mock ? null : config.catalogue.snapshotPath, + logger, + reporter, + background, + }); + + const assets = await createAssets({ + publicDir: fileURLToPath(new URL('../public', import.meta.url)), + versioned: config.isProduction, + }); + + const app = createApp({ config, catalogue, reporter, logger, assets }); + await catalogue.start(); + return { app, config, logger, reporter, assets }; +} + +/** + * Runs the site as a long-lived server (local development, or any non-Vercel host): + * listens on PORT, exits after reporting an unexpected crash, and shuts down gracefully. + */ +export function serve({ app, config, logger, reporter, assets }) { + // Last line of defence: record the crash, then exit and let the host restart us + // (continuing after an unknown failure risks serving from a corrupt state). + let crashing = false; + const crash = async (error, origin) => { + if (crashing) return; + crashing = true; + reporter.exception(error, { level: 'fatal', msg: `Fatal ${origin}; exiting`, tags: { origin } }); + await reporter.flush(2000); + process.exit(1); + }; + process.on('uncaughtException', (error) => crash(error, 'uncaughtException')); + process.on('unhandledRejection', (reason) => crash(reason instanceof Error ? reason : new Error(String(reason)), 'unhandledRejection')); + + const server = app.listen(config.port, () => { + logger.info({ port: config.port, assetVersion: assets.version, env: config.env }, `Listening on http://localhost:${config.port}`); + }); + server.on('error', (error) => crash(error, 'server')); + // Outlive load-balancer idle connections so they are never cut mid-request. + server.keepAliveTimeout = 65_000; + server.headersTimeout = 66_000; + + const shutdown = (signal) => { + logger.info({ signal }, 'Shutting down'); + const force = setTimeout(() => process.exit(1), SHUTDOWN_TIMEOUT_MS); + force.unref(); + server.close(async () => { + await reporter.flush(2000); + process.exit(0); + }); + server.closeIdleConnections(); + }; + process.once('SIGTERM', shutdown); + process.once('SIGINT', shutdown); +} diff --git a/src/tidal/auth.js b/src/tidal/auth.js new file mode 100644 index 00000000..3fbb472a --- /dev/null +++ b/src/tidal/auth.js @@ -0,0 +1,91 @@ +import { TidalAuthError, TidalError } from '../errors.js'; +import { withRetry } from './retry.js'; + +const EXPIRY_MARGIN_MS = 60_000; + +/** + * Supplies TIDAL access tokens, cached until shortly before they expire. + * Concurrent callers share one in-flight token request. + * + * - 'client' mode: client-credentials grant (no user involved). + * - 'user' mode: refresh-token grant, for when TIDAL requires a user's + * authorisation to read playlists. See scripts/tidal-login.js. + */ +export function createTokenProvider({ + clientId, + clientSecret, + refreshToken, + tokenUrl, + fetch = globalThis.fetch, + logger, + now = Date.now, + retryOptions, +}) { + const mode = refreshToken ? 'user' : 'client'; + let currentRefreshToken = refreshToken; + let cached = null; + let pending = null; + + async function requestToken() { + const headers = { 'Content-Type': 'application/x-www-form-urlencoded', Accept: 'application/json' }; + let body; + if (mode === 'client') { + headers.Authorization = `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString('base64')}`; + body = new URLSearchParams({ grant_type: 'client_credentials' }); + } else { + body = new URLSearchParams({ + grant_type: 'refresh_token', + refresh_token: currentRefreshToken, + client_id: clientId, + client_secret: clientSecret, + }); + } + + let res; + try { + res = await fetch(tokenUrl, { method: 'POST', headers, body, signal: AbortSignal.timeout(10_000) }); + } catch (cause) { + throw new TidalError(`Could not reach the TIDAL token endpoint: ${cause.message}`, { url: tokenUrl, retryable: true, cause }); + } + + const payload = await res.json().catch(() => ({})); + if (!res.ok) { + const reason = payload.error_description || payload.error || res.statusText || `HTTP ${res.status}`; + const details = { status: res.status, tidalCode: payload.error, subStatus: payload.sub_status, url: tokenUrl }; + if (res.status === 429 || res.status >= 500) { + throw new TidalError(`TIDAL token endpoint failed (${res.status}): ${reason}`, { ...details, retryable: true }); + } + const fix = mode === 'client' + ? 'Check TIDAL_CLIENT_ID and TIDAL_CLIENT_SECRET match your app at developer.tidal.com.' + : 'TIDAL_REFRESH_TOKEN was rejected — run `npm run tidal:login` to get a new one.'; + throw new TidalAuthError(`TIDAL refused to issue an access token (${res.status}: ${reason}). ${fix}`, details); + } + if (!payload.access_token) { + throw new TidalAuthError('TIDAL token response did not include an access token.', { url: tokenUrl }); + } + + if (mode === 'user' && payload.refresh_token && payload.refresh_token !== currentRefreshToken) { + currentRefreshToken = payload.refresh_token; + logger?.warn('TIDAL issued a new refresh token. If playlists stop loading after a restart, run `npm run tidal:login` again.'); + } + + const expiresInSeconds = Number(payload.expires_in) > 0 ? Number(payload.expires_in) : 3600; + cached = { accessToken: payload.access_token, expiresAt: now() + expiresInSeconds * 1000 }; + logger?.debug({ mode, expiresInSeconds }, 'Obtained TIDAL access token'); + return cached.accessToken; + } + + return { + mode, + async getToken() { + if (cached && cached.expiresAt - EXPIRY_MARGIN_MS > now()) return cached.accessToken; + pending ??= withRetry(requestToken, retryOptions).finally(() => { + pending = null; + }); + return pending; + }, + invalidate() { + cached = null; + }, + }; +} diff --git a/src/tidal/client.js b/src/tidal/client.js new file mode 100644 index 00000000..9d0aaec1 --- /dev/null +++ b/src/tidal/client.js @@ -0,0 +1,119 @@ +import { TidalAuthError, TidalError } from '../errors.js'; +import { parseRetryAfter, sleep, withRetry } from './retry.js'; + +const JSON_API = 'application/vnd.api+json'; + +export function buildUrl(baseUrl, path, query = {}) { + const url = new URL(baseUrl.replace(/\/$/, '') + path); + for (const [key, value] of Object.entries(query)) { + if (value === undefined || value === null || value === '') continue; + url.searchParams.set(key, Array.isArray(value) ? value.join(',') : String(value)); + } + return url.href; +} + +/** Cursor for the next page, from `links.meta.nextCursor` or the `links.next` URL. */ +export function nextCursor(doc) { + const cursor = doc?.links?.meta?.nextCursor; + if (cursor) return cursor; + if (!doc?.links?.next) return undefined; + return new URL(doc.links.next, 'https://placeholder.invalid').searchParams.get('page[cursor]') || undefined; +} + +/** + * Minimal client for TIDAL's JSON:API (https://openapi.tidal.com/v2). + * Retries network errors, timeouts, 429s and 5xx responses; refreshes the + * token once on a 401; raises typed errors with TIDAL's own error details. + */ +export function createTidalClient({ baseUrl, tokens, fetch = globalThis.fetch, logger, timeoutMs = 10_000, pageDelayMs = 0, retryOptions }) { + async function attempt(url) { + const token = await tokens.getToken(); + let res; + try { + res = await fetch(url, { + headers: { Authorization: `Bearer ${token}`, Accept: JSON_API }, + signal: AbortSignal.timeout(timeoutMs), + }); + } catch (cause) { + const what = cause?.name === 'TimeoutError' ? `timed out after ${timeoutMs}ms` : cause?.message; + throw new TidalError(`TIDAL request ${what}`, { url, retryable: true, cause }); + } + + if (res.ok) { + try { + return await res.json(); + } catch (cause) { + throw new TidalError('TIDAL returned a response that is not valid JSON', { status: res.status, url, retryable: true, cause }); + } + } + + const body = await res.json().catch(() => null); + const first = body?.errors?.[0] ?? {}; + const details = { + status: res.status, + tidalCode: first.code, + // TIDAL sits behind CloudFront; its id identifies the request if you ever need TIDAL support. + requestId: res.headers.get('x-amz-cf-id') ?? res.headers.get('x-request-id') ?? first.id, + url, + }; + const reason = first.detail || res.statusText || 'no details'; + + if (res.status === 401 || res.status === 403) { + if (res.status === 401) tokens.invalidate(); + throw new TidalAuthError(`TIDAL denied access (${res.status}): ${reason}`, details); + } + if (res.status === 429 || res.status >= 500) { + const error = new TidalError(`TIDAL is ${res.status === 429 ? 'rate limiting us' : 'having problems'} (${res.status}): ${reason}`, { + ...details, + retryable: true, + }); + error.retryAfterMs = parseRetryAfter(res.headers.get('retry-after')); + throw error; + } + throw new TidalError(`TIDAL request failed (${res.status}): ${reason}`, details); + } + + async function get(path, query) { + const url = buildUrl(baseUrl, path, query); + let refreshedToken = false; + return withRetry( + async () => { + try { + return await attempt(url); + } catch (error) { + // An expired or revoked token: fetch a fresh one and try once more. + if (error instanceof TidalAuthError && error.upstreamStatus === 401 && !refreshedToken) { + refreshedToken = true; + return attempt(url); + } + throw error; + } + }, + { + ...retryOptions, + // One line per retry: these are expected (e.g. rate limits) and recovered from. + onRetry: ({ error, attempt: n, delay }) => + logger?.warn({ upstreamStatus: error.upstreamStatus, attempt: n, delayMs: Math.round(delay), path }, `Retrying TIDAL request: ${error.message}`), + }, + ); + } + + /** Yields every page of a paginated collection. */ + async function* paginate(path, query, { maxPages = 50 } = {}) { + const seen = new Set(); + let cursor; + for (let page = 1; page <= maxPages; page++) { + const doc = await get(path, cursor ? { ...query, 'page[cursor]': cursor } : query); + yield doc; + cursor = nextCursor(doc); + if (!cursor) return; + if (seen.has(cursor)) throw new TidalError('TIDAL returned the same page cursor twice', { url: buildUrl(baseUrl, path, query) }); + seen.add(cursor); + // A short pause between pages keeps us under TIDAL's rate limit. + if (pageDelayMs) await sleep(pageDelayMs); + } + logger?.warn({ path, maxPages }, 'Stopped paging TIDAL results at the page limit; some playlists may be missing'); + } + + return { get, paginate }; +} diff --git a/src/tidal/mock.js b/src/tidal/mock.js new file mode 100644 index 00000000..1b7c3b2b --- /dev/null +++ b/src/tidal/mock.js @@ -0,0 +1,95 @@ +// Demo data for local development and tests (TIDAL_MOCK=1). Serves responses +// shaped like TIDAL's JSON:API, so the real client and normalisation run. + +const GENRES = ['rock', 'electronic', 'jazz', 'ambient', 'hip hop', 'soul', 'folk', 'techno', 'post-punk', 'disco']; +const ARTISTS = ['Björk', 'Radiohead', 'Talking Heads', 'Nina Simone', 'Aphex Twin', 'Kate Bush', 'Can', 'Sade', 'Dvořák', 'AC/DC']; +const WORDS = ['Night', 'Drive', 'Static', 'Bloom', 'Low Light', 'Tidal', 'Morning', 'Glass', 'Fever', 'Slow Motion', 'Deep Cuts', 'Echoes', 'Sundown', 'Neon', 'Weather']; +const PALETTE = ['#e4572e', '#29335c', '#f3a712', '#a8c686', '#669bbc', '#8e3b46', '#4c956c', '#c0a9b0', '#2d6a4f', '#ff006e', '#3a86ff', '#8338ec']; +const DAY = 86_400_000; + +const pick = (list, i) => list[i % list.length]; +const uuid = (i) => `00000000-0000-4000-8000-${String(i).padStart(12, '0')}`; + +function buildPlaylists(count, now) { + return Array.from({ length: count }, (_, i) => { + const single = i % 3 === 0; + const tag = single ? pick(ARTISTS, i) : pick(GENRES, i * 7); + const name = `${pick(WORDS, i * 5)} ${pick(WORDS, i * 11 + 3)} (${tag})`; + const tracks = 12 + ((i * 37) % 80); + return { + id: uuid(i + 1), + type: 'playlists', + attributes: { + name: i === 4 ? 'Untitled mix without a tag' : name, + description: single + ? `A deep dive through the back catalogue of ${tag}, from the hits to the B-sides.` + : `Weekly selection of ${tag} — new finds & old favourites, sequenced for start-to-finish listening.`, + accessType: i % 25 === 24 ? 'PRIVATE' : 'PUBLIC', + bounded: true, + createdAt: new Date(now - (i * 9 + 2) * DAY).toISOString(), + lastModifiedAt: new Date(now - i * 4 * DAY).toISOString(), + duration: `PT${Math.floor((tracks * 4) / 60)}H${(tracks * 4) % 60}M${i % 60}S`, + numberOfItems: tracks, + numberOfTrackItems: tracks, + numberOfFollowers: (i * 13) % 140, + playlistType: 'USER', + externalLinks: [{ href: `https://tidal.com/browse/playlist/${uuid(i + 1)}`, meta: { type: 'TIDAL_SHARING' } }], + }, + relationships: { coverArt: { data: i === 9 ? [] : [{ id: `art-${i + 1}`, type: 'artworks' }], links: { self: '' } } }, + }; + }); +} + +const buildArtwork = (i) => ({ + id: `art-${i}`, + type: 'artworks', + attributes: { + mediaType: 'IMAGE', + files: [160, 320, 640, 1080].map((width) => ({ + href: `/__mock/art/${i}.svg?w=${width}`, + meta: { width, height: width }, + })), + visualMetadata: { selectedPaletteColor: pick(PALETTE, i), status: 'OK' }, + }, +}); + +const json = (body, status = 200, headers = {}) => + new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/vnd.api+json', ...headers } }); + +export function createMockFetch({ count = 150, pageSize = 20, latencyMs = 120, now = Date.now() } = {}) { + const playlists = buildPlaylists(count, now); + const delay = () => new Promise((resolve) => setTimeout(resolve, latencyMs)); + + return async function mockFetch(input) { + await delay(); + const url = new URL(typeof input === 'string' ? input : input.url); + + if (url.pathname.endsWith('/oauth2/token')) return json({ access_token: 'mock-token', token_type: 'Bearer', expires_in: 86_400 }); + + if (url.pathname.endsWith('/playlists')) { + const start = Number(url.searchParams.get('page[cursor]') || 0); + const page = playlists.slice(start, start + pageSize); + const next = start + pageSize < playlists.length ? String(start + pageSize) : undefined; + const included = page.flatMap((p) => p.relationships.coverArt.data).map((ref) => buildArtwork(Number(ref.id.slice(4)))); + return json({ data: page, included, links: { self: url.pathname, ...(next && { next: `/playlists?page[cursor]=${next}`, meta: { nextCursor: next } }) } }); + } + + if (url.pathname.endsWith('/artworks')) { + const ids = (url.searchParams.get('filter[id]') || '').split(',').filter(Boolean); + return json({ data: ids.map((id) => buildArtwork(Number(id.slice(4)))), links: { self: url.pathname } }); + } + + return json({ errors: [{ status: '404', detail: 'Not found in mock' }] }, 404); + }; +} + +/** Express handler drawing a simple generative cover for mock artwork. */ +export function mockArtworkHandler(req, res) { + const i = Number.parseInt(req.params.seed, 10) || 0; + const a = pick(PALETTE, i); + const b = pick(PALETTE, i * 5 + 3); + const rings = Array.from({ length: 6 }, (_, n) => ``).join(''); + res.type('image/svg+xml').set('Cache-Control', 'public, max-age=86400').send( + `${rings}No. ${i}`, + ); +} diff --git a/src/tidal/normalise.js b/src/tidal/normalise.js new file mode 100644 index 00000000..4ea83a65 --- /dev/null +++ b/src/tidal/normalise.js @@ -0,0 +1,116 @@ +import { createHash } from 'node:crypto'; + +// Trailing "(…)" holds the artist (single-artist playlists) or genre (mixes). +const TITLE_WITH_TAG = /^(.*\S)\s*\(\s*([^()]*?)\s*\)\s*$/; +const ISO_DURATION = /^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/; +const HEX_COLOUR = /^#?([0-9a-f]{6}|[0-9a-f]{3})$/i; +const ENTITIES = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", '#39': "'", nbsp: ' ' }; + +const MIN_ART_WIDTH = 100; +const MAX_ART_WIDTH = 1280; + +export function parseTitle(name) { + const clean = String(name ?? '').replace(/\s+/g, ' ').trim(); + const match = clean.match(TITLE_WITH_TAG); + if (!match || !match[2]) return { title: clean, tag: null }; + return { title: match[1], tag: match[2] }; +} + +/** "PT1H2M3S" → 3723 (seconds), or null when missing/invalid. */ +export function parseDuration(iso) { + const match = typeof iso === 'string' ? iso.match(ISO_DURATION) : null; + if (!match) return null; + const [, d = 0, h = 0, m = 0, s = 0] = match; + return Math.round(Number(d) * 86_400 + Number(h) * 3600 + Number(m) * 60 + Number(s)); +} + +export function cleanText(value) { + if (typeof value !== 'string') return ''; + return value + .replace(/&(amp|lt|gt|quot|apos|#39|nbsp);/g, (_, entity) => ENTITIES[entity]) + .replace(/[ \t]+/g, ' ') + .replace(/\n{3,}/g, '\n\n') + .trim(); +} + +const toIsoDate = (value) => { + const time = Date.parse(value); + return Number.isFinite(time) ? new Date(time).toISOString() : null; +}; + +const isHttpsOn = (href, domain) => { + try { + const url = new URL(href); + return url.protocol === 'https:' && (url.hostname === domain || url.hostname.endsWith(`.${domain}`)); + } catch { + return false; + } +}; + +// HTTPS only; root-relative paths are same-origin (used by mock mode). +const isAllowedImageUrl = (href) => typeof href === 'string' && (href.startsWith('https://') || /^\/(?!\/)/.test(href)); + +/** Artwork resource → { color, sources: [[url, width], …] } sorted by width, or null. */ +export function pickArtwork(artwork) { + const attributes = artwork?.attributes; + if (!attributes || (attributes.mediaType && attributes.mediaType !== 'IMAGE')) return null; + + const byWidth = new Map(); + for (const file of attributes.files ?? []) { + const width = Number(file?.meta?.width); + if (!isAllowedImageUrl(file?.href) || !(width > 0)) continue; + if (!byWidth.has(width)) byWidth.set(width, file.href); + } + const all = [...byWidth.entries()].sort((a, b) => a[0] - b[0]); + if (!all.length) return null; + + const inRange = all.filter(([width]) => width >= MIN_ART_WIDTH && width <= MAX_ART_WIDTH); + const sources = (inRange.length ? inRange : [all[0]]).map(([width, url]) => [url, width]); + + const colour = attributes.visualMetadata?.selectedPaletteColor; + const match = typeof colour === 'string' ? colour.trim().match(HEX_COLOUR) : null; + return { color: match ? `#${match[1].toLowerCase()}` : null, sources }; +} + +/** Short, stable hash of a record's content. Changes whenever anything visible changes. */ +export function revision(record) { + return createHash('sha256').update(JSON.stringify(record)).digest('base64url').slice(0, 12); +} + +/** + * TIDAL playlist resource → the compact record sent to browsers. + * Returns null for anything that is not public, so private and unlisted + * playlists can never leak, whichever credentials fetched them. + */ +export function normalisePlaylist(resource, artworksById = new Map()) { + const attributes = resource?.attributes; + if (typeof resource?.id !== 'string' || !attributes) return null; + if (attributes.accessType !== 'PUBLIC') return null; + + const { title, tag } = parseTitle(attributes.name); + if (!title) return null; + + const share = attributes.externalLinks?.find((link) => link?.meta?.type === 'TIDAL_SHARING')?.href; + const coverArtId = resource.relationships?.coverArt?.data?.[0]?.id; + const count = (value) => (Number.isInteger(value) && value >= 0 ? value : null); + + const record = { + id: resource.id, + title, + tag, + description: cleanText(attributes.description), + tracks: count(attributes.numberOfTrackItems) ?? count(attributes.numberOfItems), + duration: parseDuration(attributes.duration), + followers: count(attributes.numberOfFollowers), + createdAt: toIsoDate(attributes.createdAt), + updatedAt: toIsoDate(attributes.lastModifiedAt), + url: isHttpsOn(share, 'tidal.com') ? share : `https://tidal.com/playlist/${encodeURIComponent(resource.id)}`, + art: pickArtwork(artworksById.get(coverArtId)), + }; + return { ...record, rev: revision(record) }; +} + +/** Newest first; undated playlists last; ties broken by title. */ +export function compareNewest(a, b) { + return (b.createdAt ?? '').localeCompare(a.createdAt ?? '') || a.title.localeCompare(b.title); +} diff --git a/src/tidal/playlists.js b/src/tidal/playlists.js new file mode 100644 index 00000000..c7c71e51 --- /dev/null +++ b/src/tidal/playlists.js @@ -0,0 +1,69 @@ +import { TidalAuthError, TidalError } from '../errors.js'; +import { compareNewest, normalisePlaylist } from './normalise.js'; + +const ARTWORK_BATCH = 20; + +const chunk = (items, size) => Array.from({ length: Math.ceil(items.length / size) }, (_, i) => items.slice(i * size, (i + 1) * size)); + +/** + * Fetches every public playlist owned by `ownerId`, with cover art, in as few + * requests as TIDAL allows (one per page of results, rather than one per playlist). + */ +export async function fetchPublicPlaylists({ client, ownerId, countryCode, authMode, logger }) { + const resources = new Map(); + const artworks = new Map(); + + try { + for await (const doc of client.paginate('/playlists', { 'filter[owners.id]': ownerId, include: 'coverArt', countryCode })) { + if (!Array.isArray(doc?.data)) { + throw new TidalError('Unexpected response from TIDAL: /playlists returned no data array'); + } + for (const resource of doc.data) if (resource?.type === 'playlists') resources.set(resource.id, resource); + for (const item of doc.included ?? []) if (item?.type === 'artworks') artworks.set(item.id, item); + } + } catch (error) { + if (error instanceof TidalAuthError && authMode === 'client') { + error.message += + ' — TIDAL may only allow reading playlists on behalf of a signed-in user. Run `npm run tidal:login` once and set TIDAL_REFRESH_TOKEN.'; + } + throw error; + } + + // With client credentials TIDAL answers an owner query with an empty list rather than an error. + if (!resources.size && authMode === 'client') { + throw new TidalAuthError( + `TIDAL returned no playlists for user ${ownerId}. TIDAL only lists a user's playlists to an app signed in as that user: ` + + 'run `npm run tidal:login -- --save` once (with the app stopped), then restart.', + ); + } + + // Artwork TIDAL referenced but did not include: fetch it in batches. Not fatal. + const missing = [...resources.values()] + .map((resource) => resource.relationships?.coverArt?.data?.[0]?.id) + .filter((id) => id && !artworks.has(id)); + for (const ids of chunk([...new Set(missing)], ARTWORK_BATCH)) { + try { + const doc = await client.get('/artworks', { 'filter[id]': ids, countryCode }); + for (const item of doc?.data ?? []) artworks.set(item.id, item); + } catch (err) { + logger?.warn({ err, count: ids.length }, 'Could not fetch some playlist artwork; showing placeholders'); + } + } + + const records = []; + let hidden = 0; + for (const resource of resources.values()) { + const record = normalisePlaylist(resource, artworks); + if (record) records.push(record); + else hidden++; + } + + if (!records.length && hidden) { + logger?.warn({ hidden }, 'TIDAL returned playlists but none are marked public (accessType PUBLIC); none will be shown'); + } + const withoutArt = records.filter((record) => !record.art).length; + if (withoutArt) logger?.warn({ withoutArt }, 'Some playlists have no usable artwork'); + logger?.info({ public: records.length, hidden }, 'Fetched playlists from TIDAL'); + + return records.sort(compareNewest); +} diff --git a/src/tidal/retry.js b/src/tidal/retry.js new file mode 100644 index 00000000..2d61c9df --- /dev/null +++ b/src/tidal/retry.js @@ -0,0 +1,31 @@ +export const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); + +const MAX_RETRY_AFTER_MS = 30_000; + +/** Parses a Retry-After header (seconds or HTTP date) into milliseconds. */ +export function parseRetryAfter(value, now = Date.now()) { + if (!value) return undefined; + const seconds = Number(value); + const ms = Number.isFinite(seconds) ? seconds * 1000 : Date.parse(value) - now; + return Number.isFinite(ms) ? Math.max(0, ms) : undefined; +} + +/** + * Runs `fn`, retrying failures marked `retryable` with exponential backoff and + * jitter. Honours a server-provided `retryAfterMs`, but gives up rather than + * stall a request when the server asks for a very long wait. + */ +export async function withRetry(fn, { retries = 3, baseDelayMs = 500, maxDelayMs = 8000, wait = sleep, random = Math.random, onRetry } = {}) { + for (let attempt = 0; ; attempt++) { + try { + return await fn(attempt); + } catch (error) { + if (attempt >= retries || error?.retryable !== true) throw error; + if (error.retryAfterMs > MAX_RETRY_AFTER_MS) throw error; + const backoff = Math.min(maxDelayMs, baseDelayMs * 2 ** attempt * (0.8 + random() * 0.2)); + const delay = error.retryAfterMs ?? backoff; + onRetry?.({ error, attempt: attempt + 1, delay }); + await wait(delay); + } + } +} diff --git a/test/browser-logic.test.js b/test/browser-logic.test.js new file mode 100644 index 00000000..8b9d48e7 --- /dev/null +++ b/test/browser-logic.test.js @@ -0,0 +1,153 @@ +// The browser modules' pure logic, run in Node. +import assert from 'node:assert/strict'; +import { afterEach, describe, it } from 'node:test'; +import { DEFAULT_SORT, applyView, fold, popularTags, searchText } from '../public/js/filter.js'; +import { formatDuration, formatFollowers, formatTracks, isNew, joinStats } from '../public/js/format.js'; +import { diffManifest, mergePlaylists, syncPlaylists } from '../public/js/sync.js'; +import { jsonResponse } from './helpers.js'; + +const record = (id, extra = {}) => ({ id, rev: `${id}-1`, title: `Title ${id}`, tag: null, description: '', createdAt: '2024-01-01T00:00:00Z', updatedAt: '2024-01-01T00:00:00Z', ...extra }); + +describe('search and filters', () => { + const records = [ + record('a', { title: 'Night Bloom', tag: 'Björk', description: 'Icelandic deep dive', createdAt: '2024-03-01T00:00:00Z' }), + record('b', { title: 'Static Drive', tag: 'rock', description: 'Guitars & motorways', createdAt: '2024-05-01T00:00:00Z', updatedAt: '2024-01-02T00:00:00Z' }), + record('c', { title: 'after Dark', tag: 'Rock', description: 'Late night rock', createdAt: '2024-04-01T00:00:00Z', updatedAt: '2024-09-01T00:00:00Z' }), + ]; + const entries = records.map((r) => ({ record: r, text: searchText(r) })); + const ids = (view) => applyView(entries, view).map((r) => r.id); + + it('ignores case and accents', () => { + assert.equal(fold('Björk DVOŘÁK'), 'bjork dvorak'); + assert.deepEqual(ids({ query: 'bjork' }), ['a']); + }); + + it('searches titles, tags and descriptions; every word must match', () => { + assert.deepEqual(ids({ query: 'motorways' }), ['b']); + assert.deepEqual(ids({ query: 'night' }).sort(), ['a', 'c']); + assert.deepEqual(ids({ query: 'night rock' }), ['c']); + assert.deepEqual(ids({ query: ' ' }).length, 3); + }); + + it('filters by tag, case-insensitively', () => { + assert.deepEqual(ids({ tag: 'ROCK' }), ['b', 'c']); + }); + + it('sorts newest first by default, or by update, or A–Z', () => { + assert.equal(DEFAULT_SORT, 'newest'); + assert.deepEqual(ids({}), ['b', 'c', 'a']); + assert.deepEqual(ids({ sort: 'updated' }), ['c', 'b', 'a']); + assert.deepEqual(ids({ sort: 'az' }), ['c', 'a', 'b']); + assert.deepEqual(ids({ sort: 'nonsense' }), ['b', 'c', 'a']); + }); + + it('lists tags shared by several playlists, most common first', () => { + assert.deepEqual(popularTags(records), [{ key: 'rock', label: 'rock', count: 2 }]); + assert.equal(popularTags(records, { min: 1 }).length, 2); + }); +}); + +describe('formatting', () => { + it('formats counts and durations in British English', () => { + assert.equal(formatTracks(1), '1 track'); + assert.equal(formatTracks(1500), '1,500 tracks'); + assert.equal(formatFollowers(0), null); + assert.equal(formatDuration(2880), '48 min'); + assert.equal(formatDuration(3723), '1 hr 2 min'); + assert.equal(formatDuration(7200), '2 hr'); + assert.equal(joinStats('a', null, 'b'), 'a · b'); + }); + + it('marks recent playlists as new', () => { + const now = Date.parse('2024-02-01T00:00:00Z'); + assert.equal(isNew({ createdAt: '2024-01-25T00:00:00Z' }, now), true); + assert.equal(isNew({ createdAt: '2023-12-01T00:00:00Z' }, now), false); + assert.equal(isNew({ createdAt: null }, now), false); + }); +}); + +describe('sync', () => { + const realFetch = globalThis.fetch; + afterEach(() => (globalThis.fetch = realFetch)); + + /** Fake server: answers manifest/playlists requests from `server` and records them. */ + function serve(server) { + const calls = []; + globalThis.fetch = async (url, init = {}) => { + calls.push(url); + const etag = server.etag; + if (url === '/api/playlists/manifest') { + if (init.headers?.['If-None-Match'] === `"${etag}"`) return new Response(null, { status: 304 }); + return jsonResponse({ etag, items: server.records.map((r) => [r.id, r.rev]) }); + } + const ids = new URL(url, 'http://x').searchParams.get('ids'); + const wanted = ids ? server.records.filter((r) => ids.split(',').includes(r.id)) : server.records; + return jsonResponse({ etag, playlists: wanted, missing: [] }); + }; + return calls; + } + + it('diffs a manifest against the cache', () => { + const cached = [record('a'), record('b'), record('c')]; + const diff = diffManifest(cached, [['a', 'a-1'], ['b', 'b-2'], ['d', 'd-1']]); + assert.deepEqual(diff, { added: ['d'], changed: ['b'], removed: ['c'] }); + assert.deepEqual(mergePlaylists(cached, [record('d'), { ...record('b'), rev: 'b-2' }], diff.removed).map((r) => r.id), ['a', 'b', 'd']); + }); + + it('downloads everything on a first visit', async () => { + const calls = serve({ etag: 'e1', records: [record('a'), record('b')] }); + const result = await syncPlaylists({ cache: null }); + assert.equal(result.mode, 'full'); + assert.equal(result.playlists.length, 2); + assert.deepEqual(calls, ['/api/playlists']); + }); + + it('downloads nothing when nothing changed', async () => { + const calls = serve({ etag: 'e1', records: [record('a')] }); + const result = await syncPlaylists({ cache: { etag: 'e1', playlists: [record('a')] } }); + assert.equal(result.mode, 'unchanged'); + assert.deepEqual(calls, ['/api/playlists/manifest']); + }); + + it('downloads only new and changed playlists', async () => { + const cached = Array.from({ length: 40 }, (_, i) => record(`p${i}`)); + const server = { etag: 'e2', records: [...cached.slice(1), { ...cached[5], rev: 'changed', title: 'Renamed' }, record('new')] }; + server.records.splice(4, 1); // p5 appears once, in its changed form. + const calls = serve(server); + const result = await syncPlaylists({ cache: { etag: 'e1', playlists: cached } }); + assert.equal(result.mode, 'delta'); + assert.deepEqual(result.added, ['new']); + assert.equal(result.changed, 1); + assert.equal(result.removed, 1); + assert.equal(calls[1], '/api/playlists?ids=new,p5'); + assert.equal(result.playlists.find((r) => r.id === 'p5').title, 'Renamed'); + assert.equal(result.playlists.length, 40); + assert.equal(result.etag, 'e2'); + }); + + it('falls back to one full download when most things changed', async () => { + const cached = Array.from({ length: 30 }, (_, i) => record(`p${i}`)); + const calls = serve({ etag: 'e2', records: cached.map((r) => ({ ...r, rev: 'new' })) }); + const result = await syncPlaylists({ cache: { etag: 'e1', playlists: cached } }); + assert.equal(result.mode, 'full'); + assert.deepEqual(calls, ['/api/playlists/manifest', '/api/playlists']); + }); + + it('uses the request the page started early, when it matches the cache', async () => { + const calls = serve({ etag: 'e1', records: [record('a')] }); + const boot = { etag: 'e1', request: Promise.resolve(new Response(null, { status: 304 })) }; + const result = await syncPlaylists({ cache: { etag: 'e1', playlists: [record('a')] }, boot }); + assert.equal(result.mode, 'unchanged'); + assert.deepEqual(calls, []); + }); + + it('rejects malformed responses with a clear error', async () => { + globalThis.fetch = async () => jsonResponse({ playlists: 'nope' }); + await assert.rejects(syncPlaylists({ cache: null }), { name: 'ApiError', code: 'BAD_RESPONSE' }); + }); + + it('turns server errors into ApiErrors carrying the request id', async () => { + globalThis.fetch = async () => jsonResponse({ error: { code: 'CATALOGUE_UNAVAILABLE', message: 'later', requestId: 'req-1' } }, 503, { 'Retry-After': '30' }); + await assert.rejects(syncPlaylists({ cache: null }), { code: 'CATALOGUE_UNAVAILABLE', status: 503, requestId: 'req-1', retryAfter: 30 }); + }); +}); diff --git a/test/catalogue.test.js b/test/catalogue.test.js new file mode 100644 index 00000000..b81fc976 --- /dev/null +++ b/test/catalogue.test.js @@ -0,0 +1,145 @@ +import assert from 'node:assert/strict'; +import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { after, before, describe, it } from 'node:test'; +import { catalogueEtag, createCatalogue } from '../src/catalogue.js'; +import { CatalogueUnavailableError, TidalAuthError } from '../src/errors.js'; +import { fakeReporter, silentLogger } from './helpers.js'; + +const record = (id, rev = 'r1') => ({ id, rev, title: `Playlist ${id}` }); +const settle = () => new Promise((resolve) => setImmediate(resolve)); + +function setup({ load, snapshotPath = null, ttlMs = 1000 } = {}) { + let now = 1_000_000; + const reporter = fakeReporter(); + const catalogue = createCatalogue({ load, ttlMs, snapshotPath, logger: silentLogger, reporter, now: () => now, minRetryMs: 100 }); + return { catalogue, reporter, advance: (ms) => (now += ms) }; +} + +describe('catalogueEtag', () => { + it('depends only on ids and revisions', () => { + assert.equal(catalogueEtag([record('a'), record('b')]), catalogueEtag([record('a'), record('b')])); + assert.notEqual(catalogueEtag([record('a')]), catalogueEtag([record('a', 'r2')])); + }); +}); + +describe('catalogue', () => { + let dir; + before(async () => (dir = await mkdtemp(join(tmpdir(), 'selections-')))); + // Background snapshot writes may still be finishing. + after(() => rm(dir, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 })); + + it('loads on first use and shares one load between concurrent requests', async () => { + let loads = 0; + const { catalogue } = setup({ load: async () => (loads++, [record('a')]) }); + const [one, two] = await Promise.all([catalogue.get(), catalogue.get()]); + assert.equal(loads, 1); + assert.equal(one, two); + assert.deepEqual(one.manifest, [['a', 'r1']]); + assert.equal(one.byId.get('a').title, 'Playlist a'); + }); + + it('serves stale data immediately while refreshing in the background', async () => { + let version = 1; + const { catalogue, advance } = setup({ load: async () => [record('a', `r${version}`)] }); + await catalogue.get(); + version = 2; + advance(1001); + const stale = await catalogue.get(); + assert.equal(stale.byId.get('a').rev, 'r1'); + await settle(); + assert.equal((await catalogue.get()).byId.get('a').rev, 'r2'); + }); + + it('keeps serving the last good copy when TIDAL fails, and backs off', async () => { + let fail = false; + let loads = 0; + const { catalogue, advance, reporter } = setup({ + load: async () => { + loads++; + if (fail) throw new Error('TIDAL down'); + return [record('a')]; + }, + }); + await catalogue.get(); + fail = true; + advance(1001); + assert.equal((await catalogue.get()).records.length, 1); + await settle(); + assert.equal(loads, 2); + assert.equal(catalogue.status().consecutiveFailures, 1); + assert.equal(reporter.calls.exception[0].options.level, 'warn'); + + await catalogue.get(); // Within the back-off window: no new attempt. + await settle(); + assert.equal(loads, 2); + advance(101); + await catalogue.get(); + await settle(); + assert.equal(loads, 3); + }); + + it('hands background refreshes to the host, so serverless functions finish them', async () => { + const handed = []; + let now = 0; + const catalogue = createCatalogue({ load: async () => [record('a')], ttlMs: 1000, logger: silentLogger, reporter: fakeReporter(), now: () => now, background: (p) => handed.push(p) }); + await catalogue.get(); + assert.equal(handed.length, 0); // The first load is awaited by the request itself. + now = 1001; + await catalogue.get(); + assert.equal(handed.length, 1); + await handed[0]; + }); + + it('reports credential problems as errors even while serving stale data', async () => { + let fail = false; + const { catalogue, advance, reporter } = setup({ + load: async () => { + if (fail) throw new TidalAuthError('denied'); + return [record('a')]; + }, + }); + await catalogue.get(); + fail = true; + advance(1001); + await catalogue.get(); + await settle(); + assert.equal(reporter.calls.exception[0].options.level, 'error'); + }); + + it('is unavailable (503) with nothing to serve, with a Retry-After hint', async () => { + const { catalogue } = setup({ load: async () => Promise.reject(new Error('down')) }); + await assert.rejects(catalogue.get(), (error) => { + assert.ok(error instanceof CatalogueUnavailableError); + assert.equal(error.status, 503); + assert.ok(error.retryAfterSeconds >= 5); + return true; + }); + assert.equal(catalogue.status().ready, false); + }); + + it('persists a snapshot and restores it on restart', async () => { + const snapshotPath = join(dir, 'nested', 'snapshot.json'); + const first = setup({ load: async () => [record('a'), record('b')], snapshotPath }); + await first.catalogue.get(); + await settle(); + await new Promise((resolve) => setTimeout(resolve, 50)); + assert.equal(JSON.parse(await readFile(snapshotPath, 'utf8')).records.length, 2); + + const second = setup({ load: () => new Promise(() => {}), snapshotPath }); // TIDAL never answers. + await second.catalogue.start(); + const snapshot = await second.catalogue.get(); + assert.deepEqual(snapshot.records.map((r) => r.id), ['a', 'b']); + }); + + it('ignores corrupt or outdated snapshots', async () => { + const snapshotPath = join(dir, 'bad.json'); + for (const content of ['{not json', JSON.stringify({ version: 0, records: [] }), JSON.stringify({ version: 1, fetchedAt: Date.now(), records: [] }), JSON.stringify({ version: 1, records: [{ id: 1 }] })]) { + await writeFile(snapshotPath, content); + const { catalogue } = setup({ load: async () => [record('fresh')], snapshotPath }); + await catalogue.start(); + assert.equal((await catalogue.get()).records[0].id, 'fresh'); + } + }); +}); diff --git a/test/helpers.js b/test/helpers.js new file mode 100644 index 00000000..c1d65195 --- /dev/null +++ b/test/helpers.js @@ -0,0 +1,78 @@ +// Shared test utilities. + +export const silentLogger = { + trace() {}, + debug() {}, + info() {}, + warn() {}, + error() {}, + fatal() {}, + child() { + return silentLogger; + }, +}; + +/** Collects reporter calls instead of logging them. */ +export function fakeReporter() { + const calls = { exception: [], browserError: [], cspViolation: [] }; + return { + calls, + sentryEnabled: false, + exception: (error, options) => calls.exception.push({ error, options }), + browserError: (report, meta) => calls.browserError.push({ report, meta }), + cspViolation: (violation, meta) => calls.cspViolation.push({ violation, meta }), + flush: async () => true, + }; +} + +export const jsonResponse = (body, status = 200, headers = {}) => + new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json', ...headers } }); + +/** A fetch stub that answers from a queue of handlers and records every call. */ +export function scriptedFetch(...handlers) { + const calls = []; + const fetch = async (input, init = {}) => { + const url = typeof input === 'string' ? input : input.url; + calls.push({ url, init }); + const handler = handlers.length > 1 ? handlers.shift() : handlers[0]; + if (!handler) throw new Error(`Unexpected fetch: ${url}`); + return handler(url, init); + }; + return { fetch, calls }; +} + +export const noWait = { wait: async () => {}, random: () => 0.5 }; + +/** A minimal TIDAL playlist resource. */ +export function playlistResource(id, overrides = {}) { + const { attributes, relationships } = overrides; + return { + id, + type: 'playlists', + attributes: { + name: `Playlist ${id} (rock)`, + description: 'Some songs', + accessType: 'PUBLIC', + createdAt: '2024-01-01T00:00:00Z', + lastModifiedAt: '2024-02-01T00:00:00Z', + duration: 'PT1H2M3S', + numberOfItems: 10, + numberOfFollowers: 3, + externalLinks: [], + ...attributes, + }, + relationships: relationships ?? { coverArt: { data: [{ id: `art-${id}`, type: 'artworks' }] } }, + }; +} + +export function artworkResource(id, widths = [80, 160, 320, 640, 1280, 3000]) { + return { + id, + type: 'artworks', + attributes: { + mediaType: 'IMAGE', + files: widths.map((w) => ({ href: `https://resources.tidal.com/images/${id}/${w}x${w}.jpg`, meta: { width: w, height: w } })), + visualMetadata: { selectedPaletteColor: '#AABBCC' }, + }, + }; +} diff --git a/test/http.test.js b/test/http.test.js new file mode 100644 index 00000000..51026725 --- /dev/null +++ b/test/http.test.js @@ -0,0 +1,235 @@ +import assert from 'node:assert/strict'; +import { fileURLToPath } from 'node:url'; +import { after, before, describe, it } from 'node:test'; +import { readConfig } from '../src/config.js'; +import { CatalogueUnavailableError } from '../src/errors.js'; +import { createAssets } from '../src/http/assets.js'; +import { createApp, etagMatches } from '../src/http/app.js'; +import { createLogger } from '../src/logger.js'; +import { fakeReporter } from './helpers.js'; + +const silentLogger = createLogger({ level: 'silent' }); + +const records = [ + { id: 'aaaa-1', rev: 'r1', title: 'One', tag: 'rock', art: { color: '#112233', sources: [['https://resources.tidal.com/images/1/320x320.jpg', 320]] } }, + { id: 'bbbb-2', rev: 'r2', title: 'Two', tag: null, art: null }, +]; +const snapshot = { + records, + byId: new Map(records.map((r) => [r.id, r])), + manifest: records.map((r) => [r.id, r.rev]), + etag: 'etag123', + fetchedAt: Date.now(), +}; + +async function startServer({ catalogue, production = false, vercel = false } = {}) { + const config = readConfig({ TIDAL_MOCK: '1', NODE_ENV: production ? 'production' : 'test', ...(vercel && { VERCEL: '1' }) }); + const assets = await createAssets({ publicDir: fileURLToPath(new URL('../public', import.meta.url)), versioned: production }); + const reporter = fakeReporter(); + const app = createApp({ config, catalogue, reporter, logger: silentLogger, assets }); + const server = await new Promise((resolve) => { + const s = app.listen(0, () => resolve(s)); + }); + const base = `http://localhost:${server.address().port}`; + return { base, server, reporter, assets }; +} + +const healthyCatalogue = { + get: async () => snapshot, + peek: () => snapshot, + status: () => ({ ready: true, count: 2, lastError: null, refreshing: false }), +}; + +describe('HTTP API', () => { + let ctx; + before(async () => (ctx = await startServer({ catalogue: healthyCatalogue }))); + after(() => ctx.server.close()); + + it('serves the manifest with an ETag, and 304 when unchanged', async () => { + const res = await fetch(`${ctx.base}/api/playlists/manifest`); + assert.equal(res.headers.get('vercel-cdn-cache-control'), null); // Only on Vercel. + assert.equal(res.status, 200); + assert.equal(res.headers.get('etag'), '"etag123"'); + assert.equal(res.headers.get('cache-control'), 'no-cache'); + assert.deepEqual(await res.json(), { etag: 'etag123', count: 2, items: [['aaaa-1', 'r1'], ['bbbb-2', 'r2']] }); + + // Browsers send Cache-Control: no-cache with the app's cache: 'no-store' requests. + const again = await fetch(`${ctx.base}/api/playlists/manifest`, { headers: { 'If-None-Match': '"etag123"', 'Cache-Control': 'no-cache' } }); + assert.equal(again.status, 304); + assert.equal(await again.text(), ''); + + const changed = await fetch(`${ctx.base}/api/playlists/manifest`, { headers: { 'If-None-Match': '"older"' } }); + assert.equal(changed.status, 200); + }); + + it('matches entity tags the way browsers send them', () => { + assert.equal(etagMatches('"abc"', 'abc'), true); + assert.equal(etagMatches('W/"abc"', 'abc'), true); + assert.equal(etagMatches('"x", "abc"', 'abc'), true); + assert.equal(etagMatches('*', 'abc'), true); + assert.equal(etagMatches('"abcd"', 'abc'), false); + assert.equal(etagMatches(undefined, 'abc'), false); + }); + + it('serves all playlists, or just the ones asked for', async () => { + const all = await (await fetch(`${ctx.base}/api/playlists`)).json(); + assert.equal(all.playlists.length, 2); + + const some = await (await fetch(`${ctx.base}/api/playlists?ids=bbbb-2,missing-3`)).json(); + assert.deepEqual(some.playlists.map((p) => p.id), ['bbbb-2']); + assert.deepEqual(some.missing, ['missing-3']); + }); + + it('rejects invalid or excessive ids with a helpful 400', async () => { + const bad = await fetch(`${ctx.base}/api/playlists?ids=${encodeURIComponent(' + - - - - -
- -
- -
-

Loading... Sometimes this can take a while - still learning to code!

-
+
+
+

Loading playlists…

+ +
+

-
- -
+ + -
- -
-
+ - +
    + <% for (let i = 0; i < 12; i++) { %><% } %> +
-
-

Weekly curated playlists by Beere - since 2019 ©

-
+ +
+
+ -
-