Add initial PIS route

This commit is contained in:
2026-02-21 00:04:25 +00:00
parent 35bfa52531
commit 4059082416
7 changed files with 111 additions and 5 deletions

17
src/lib/errors.ts Normal file
View File

@@ -0,0 +1,17 @@
import type { ApiEnvelope } from "@owlboard/api-schema-types";
type RawErrorObject = NonNullable<ApiEnvelope.Envelope["e"]>;
export type ApiErrorCode = NonNullable<RawErrorObject['code']>
export class ApiError extends Error {
public readonly code: ApiErrorCode;
public readonly status: number;
constructor(errorObj: RawErrorObject, status: number) {
super(errorObj.msg || 'An unknown error occurred');
this.name = 'ApiError';
this.status = status;
// cast fallback to ensure it satisfies union
this.code = errorObj.code || ("SERVER" as ApiErrorCode);
}
}