fix: choose buckets

This commit is contained in:
2026-04-09 02:23:11 +04:00
parent db9c63a096
commit 27d8630611
7 changed files with 60 additions and 23 deletions
+7
View File
@@ -5,6 +5,7 @@ import sql from "../db";
const Theme = t.Union([t.Literal("auto"), t.Literal("light"), t.Literal("dark")]);
const Window = t.Union([t.Literal("24h"), t.Literal("7d"), t.Literal("30d"), t.Literal("90d")]);
const DisplayMode = t.Union([t.Literal("compact"), t.Literal("expanded")]);
const BarFrequency = t.Union([t.Literal("hourly"), t.Literal("daily")]);
const StatusPageBody = t.Object({
slug: t.String({ minLength: 1, maxLength: 80, pattern: "^[a-z0-9][a-z0-9-]*$", description: "URL slug, lowercase + hyphens" }),
@@ -18,6 +19,8 @@ const StatusPageBody = t.Object({
show_cert_expiry: t.Optional(t.Boolean()),
default_window: t.Optional(Window),
display_mode: t.Optional(DisplayMode),
bar_frequency: t.Optional(BarFrequency),
bar_count: t.Optional(t.Number({ minimum: 1, maximum: 180 })),
custom_css: t.Optional(t.Nullable(t.String({ maxLength: 50_000 }))),
footer_text: t.Optional(t.Nullable(t.String({ maxLength: 5000 }))),
og_image_url: t.Optional(t.Nullable(t.String({ maxLength: 2048 }))),
@@ -126,6 +129,7 @@ export const statusPages = new Elysia({ prefix: "/status-pages" })
INSERT INTO status_pages (
account_id, slug, title, description, theme, password_hash, index_search,
show_powered_by, show_response_time, show_cert_expiry, default_window, display_mode,
bar_frequency, bar_count,
custom_css, footer_text, og_image_url, analytics_html, auto_refresh_s
)
VALUES (
@@ -133,6 +137,7 @@ export const statusPages = new Elysia({ prefix: "/status-pages" })
${body.theme ?? 'auto'}, ${password_hash}, ${body.index_search ?? true},
${body.show_powered_by ?? true}, ${body.show_response_time ?? true},
${body.show_cert_expiry ?? false}, ${body.default_window ?? '24h'}, ${body.display_mode ?? 'expanded'},
${body.bar_frequency ?? 'daily'}, ${body.bar_count ?? 90},
${css}, ${body.footer_text ?? null}, ${body.og_image_url ?? null},
${body.analytics_html ?? null}, ${body.auto_refresh_s ?? 60}
)
@@ -189,6 +194,8 @@ export const statusPages = new Elysia({ prefix: "/status-pages" })
show_cert_expiry = COALESCE(${body.show_cert_expiry ?? null}, show_cert_expiry),
default_window = COALESCE(${body.default_window ?? null}, default_window),
display_mode = COALESCE(${body.display_mode ?? null}, display_mode),
bar_frequency = COALESCE(${body.bar_frequency ?? null}, bar_frequency),
bar_count = COALESCE(${body.bar_count ?? null}, bar_count),
custom_css = CASE WHEN ${body.custom_css !== undefined} THEN ${css} ELSE custom_css END,
footer_text = COALESCE(${body.footer_text ?? null}, footer_text),
og_image_url = COALESCE(${body.og_image_url ?? null}, og_image_url),