- execute: actually call isInScheduleWindow/waitForWindow/sleepBetweenJobs in runSequential (they were dead code); emit queue_status SSE events (running/paused/sleeping/idle) so the pipeline's existing QueueStatus listener lights up - review: POST /:id/retry resets an errored plan to approved, wipes old done/error jobs, rebuilds command from current decisions, queues fresh job - scan: dev-mode DELETE now also wipes jobs + subtitle_files (previously orphaned after every dev reset) - biome: migrate config to 2.4 schema, autoformat 68 files (strings + indentation), relax opinionated a11y/hooks-deps/index-key rules that don't fit this codebase - routeTree.gen.ts regenerated after /nodes removal
27 lines
855 B
TypeScript
27 lines
855 B
TypeScript
import type { Context } from "hono";
|
|
|
|
/** Parse a route param as a positive integer id. Returns null if invalid. */
|
|
export function parseId(raw: string | undefined): number | null {
|
|
if (!raw) return null;
|
|
const n = Number.parseInt(raw, 10);
|
|
return Number.isFinite(n) && n > 0 ? n : null;
|
|
}
|
|
|
|
/**
|
|
* Require a positive integer id param. Returns the id, or responds 400
|
|
* and returns null. Callers check for null and return the response.
|
|
*/
|
|
export function requireId(c: Context, name: string): number | null {
|
|
const id = parseId(c.req.param(name));
|
|
if (id == null) {
|
|
c.status(400);
|
|
return null;
|
|
}
|
|
return id;
|
|
}
|
|
|
|
/** True if value is one of the allowed strings. */
|
|
export function isOneOf<T extends string>(value: unknown, allowed: readonly T[]): value is T {
|
|
return typeof value === "string" && (allowed as readonly string[]).includes(value);
|
|
}
|