diff --git a/packages/apn-relay/src/index.ts b/packages/apn-relay/src/index.ts index 6cef25bbff..41d516a311 100644 --- a/packages/apn-relay/src/index.ts +++ b/packages/apn-relay/src/index.ts @@ -23,6 +23,19 @@ function tail(input: string) { return input.slice(-8) } +function esc(input: unknown) { + return String(input ?? "") + .replaceAll("&", "&") + .replaceAll("<", "<") + .replaceAll(">", ">") + .replaceAll('"', """) + .replaceAll("'", "'") +} + +function fmt(input: number) { + return new Date(input).toISOString() +} + const reg = z.object({ secret: z.string().min(1), deviceToken: z.string().min(1), @@ -90,6 +103,16 @@ app.get("/health", async (c) => { app.get("/", async (c) => { const [a] = await db.select({ value: sql`count(*)` }).from(device_registration) const [b] = await db.select({ value: sql`count(*)` }).from(delivery_log) + const devices = await db.select().from(device_registration).orderBy(desc(device_registration.updated_at)).limit(100) + const byBundle = await db + .select({ + bundle: device_registration.bundle_id, + env: device_registration.apns_env, + value: sql`count(*)`, + }) + .from(device_registration) + .groupBy(device_registration.bundle_id, device_registration.apns_env) + .orderBy(desc(sql`count(*)`)) const rows = await db.select().from(delivery_log).orderBy(desc(delivery_log.created_at)).limit(20) const html = ` @@ -101,9 +124,11 @@ app.get("/", async (c) => {