feat(db): mesh data model — meshes, members, invites, audit log
- 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>
This commit is contained in:
32
packages/shared/src/utils/exceptions.ts
Normal file
32
packages/shared/src/utils/exceptions.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user