ugly-app 0.1.792 → 0.1.793

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.
@@ -1,2 +1,2 @@
1
- export declare const CLI_VERSION = "0.1.792";
1
+ export declare const CLI_VERSION = "0.1.793";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by prebuild — do not edit manually
2
- export const CLI_VERSION = "0.1.792";
2
+ export const CLI_VERSION = "0.1.793";
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-app",
3
- "version": "0.1.792",
3
+ "version": "0.1.793",
4
4
  "type": "module",
5
5
  "comment:files": "Allowlist what ships to npm. dist = runtime; src = sourcemap targets (dist/*.js.map reference ../../src/); templates = CLI scaffold. Everything else at repo root (.pgdata local Postgres, coverage, assets/icons sources, test/, test-results/) is excluded by omission. The !negations strip the scaffold's installed deps + cruft (templates/node_modules is 200MB+ and must never ship). package.json/README/LICENSE ship automatically.",
6
6
  "files": [
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by prebuild — do not edit manually
2
- export const CLI_VERSION = "0.1.792";
2
+ export const CLI_VERSION = "0.1.793";
@@ -75,7 +75,7 @@ const app = createApp(
75
75
  page,
76
76
  query: query ?? {},
77
77
  ...(imageUrl ? { imageUrl } : {}),
78
- } as TypedPushSendInput<typeof pages, keyof typeof pages & string>);
78
+ } as TypedPushSendInput<typeof pages, keyof typeof pages>);
79
79
  return { sent: result.sent };
80
80
  } catch (e) {
81
81
  console.error(e);
@@ -19,17 +19,37 @@ import {
19
19
  SessionDO,
20
20
  createWorkersApp,
21
21
  } from 'ugly-app/server/adapter/workers';
22
- import type { RequestHandlers } from 'ugly-app';
22
+ import type { RequestHandlers, TypedPushSendInput } from 'ugly-app';
23
23
  import type { WorkerHandlers } from 'ugly-app/shared';
24
24
 
25
25
  import { messages, requests } from '../shared/api';
26
26
  import { collections } from '../shared/collections';
27
27
  import { cronTasks } from '../shared/cron';
28
+ import { pages } from '../shared/pages';
28
29
 
29
- // Request handlers run inside the Worker for `fetch` requests. Most
30
- // projects keep these in sync with `server/index.ts`; the framework's
31
- // `app.db` works the same way in both runtimes.
32
- const requestHandlers: Partial<RequestHandlers<typeof requests>> = {};
30
+ // Request handlers run inside the Worker for `fetch` requests. Keep these in
31
+ // sync with `server/index.ts` — a handler registered only on the Node entry is
32
+ // "not registered" on the deployed Worker. The framework's `app.db` /
33
+ // `app.pushSend` work the same way in both runtimes. (`app` is referenced inside
34
+ // the async body, resolved at request time after `app` below is assigned.)
35
+ const requestHandlers: Partial<RequestHandlers<typeof requests>> = {
36
+ sendPush: async (_userId, { targetUserId, title, body, page, query, imageUrl }): Promise<{ sent: boolean }> => {
37
+ try {
38
+ const result = await app.pushSend({
39
+ targetUserId,
40
+ title,
41
+ body,
42
+ page,
43
+ query: query ?? {},
44
+ ...(imageUrl ? { imageUrl } : {}),
45
+ } as TypedPushSendInput<typeof pages, keyof typeof pages>);
46
+ return { sent: result.sent };
47
+ } catch (e) {
48
+ console.error(e);
49
+ return { sent: false };
50
+ }
51
+ },
52
+ };
33
53
 
34
54
  // Cron handlers run on Cloudflare Cron Triggers (matches the schedule
35
55
  // declared in `shared/cron.ts`).
@@ -40,8 +60,12 @@ const cronHandlers: WorkerHandlers<typeof cronTasks> = {
40
60
  },
41
61
  };
42
62
 
63
+ // The registry MUST carry `pages` — `createWorkersApp` reads its route table
64
+ // from `registry.pages` (there is no Workers `configurator.setPages`, unlike the
65
+ // Node `createApp` path). Without it `app.pushSend`'s route-check sees an empty
66
+ // table and throws `unknown route "…"` for every push.
43
67
  const app = createWorkersApp(
44
- { requests, messages },
68
+ { requests, messages, pages },
45
69
  requestHandlers,
46
70
  collections,
47
71
  (cfg) => {