- pgSchema "mesh" with 4 tables isolating the peer mesh domain - Enums: visibility, transport, tier, role - audit_log is metadata-only (E2E encryption enforced at broker/client) - Cascade on mesh delete, soft-delete via archivedAt/revokedAt Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
33 lines
861 B
TypeScript
33 lines
861 B
TypeScript
import { HttpStatusCode } from "../constants";
|
|
|
|
export const isHttpStatus = (status: number): status is HttpStatusCode =>
|
|
Object.values<number>(HttpStatusCode).includes(status);
|
|
|
|
interface HttpExceptionOptions {
|
|
message?: string;
|
|
code?: string;
|
|
}
|
|
|
|
export class HttpException extends Error {
|
|
readonly status?: HttpStatusCode;
|
|
readonly code?: string;
|
|
|
|
constructor(status?: HttpStatusCode, options?: HttpExceptionOptions) {
|
|
super(options?.message);
|
|
this.status = status;
|
|
this.code = options?.code;
|
|
}
|
|
}
|
|
|
|
export const getStatusCode = (e: unknown) => {
|
|
if (typeof e === "object" && e && "status" in e) {
|
|
const status = Number(e.status);
|
|
// Guard against NaN or invalid status codes
|
|
if (!Number.isNaN(status) && status >= 200 && status <= 599) {
|
|
return status;
|
|
}
|
|
}
|
|
|
|
return HttpStatusCode.INTERNAL_SERVER_ERROR;
|
|
};
|