Files
claudecodeui/server/src/shared/http/api-response.ts
Haileyesus 695da128f3 refactor: restructure db logic and add import alias using tsc-alias
Note: the legacy githubTokensDb migration is not included in this commit.
It's used only in `agents.js` and will be removed in a future commit. We
will directly use credentials repository instead of github tokens repository.
2026-03-25 11:22:50 +03:00

41 lines
634 B
TypeScript

import type {
ApiErrorShape,
ApiMeta,
ApiSuccessShape,
} from '@/shared/types/http.js';
export function createApiMeta(requestId?: string, startedAt?: string): ApiMeta {
return {
requestId,
startedAt,
};
}
export function createApiSuccessResponse<TData>(
data: TData,
meta?: ApiMeta
): ApiSuccessShape<TData> {
return {
success: true,
data,
meta,
};
}
export function createApiErrorResponse(
code: string,
message: string,
meta?: ApiMeta,
details?: unknown
): ApiErrorShape {
return {
success: false,
error: {
code,
message,
details,
},
meta,
};
}