nixamp 0.17.0 → 0.17.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.
- package/dist/live-api.js +1 -0
- package/dist/live-events.js +11 -3
- package/package.json +1 -1
- package/src/live-api.ts +1 -0
- package/src/live-events.ts +14 -3
- package/web/dist/sw.js +1 -1
package/dist/live-api.js
CHANGED
|
@@ -563,6 +563,7 @@ export async function handleLiveApi(request, response, url, options) {
|
|
|
563
563
|
json(response, error.status, { error: error.message });
|
|
564
564
|
return true;
|
|
565
565
|
}
|
|
566
|
+
console.error(`live api ${request.method} ${path}:`, error instanceof Error ? error.message : error);
|
|
566
567
|
json(response, 500, { error: "the live event service failed" });
|
|
567
568
|
return true;
|
|
568
569
|
}
|
package/dist/live-events.js
CHANGED
|
@@ -71,19 +71,22 @@ const EVENT_SCHEMA = `
|
|
|
71
71
|
ON live_events (visibility, status, starts_at, updated_at DESC);
|
|
72
72
|
CREATE INDEX IF NOT EXISTS live_events_owner
|
|
73
73
|
ON live_events (owner_id, updated_at DESC);
|
|
74
|
-
CREATE INDEX IF NOT EXISTS live_events_kind
|
|
75
|
-
ON live_events (kind, status, starts_at);
|
|
76
74
|
|
|
77
75
|
-- The repo has no migration runner, so a table that already exists is
|
|
78
76
|
-- brought forward here. Every statement is idempotent, and the CHECKs are
|
|
79
77
|
-- replaced by name rather than added twice: the originals were unnamed, so
|
|
80
78
|
-- the ones carrying the old status list are found by what they say.
|
|
79
|
+
-- The columns come before any index on them: nixamp.com had live_events
|
|
80
|
+
-- from before 0.17.0, and an index on kind ahead of ADD COLUMN kind failed
|
|
81
|
+
-- there while every fresh database (tests, CI) sailed through.
|
|
81
82
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS kind TEXT NOT NULL DEFAULT 'talk';
|
|
82
83
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS doors_open_at TIMESTAMPTZ;
|
|
83
84
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS ticket_price_cents INTEGER NOT NULL DEFAULT 0;
|
|
84
85
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS ticket_currency TEXT NOT NULL DEFAULT 'USD';
|
|
85
86
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS ticket_minutes INTEGER NOT NULL DEFAULT 1440;
|
|
86
87
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS pay_to TEXT;
|
|
88
|
+
CREATE INDEX IF NOT EXISTS live_events_kind
|
|
89
|
+
ON live_events (kind, status, starts_at);
|
|
87
90
|
|
|
88
91
|
DO $$
|
|
89
92
|
DECLARE stale record;
|
|
@@ -402,7 +405,12 @@ export class LiveEvents {
|
|
|
402
405
|
this.db = db;
|
|
403
406
|
}
|
|
404
407
|
async ensure() {
|
|
405
|
-
|
|
408
|
+
// A failed schema run is not remembered: the next request tries again
|
|
409
|
+
// rather than answering 500 until the process restarts.
|
|
410
|
+
this.ready ??= this.db.query(EVENT_SCHEMA).then(() => undefined, (error) => {
|
|
411
|
+
this.ready = null;
|
|
412
|
+
throw error;
|
|
413
|
+
});
|
|
406
414
|
await this.ready;
|
|
407
415
|
}
|
|
408
416
|
async create(ownerId, input) {
|
package/package.json
CHANGED
package/src/live-api.ts
CHANGED
|
@@ -628,6 +628,7 @@ export async function handleLiveApi(
|
|
|
628
628
|
json(response, error.status, { error: error.message });
|
|
629
629
|
return true;
|
|
630
630
|
}
|
|
631
|
+
console.error(`live api ${request.method} ${path}:`, error instanceof Error ? error.message : error);
|
|
631
632
|
json(response, 500, { error: "the live event service failed" });
|
|
632
633
|
return true;
|
|
633
634
|
}
|
package/src/live-events.ts
CHANGED
|
@@ -173,19 +173,22 @@ const EVENT_SCHEMA = `
|
|
|
173
173
|
ON live_events (visibility, status, starts_at, updated_at DESC);
|
|
174
174
|
CREATE INDEX IF NOT EXISTS live_events_owner
|
|
175
175
|
ON live_events (owner_id, updated_at DESC);
|
|
176
|
-
CREATE INDEX IF NOT EXISTS live_events_kind
|
|
177
|
-
ON live_events (kind, status, starts_at);
|
|
178
176
|
|
|
179
177
|
-- The repo has no migration runner, so a table that already exists is
|
|
180
178
|
-- brought forward here. Every statement is idempotent, and the CHECKs are
|
|
181
179
|
-- replaced by name rather than added twice: the originals were unnamed, so
|
|
182
180
|
-- the ones carrying the old status list are found by what they say.
|
|
181
|
+
-- The columns come before any index on them: nixamp.com had live_events
|
|
182
|
+
-- from before 0.17.0, and an index on kind ahead of ADD COLUMN kind failed
|
|
183
|
+
-- there while every fresh database (tests, CI) sailed through.
|
|
183
184
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS kind TEXT NOT NULL DEFAULT 'talk';
|
|
184
185
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS doors_open_at TIMESTAMPTZ;
|
|
185
186
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS ticket_price_cents INTEGER NOT NULL DEFAULT 0;
|
|
186
187
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS ticket_currency TEXT NOT NULL DEFAULT 'USD';
|
|
187
188
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS ticket_minutes INTEGER NOT NULL DEFAULT 1440;
|
|
188
189
|
ALTER TABLE live_events ADD COLUMN IF NOT EXISTS pay_to TEXT;
|
|
190
|
+
CREATE INDEX IF NOT EXISTS live_events_kind
|
|
191
|
+
ON live_events (kind, status, starts_at);
|
|
189
192
|
|
|
190
193
|
DO $$
|
|
191
194
|
DECLARE stale record;
|
|
@@ -511,7 +514,15 @@ export class LiveEvents {
|
|
|
511
514
|
constructor(private readonly db: Queryable) {}
|
|
512
515
|
|
|
513
516
|
private async ensure(): Promise<void> {
|
|
514
|
-
|
|
517
|
+
// A failed schema run is not remembered: the next request tries again
|
|
518
|
+
// rather than answering 500 until the process restarts.
|
|
519
|
+
this.ready ??= this.db.query(EVENT_SCHEMA).then(
|
|
520
|
+
() => undefined,
|
|
521
|
+
(error: unknown) => {
|
|
522
|
+
this.ready = null;
|
|
523
|
+
throw error;
|
|
524
|
+
},
|
|
525
|
+
);
|
|
515
526
|
await this.ready;
|
|
516
527
|
}
|
|
517
528
|
|
package/web/dist/sw.js
CHANGED