@profullstack/leaderboard 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +10 -0
  2. package/package.json +1 -1
  3. package/src/next.js +7 -0
package/README.md CHANGED
@@ -182,6 +182,16 @@ export const { GET } = leaderboardRoute(lb);
182
182
  export const dynamic = 'force-dynamic';
183
183
  ```
184
184
 
185
+ That serves everything **under** the base path. It does not serve `/leaderboard.json`, because Next matches on path segments and that path is a sibling of `/leaderboard` rather than a child, so the catch-all never sees it. Either use `/leaderboard/index.json`, which is the same index, or give it a route of its own:
186
+
187
+ ```js
188
+ // app/leaderboard.json/route.js
189
+ export const { GET } = leaderboardRoute(lb);
190
+ export const dynamic = 'force-dynamic';
191
+ ```
192
+
193
+ Testing this needs the router, not just the handler: calling the exported `GET` directly answers every path you hand it, including the ones Next would never route to it.
194
+
185
195
  ## Programmatic
186
196
 
187
197
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/leaderboard",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "A public leaderboard with badges, streaks and a commission ladder that drops into any site. Ranks either side of a transaction, earners and spenders and usage, kept segregated. Zero dependencies, Fetch API core, Hono and Next adapters.",
6
6
  "keywords": [
package/src/next.js CHANGED
@@ -10,6 +10,13 @@ import { createLeaderboard } from './index.js';
10
10
  *
11
11
  * Anything the leaderboard does not answer 404s, which is what a route under
12
12
  * its own path should do.
13
+ *
14
+ * This serves everything UNDER the base path, and not `<base>.json`: Next
15
+ * matches on path segments, so that path is a sibling of the base rather than
16
+ * a child and the catch-all never sees it. Use `<base>/index.json`, which is
17
+ * the same index, or give `app/<base>.json/route.js` its own copy of this.
18
+ * Note that calling the exported GET directly in a test answers any path it is
19
+ * handed, including ones Next would never route to it.
13
20
  */
14
21
  export function leaderboardRoute(lbOrOptions) {
15
22
  const lb = lbOrOptions && typeof lbOrOptions.handle === 'function' ? lbOrOptions : createLeaderboard(lbOrOptions);